12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913939149391593916939179391893919939209392193922939239392493925939269392793928939299393093931939329393393934939359393693937939389393993940939419394293943939449394593946939479394893949939509395193952939539395493955939569395793958939599396093961939629396393964939659396693967939689396993970939719397293973939749397593976939779397893979939809398193982939839398493985939869398793988939899399093991939929399393994939959399693997939989399994000940019400294003940049400594006940079400894009940109401194012940139401494015940169401794018940199402094021940229402394024940259402694027940289402994030940319403294033940349403594036940379403894039940409404194042940439404494045940469404794048940499405094051940529405394054940559405694057940589405994060940619406294063940649406594066940679406894069940709407194072940739407494075940769407794078940799408094081940829408394084940859408694087940889408994090940919409294093940949409594096940979409894099941009410194102941039410494105941069410794108941099411094111941129411394114941159411694117941189411994120941219412294123941249412594126941279412894129941309413194132941339413494135941369413794138941399414094141941429414394144941459414694147941489414994150941519415294153941549415594156941579415894159941609416194162941639416494165941669416794168941699417094171941729417394174941759417694177941789417994180941819418294183941849418594186941879418894189941909419194192941939419494195941969419794198941999420094201942029420394204942059420694207942089420994210942119421294213942149421594216942179421894219942209422194222942239422494225942269422794228942299423094231942329423394234942359423694237942389423994240942419424294243942449424594246942479424894249942509425194252942539425494255942569425794258942599426094261942629426394264942659426694267942689426994270942719427294273942749427594276942779427894279942809428194282942839428494285942869428794288942899429094291942929429394294942959429694297942989429994300943019430294303943049430594306943079430894309943109431194312943139431494315943169431794318943199432094321943229432394324943259432694327943289432994330943319433294333943349433594336943379433894339943409434194342943439434494345943469434794348943499435094351943529435394354943559435694357943589435994360943619436294363943649436594366943679436894369943709437194372943739437494375943769437794378943799438094381943829438394384943859438694387943889438994390943919439294393943949439594396943979439894399944009440194402944039440494405944069440794408944099441094411944129441394414944159441694417944189441994420944219442294423944249442594426944279442894429944309443194432944339443494435944369443794438944399444094441944429444394444944459444694447944489444994450944519445294453944549445594456944579445894459944609446194462944639446494465944669446794468944699447094471944729447394474944759447694477944789447994480944819448294483944849448594486944879448894489944909449194492944939449494495944969449794498944999450094501945029450394504945059450694507945089450994510945119451294513945149451594516945179451894519945209452194522945239452494525945269452794528945299453094531945329453394534945359453694537945389453994540945419454294543945449454594546945479454894549945509455194552945539455494555945569455794558945599456094561945629456394564945659456694567945689456994570945719457294573945749457594576945779457894579945809458194582945839458494585945869458794588945899459094591945929459394594945959459694597945989459994600946019460294603946049460594606946079460894609946109461194612946139461494615946169461794618946199462094621946229462394624946259462694627946289462994630946319463294633946349463594636946379463894639946409464194642946439464494645946469464794648946499465094651946529465394654946559465694657946589465994660946619466294663946649466594666946679466894669946709467194672946739467494675946769467794678946799468094681946829468394684946859468694687946889468994690946919469294693946949469594696946979469894699947009470194702947039470494705947069470794708947099471094711947129471394714947159471694717947189471994720947219472294723947249472594726947279472894729947309473194732947339473494735947369473794738947399474094741947429474394744947459474694747947489474994750947519475294753947549475594756947579475894759947609476194762947639476494765947669476794768947699477094771947729477394774947759477694777947789477994780947819478294783947849478594786947879478894789947909479194792947939479494795947969479794798947999480094801948029480394804948059480694807948089480994810948119481294813948149481594816948179481894819948209482194822948239482494825948269482794828948299483094831948329483394834948359483694837948389483994840948419484294843948449484594846948479484894849948509485194852948539485494855948569485794858948599486094861948629486394864948659486694867948689486994870948719487294873948749487594876948779487894879948809488194882948839488494885948869488794888948899489094891948929489394894948959489694897948989489994900949019490294903949049490594906949079490894909949109491194912949139491494915949169491794918949199492094921949229492394924949259492694927949289492994930949319493294933949349493594936949379493894939949409494194942949439494494945949469494794948949499495094951949529495394954949559495694957949589495994960949619496294963949649496594966949679496894969949709497194972949739497494975949769497794978949799498094981949829498394984949859498694987949889498994990949919499294993949949499594996949979499894999950009500195002950039500495005950069500795008950099501095011950129501395014950159501695017950189501995020950219502295023950249502595026950279502895029950309503195032950339503495035950369503795038950399504095041950429504395044950459504695047950489504995050950519505295053950549505595056950579505895059950609506195062950639506495065950669506795068950699507095071950729507395074950759507695077950789507995080950819508295083950849508595086950879508895089950909509195092950939509495095950969509795098950999510095101951029510395104951059510695107951089510995110951119511295113951149511595116951179511895119951209512195122951239512495125951269512795128951299513095131951329513395134951359513695137951389513995140951419514295143951449514595146951479514895149951509515195152951539515495155951569515795158951599516095161951629516395164951659516695167951689516995170951719517295173951749517595176951779517895179951809518195182951839518495185951869518795188951899519095191951929519395194951959519695197951989519995200952019520295203952049520595206952079520895209952109521195212952139521495215952169521795218952199522095221952229522395224952259522695227952289522995230952319523295233952349523595236952379523895239952409524195242952439524495245952469524795248952499525095251952529525395254952559525695257952589525995260952619526295263952649526595266952679526895269952709527195272952739527495275952769527795278952799528095281952829528395284952859528695287952889528995290952919529295293952949529595296952979529895299953009530195302953039530495305953069530795308953099531095311953129531395314953159531695317953189531995320953219532295323953249532595326953279532895329953309533195332953339533495335953369533795338953399534095341953429534395344953459534695347953489534995350953519535295353953549535595356953579535895359953609536195362953639536495365953669536795368953699537095371953729537395374953759537695377953789537995380953819538295383953849538595386953879538895389953909539195392953939539495395953969539795398953999540095401954029540395404954059540695407954089540995410954119541295413954149541595416954179541895419954209542195422954239542495425954269542795428954299543095431954329543395434954359543695437954389543995440954419544295443954449544595446954479544895449954509545195452954539545495455954569545795458954599546095461954629546395464954659546695467954689546995470954719547295473954749547595476954779547895479954809548195482954839548495485954869548795488954899549095491954929549395494954959549695497954989549995500955019550295503955049550595506955079550895509955109551195512955139551495515955169551795518955199552095521955229552395524955259552695527955289552995530955319553295533955349553595536955379553895539955409554195542955439554495545955469554795548955499555095551955529555395554955559555695557955589555995560955619556295563955649556595566955679556895569955709557195572955739557495575955769557795578955799558095581955829558395584955859558695587955889558995590955919559295593955949559595596955979559895599956009560195602956039560495605956069560795608956099561095611956129561395614956159561695617956189561995620956219562295623956249562595626956279562895629956309563195632956339563495635956369563795638956399564095641956429564395644956459564695647956489564995650956519565295653956549565595656956579565895659956609566195662956639566495665956669566795668956699567095671956729567395674956759567695677956789567995680956819568295683956849568595686956879568895689956909569195692956939569495695956969569795698956999570095701957029570395704957059570695707957089570995710957119571295713957149571595716957179571895719957209572195722957239572495725957269572795728957299573095731957329573395734957359573695737957389573995740957419574295743957449574595746957479574895749957509575195752957539575495755957569575795758957599576095761957629576395764957659576695767957689576995770957719577295773957749577595776957779577895779957809578195782957839578495785957869578795788957899579095791957929579395794957959579695797957989579995800958019580295803958049580595806958079580895809958109581195812958139581495815958169581795818958199582095821958229582395824958259582695827958289582995830958319583295833958349583595836958379583895839958409584195842958439584495845958469584795848958499585095851958529585395854958559585695857958589585995860958619586295863958649586595866958679586895869958709587195872958739587495875958769587795878958799588095881958829588395884958859588695887958889588995890958919589295893958949589595896958979589895899959009590195902959039590495905959069590795908959099591095911959129591395914959159591695917959189591995920959219592295923959249592595926959279592895929959309593195932959339593495935959369593795938959399594095941959429594395944959459594695947959489594995950959519595295953959549595595956959579595895959959609596195962959639596495965959669596795968959699597095971959729597395974959759597695977959789597995980959819598295983959849598595986959879598895989959909599195992959939599495995959969599795998959999600096001960029600396004960059600696007960089600996010960119601296013960149601596016960179601896019960209602196022960239602496025960269602796028960299603096031960329603396034960359603696037960389603996040960419604296043960449604596046960479604896049960509605196052960539605496055960569605796058960599606096061960629606396064960659606696067960689606996070960719607296073960749607596076960779607896079960809608196082960839608496085960869608796088960899609096091960929609396094960959609696097960989609996100961019610296103961049610596106961079610896109961109611196112961139611496115961169611796118961199612096121961229612396124961259612696127961289612996130961319613296133961349613596136961379613896139961409614196142961439614496145961469614796148961499615096151961529615396154961559615696157961589615996160961619616296163961649616596166961679616896169961709617196172961739617496175961769617796178961799618096181961829618396184961859618696187961889618996190961919619296193961949619596196961979619896199962009620196202962039620496205962069620796208962099621096211962129621396214962159621696217962189621996220962219622296223962249622596226962279622896229962309623196232962339623496235962369623796238962399624096241962429624396244962459624696247962489624996250962519625296253962549625596256962579625896259962609626196262962639626496265962669626796268962699627096271962729627396274962759627696277962789627996280962819628296283962849628596286962879628896289962909629196292962939629496295962969629796298962999630096301963029630396304963059630696307963089630996310963119631296313963149631596316963179631896319963209632196322963239632496325963269632796328963299633096331963329633396334963359633696337963389633996340963419634296343963449634596346963479634896349963509635196352963539635496355963569635796358963599636096361963629636396364963659636696367963689636996370963719637296373963749637596376963779637896379963809638196382963839638496385963869638796388963899639096391963929639396394963959639696397963989639996400964019640296403964049640596406964079640896409964109641196412964139641496415964169641796418964199642096421964229642396424964259642696427964289642996430964319643296433964349643596436964379643896439964409644196442964439644496445964469644796448964499645096451964529645396454964559645696457964589645996460964619646296463964649646596466964679646896469964709647196472964739647496475964769647796478964799648096481964829648396484964859648696487964889648996490964919649296493964949649596496964979649896499965009650196502965039650496505965069650796508965099651096511965129651396514965159651696517965189651996520965219652296523965249652596526965279652896529965309653196532965339653496535965369653796538965399654096541965429654396544965459654696547965489654996550965519655296553965549655596556965579655896559965609656196562965639656496565965669656796568965699657096571965729657396574965759657696577965789657996580965819658296583965849658596586965879658896589965909659196592965939659496595965969659796598965999660096601966029660396604966059660696607966089660996610966119661296613966149661596616966179661896619966209662196622966239662496625966269662796628966299663096631966329663396634966359663696637966389663996640966419664296643966449664596646966479664896649966509665196652966539665496655966569665796658966599666096661966629666396664966659666696667966689666996670966719667296673966749667596676966779667896679966809668196682966839668496685966869668796688966899669096691966929669396694966959669696697966989669996700967019670296703967049670596706967079670896709967109671196712967139671496715967169671796718967199672096721967229672396724967259672696727967289672996730967319673296733967349673596736967379673896739967409674196742967439674496745967469674796748967499675096751967529675396754967559675696757967589675996760967619676296763967649676596766967679676896769967709677196772967739677496775967769677796778967799678096781967829678396784967859678696787967889678996790967919679296793967949679596796967979679896799968009680196802968039680496805968069680796808968099681096811968129681396814968159681696817968189681996820968219682296823968249682596826968279682896829968309683196832968339683496835968369683796838968399684096841968429684396844968459684696847968489684996850968519685296853968549685596856968579685896859968609686196862968639686496865968669686796868968699687096871968729687396874968759687696877968789687996880968819688296883968849688596886968879688896889968909689196892968939689496895968969689796898968999690096901969029690396904969059690696907969089690996910969119691296913969149691596916969179691896919969209692196922969239692496925969269692796928969299693096931969329693396934969359693696937969389693996940969419694296943969449694596946969479694896949969509695196952969539695496955969569695796958969599696096961969629696396964969659696696967969689696996970969719697296973969749697596976969779697896979969809698196982969839698496985969869698796988969899699096991969929699396994969959699696997969989699997000970019700297003970049700597006970079700897009970109701197012970139701497015970169701797018970199702097021970229702397024970259702697027970289702997030970319703297033970349703597036970379703897039970409704197042970439704497045970469704797048970499705097051970529705397054970559705697057970589705997060970619706297063970649706597066970679706897069970709707197072970739707497075970769707797078970799708097081970829708397084970859708697087970889708997090970919709297093970949709597096970979709897099971009710197102971039710497105971069710797108971099711097111971129711397114971159711697117971189711997120971219712297123971249712597126971279712897129971309713197132971339713497135971369713797138971399714097141971429714397144971459714697147971489714997150971519715297153971549715597156971579715897159971609716197162971639716497165971669716797168971699717097171971729717397174971759717697177971789717997180971819718297183971849718597186971879718897189971909719197192971939719497195971969719797198971999720097201972029720397204972059720697207972089720997210972119721297213972149721597216972179721897219972209722197222972239722497225972269722797228972299723097231972329723397234972359723697237972389723997240972419724297243972449724597246972479724897249972509725197252972539725497255972569725797258972599726097261972629726397264972659726697267972689726997270972719727297273972749727597276972779727897279972809728197282972839728497285972869728797288972899729097291972929729397294972959729697297972989729997300973019730297303973049730597306973079730897309973109731197312973139731497315973169731797318973199732097321973229732397324973259732697327973289732997330973319733297333973349733597336973379733897339973409734197342973439734497345973469734797348973499735097351973529735397354973559735697357973589735997360973619736297363973649736597366973679736897369973709737197372973739737497375973769737797378973799738097381973829738397384973859738697387973889738997390973919739297393973949739597396973979739897399974009740197402974039740497405974069740797408974099741097411974129741397414974159741697417974189741997420974219742297423974249742597426974279742897429974309743197432974339743497435974369743797438974399744097441974429744397444974459744697447974489744997450974519745297453974549745597456974579745897459974609746197462974639746497465974669746797468974699747097471974729747397474974759747697477974789747997480974819748297483974849748597486974879748897489974909749197492974939749497495974969749797498974999750097501975029750397504975059750697507975089750997510975119751297513975149751597516975179751897519975209752197522975239752497525975269752797528975299753097531975329753397534975359753697537975389753997540975419754297543975449754597546975479754897549975509755197552975539755497555975569755797558975599756097561975629756397564975659756697567975689756997570975719757297573975749757597576975779757897579975809758197582975839758497585975869758797588975899759097591975929759397594975959759697597975989759997600976019760297603976049760597606976079760897609976109761197612976139761497615976169761797618976199762097621976229762397624976259762697627976289762997630976319763297633976349763597636976379763897639976409764197642976439764497645976469764797648976499765097651976529765397654976559765697657976589765997660976619766297663976649766597666976679766897669976709767197672976739767497675976769767797678976799768097681976829768397684976859768697687976889768997690976919769297693976949769597696976979769897699977009770197702977039770497705977069770797708977099771097711977129771397714977159771697717977189771997720977219772297723977249772597726977279772897729977309773197732977339773497735977369773797738977399774097741977429774397744977459774697747977489774997750977519775297753977549775597756977579775897759977609776197762977639776497765977669776797768977699777097771977729777397774977759777697777977789777997780977819778297783977849778597786977879778897789977909779197792977939779497795977969779797798977999780097801978029780397804978059780697807978089780997810978119781297813978149781597816978179781897819978209782197822978239782497825978269782797828978299783097831978329783397834978359783697837978389783997840978419784297843978449784597846978479784897849978509785197852978539785497855978569785797858978599786097861978629786397864978659786697867978689786997870978719787297873978749787597876978779787897879978809788197882978839788497885978869788797888978899789097891978929789397894978959789697897978989789997900979019790297903979049790597906979079790897909979109791197912979139791497915979169791797918979199792097921979229792397924979259792697927979289792997930979319793297933979349793597936979379793897939979409794197942979439794497945979469794797948979499795097951979529795397954979559795697957979589795997960979619796297963979649796597966979679796897969979709797197972979739797497975979769797797978979799798097981979829798397984979859798697987979889798997990979919799297993979949799597996979979799897999980009800198002980039800498005980069800798008980099801098011980129801398014980159801698017980189801998020980219802298023980249802598026980279802898029980309803198032980339803498035980369803798038980399804098041980429804398044980459804698047980489804998050980519805298053980549805598056980579805898059980609806198062980639806498065980669806798068980699807098071980729807398074980759807698077980789807998080980819808298083980849808598086980879808898089980909809198092980939809498095980969809798098980999810098101981029810398104981059810698107981089810998110981119811298113981149811598116981179811898119981209812198122981239812498125981269812798128981299813098131981329813398134981359813698137981389813998140981419814298143981449814598146981479814898149981509815198152981539815498155981569815798158981599816098161981629816398164981659816698167981689816998170981719817298173981749817598176981779817898179981809818198182981839818498185981869818798188981899819098191981929819398194981959819698197981989819998200982019820298203982049820598206982079820898209982109821198212982139821498215982169821798218982199822098221982229822398224982259822698227982289822998230982319823298233982349823598236982379823898239982409824198242982439824498245982469824798248982499825098251982529825398254982559825698257982589825998260982619826298263982649826598266982679826898269982709827198272982739827498275982769827798278982799828098281982829828398284982859828698287982889828998290982919829298293982949829598296982979829898299983009830198302983039830498305983069830798308983099831098311983129831398314983159831698317983189831998320983219832298323983249832598326983279832898329983309833198332983339833498335983369833798338983399834098341983429834398344983459834698347983489834998350983519835298353983549835598356983579835898359983609836198362983639836498365983669836798368983699837098371983729837398374983759837698377983789837998380983819838298383983849838598386983879838898389983909839198392983939839498395983969839798398983999840098401984029840398404984059840698407984089840998410984119841298413984149841598416984179841898419984209842198422984239842498425984269842798428984299843098431984329843398434984359843698437984389843998440984419844298443984449844598446984479844898449984509845198452984539845498455984569845798458984599846098461984629846398464984659846698467984689846998470984719847298473984749847598476984779847898479984809848198482984839848498485984869848798488984899849098491984929849398494984959849698497984989849998500985019850298503985049850598506985079850898509985109851198512985139851498515985169851798518985199852098521985229852398524985259852698527985289852998530985319853298533985349853598536985379853898539985409854198542985439854498545 |
- 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){
- module.exports=[
- {
- "constant": true,
- "inputs": [
- {
- "name": "_owner",
- "type": "address"
- }
- ],
- "name": "name",
- "outputs": [
- {
- "name": "o_name",
- "type": "bytes32"
- }
- ],
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "owner",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "content",
- "outputs": [
- {
- "name": "",
- "type": "bytes32"
- }
- ],
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "addr",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "reserve",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "subRegistrar",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_newOwner",
- "type": "address"
- }
- ],
- "name": "transfer",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_registrar",
- "type": "address"
- }
- ],
- "name": "setSubRegistrar",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [],
- "name": "Registrar",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_a",
- "type": "address"
- },
- {
- "name": "_primary",
- "type": "bool"
- }
- ],
- "name": "setAddress",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_content",
- "type": "bytes32"
- }
- ],
- "name": "setContent",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "disown",
- "outputs": [],
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "_name",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "_winner",
- "type": "address"
- }
- ],
- "name": "AuctionEnded",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "_name",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "_bidder",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "NewBid",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "name",
- "type": "bytes32"
- }
- ],
- "name": "Changed",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "name",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "name": "addr",
- "type": "address"
- }
- ],
- "name": "PrimaryChanged",
- "type": "event"
- }
- ]
- },{}],2:[function(require,module,exports){
- module.exports=[
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "owner",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_refund",
- "type": "address"
- }
- ],
- "name": "disown",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "addr",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- }
- ],
- "name": "reserve",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_newOwner",
- "type": "address"
- }
- ],
- "name": "transfer",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_name",
- "type": "bytes32"
- },
- {
- "name": "_a",
- "type": "address"
- }
- ],
- "name": "setAddr",
- "outputs": [],
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "name",
- "type": "bytes32"
- }
- ],
- "name": "Changed",
- "type": "event"
- }
- ]
- },{}],3:[function(require,module,exports){
- module.exports=[
- {
- "constant": false,
- "inputs": [
- {
- "name": "from",
- "type": "bytes32"
- },
- {
- "name": "to",
- "type": "address"
- },
- {
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "transfer",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "from",
- "type": "bytes32"
- },
- {
- "name": "to",
- "type": "address"
- },
- {
- "name": "indirectId",
- "type": "bytes32"
- },
- {
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "icapTransfer",
- "outputs": [],
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "to",
- "type": "bytes32"
- }
- ],
- "name": "deposit",
- "outputs": [],
- "payable": true,
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "from",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "AnonymousDeposit",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "from",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "to",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "Deposit",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "from",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "name": "to",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "Transfer",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "from",
- "type": "bytes32"
- },
- {
- "indexed": true,
- "name": "to",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "indirectId",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "IcapTransfer",
- "type": "event"
- }
- ]
- },{}],4:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeAddress is a prootype that represents address type
- * It matches:
- * address
- * address[]
- * address[4]
- * address[][]
- * address[3][]
- * address[][6][], ...
- */
- var SolidityTypeAddress = function () {
- this._inputFormatter = f.formatInputInt;
- this._outputFormatter = f.formatOutputAddress;
- };
- SolidityTypeAddress.prototype = new SolidityType({});
- SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
- SolidityTypeAddress.prototype.isType = function (name) {
- return !!name.match(/address(\[([0-9]*)\])?/);
- };
- module.exports = SolidityTypeAddress;
- },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeBool is a prootype that represents bool type
- * It matches:
- * bool
- * bool[]
- * bool[4]
- * bool[][]
- * bool[3][]
- * bool[][6][], ...
- */
- var SolidityTypeBool = function () {
- this._inputFormatter = f.formatInputBool;
- this._outputFormatter = f.formatOutputBool;
- };
- SolidityTypeBool.prototype = new SolidityType({});
- SolidityTypeBool.prototype.constructor = SolidityTypeBool;
- SolidityTypeBool.prototype.isType = function (name) {
- return !!name.match(/^bool(\[([0-9]*)\])*$/);
- };
- module.exports = SolidityTypeBool;
- },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeBytes is a prototype that represents the bytes type.
- * It matches:
- * bytes
- * bytes[]
- * bytes[4]
- * bytes[][]
- * bytes[3][]
- * bytes[][6][], ...
- * bytes32
- * bytes8[4]
- * bytes[3][]
- */
- var SolidityTypeBytes = function () {
- this._inputFormatter = f.formatInputBytes;
- this._outputFormatter = f.formatOutputBytes;
- };
- SolidityTypeBytes.prototype = new SolidityType({});
- SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
- SolidityTypeBytes.prototype.isType = function (name) {
- return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
- };
- module.exports = SolidityTypeBytes;
- },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file coder.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var f = require('./formatters');
- var SolidityTypeAddress = require('./address');
- var SolidityTypeBool = require('./bool');
- var SolidityTypeInt = require('./int');
- var SolidityTypeUInt = require('./uint');
- var SolidityTypeDynamicBytes = require('./dynamicbytes');
- var SolidityTypeString = require('./string');
- var SolidityTypeReal = require('./real');
- var SolidityTypeUReal = require('./ureal');
- var SolidityTypeBytes = require('./bytes');
- var isDynamic = function (solidityType, type) {
- return solidityType.isDynamicType(type) ||
- solidityType.isDynamicArray(type);
- };
- /**
- * SolidityCoder prototype should be used to encode/decode solidity params of any type
- */
- var SolidityCoder = function (types) {
- this._types = types;
- };
- /**
- * This method should be used to transform type to SolidityType
- *
- * @method _requireType
- * @param {String} type
- * @returns {SolidityType}
- * @throws {Error} throws if no matching type is found
- */
- SolidityCoder.prototype._requireType = function (type) {
- var solidityType = this._types.filter(function (t) {
- return t.isType(type);
- })[0];
- if (!solidityType) {
- throw Error('invalid solidity type!: ' + type);
- }
- return solidityType;
- };
- /**
- * Should be used to encode plain param
- *
- * @method encodeParam
- * @param {String} type
- * @param {Object} plain param
- * @return {String} encoded plain param
- */
- SolidityCoder.prototype.encodeParam = function (type, param) {
- return this.encodeParams([type], [param]);
- };
- /**
- * Should be used to encode list of params
- *
- * @method encodeParams
- * @param {Array} types
- * @param {Array} params
- * @return {String} encoded list of params
- */
- SolidityCoder.prototype.encodeParams = function (types, params) {
- var solidityTypes = this.getSolidityTypes(types);
- var encodeds = solidityTypes.map(function (solidityType, index) {
- return solidityType.encode(params[index], types[index]);
- });
- var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
- var staticPartLength = solidityType.staticPartLength(types[index]);
- var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
- return acc + (isDynamic(solidityTypes[index], types[index]) ?
- 32 :
- roundedStaticPartLength);
- }, 0);
- var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
- return result;
- };
- SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
- var result = "";
- var self = this;
- types.forEach(function (type, i) {
- if (isDynamic(solidityTypes[i], types[i])) {
- result += f.formatInputInt(dynamicOffset).encode();
- var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
- dynamicOffset += e.length / 2;
- } else {
- // don't add length to dynamicOffset. it's already counted
- result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
- }
- // TODO: figure out nested arrays
- });
- types.forEach(function (type, i) {
- if (isDynamic(solidityTypes[i], types[i])) {
- var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
- dynamicOffset += e.length / 2;
- result += e;
- }
- });
- return result;
- };
- // TODO: refactor whole encoding!
- SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
- var self = this;
- if (solidityType.isDynamicArray(type)) {
- return (function () {
- // offset was already set
- var nestedName = solidityType.nestedName(type);
- var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
- var result = encoded[0];
- (function () {
- var previousLength = 2; // in int
- if (solidityType.isDynamicArray(nestedName)) {
- for (var i = 1; i < encoded.length; i++) {
- previousLength += +(encoded[i - 1])[0] || 0;
- result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
- }
- }
- })();
- // first element is length, skip it
- (function () {
- for (var i = 0; i < encoded.length - 1; i++) {
- var additionalOffset = result / 2;
- result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset + additionalOffset);
- }
- })();
- return result;
- })();
- } else if (solidityType.isStaticArray(type)) {
- return (function () {
- var nestedName = solidityType.nestedName(type);
- var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
- var result = "";
- if (solidityType.isDynamicArray(nestedName)) {
- (function () {
- var previousLength = 0; // in int
- for (var i = 0; i < encoded.length; i++) {
- // calculate length of previous item
- previousLength += +(encoded[i - 1] || [])[0] || 0;
- result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
- }
- })();
- }
- (function () {
- for (var i = 0; i < encoded.length; i++) {
- var additionalOffset = result / 2;
- result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
- }
- })();
- return result;
- })();
- }
- return encoded;
- };
- /**
- * Should be used to decode bytes to plain param
- *
- * @method decodeParam
- * @param {String} type
- * @param {String} bytes
- * @return {Object} plain param
- */
- SolidityCoder.prototype.decodeParam = function (type, bytes) {
- return this.decodeParams([type], bytes)[0];
- };
- /**
- * Should be used to decode list of params
- *
- * @method decodeParam
- * @param {Array} types
- * @param {String} bytes
- * @return {Array} array of plain params
- */
- SolidityCoder.prototype.decodeParams = function (types, bytes) {
- var solidityTypes = this.getSolidityTypes(types);
- var offsets = this.getOffsets(types, solidityTypes);
- return solidityTypes.map(function (solidityType, index) {
- return solidityType.decode(bytes, offsets[index], types[index], index);
- });
- };
- SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
- var lengths = solidityTypes.map(function (solidityType, index) {
- return solidityType.staticPartLength(types[index]);
- });
- for (var i = 1; i < lengths.length; i++) {
- // sum with length of previous element
- lengths[i] += lengths[i - 1];
- }
- return lengths.map(function (length, index) {
- // remove the current length, so the length is sum of previous elements
- var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
- return length - staticPartLength;
- });
- };
- SolidityCoder.prototype.getSolidityTypes = function (types) {
- var self = this;
- return types.map(function (type) {
- return self._requireType(type);
- });
- };
- var coder = new SolidityCoder([
- new SolidityTypeAddress(),
- new SolidityTypeBool(),
- new SolidityTypeInt(),
- new SolidityTypeUInt(),
- new SolidityTypeDynamicBytes(),
- new SolidityTypeBytes(),
- new SolidityTypeString(),
- new SolidityTypeReal(),
- new SolidityTypeUReal()
- ]);
- module.exports = coder;
- },{"./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){
- var f = require('./formatters');
- var SolidityType = require('./type');
- var SolidityTypeDynamicBytes = function () {
- this._inputFormatter = f.formatInputDynamicBytes;
- this._outputFormatter = f.formatOutputDynamicBytes;
- };
- SolidityTypeDynamicBytes.prototype = new SolidityType({});
- SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
- SolidityTypeDynamicBytes.prototype.isType = function (name) {
- return !!name.match(/^bytes(\[([0-9]*)\])*$/);
- };
- SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
- return true;
- };
- module.exports = SolidityTypeDynamicBytes;
- },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file formatters.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var BigNumber = require('bignumber.js');
- var utils = require('../utils/utils');
- var c = require('../utils/config');
- var SolidityParam = require('./param');
- /**
- * Formats input value to byte representation of int
- * If value is negative, return it's two's complement
- * If the value is floating point, round it down
- *
- * @method formatInputInt
- * @param {String|Number|BigNumber} value that needs to be formatted
- * @returns {SolidityParam}
- */
- var formatInputInt = function (value) {
- BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
- var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
- return new SolidityParam(result);
- };
- /**
- * Formats input bytes
- *
- * @method formatInputBytes
- * @param {String}
- * @returns {SolidityParam}
- */
- var formatInputBytes = function (value) {
- var result = utils.toHex(value).substr(2);
- var l = Math.floor((result.length + 63) / 64);
- result = utils.padRight(result, l * 64);
- return new SolidityParam(result);
- };
- /**
- * Formats input bytes
- *
- * @method formatDynamicInputBytes
- * @param {String}
- * @returns {SolidityParam}
- */
- var formatInputDynamicBytes = function (value) {
- var result = utils.toHex(value).substr(2);
- var length = result.length / 2;
- var l = Math.floor((result.length + 63) / 64);
- result = utils.padRight(result, l * 64);
- return new SolidityParam(formatInputInt(length).value + result);
- };
- /**
- * Formats input value to byte representation of string
- *
- * @method formatInputString
- * @param {String}
- * @returns {SolidityParam}
- */
- var formatInputString = function (value) {
- var result = utils.fromUtf8(value).substr(2);
- var length = result.length / 2;
- var l = Math.floor((result.length + 63) / 64);
- result = utils.padRight(result, l * 64);
- return new SolidityParam(formatInputInt(length).value + result);
- };
- /**
- * Formats input value to byte representation of bool
- *
- * @method formatInputBool
- * @param {Boolean}
- * @returns {SolidityParam}
- */
- var formatInputBool = function (value) {
- var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
- return new SolidityParam(result);
- };
- /**
- * Formats input value to byte representation of real
- * Values are multiplied by 2^m and encoded as integers
- *
- * @method formatInputReal
- * @param {String|Number|BigNumber}
- * @returns {SolidityParam}
- */
- var formatInputReal = function (value) {
- return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
- };
- /**
- * Check if input value is negative
- *
- * @method signedIsNegative
- * @param {String} value is hex format
- * @returns {Boolean} true if it is negative, otherwise false
- */
- var signedIsNegative = function (value) {
- return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
- };
- /**
- * Formats right-aligned output bytes to int
- *
- * @method formatOutputInt
- * @param {SolidityParam} param
- * @returns {BigNumber} right-aligned output bytes formatted to big number
- */
- var formatOutputInt = function (param) {
- var value = param.staticPart() || "0";
- // check if it's negative number
- // it it is, return two's complement
- if (signedIsNegative(value)) {
- return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
- }
- return new BigNumber(value, 16);
- };
- /**
- * Formats right-aligned output bytes to uint
- *
- * @method formatOutputUInt
- * @param {SolidityParam}
- * @returns {BigNumeber} right-aligned output bytes formatted to uint
- */
- var formatOutputUInt = function (param) {
- var value = param.staticPart() || "0";
- return new BigNumber(value, 16);
- };
- /**
- * Formats right-aligned output bytes to real
- *
- * @method formatOutputReal
- * @param {SolidityParam}
- * @returns {BigNumber} input bytes formatted to real
- */
- var formatOutputReal = function (param) {
- return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
- };
- /**
- * Formats right-aligned output bytes to ureal
- *
- * @method formatOutputUReal
- * @param {SolidityParam}
- * @returns {BigNumber} input bytes formatted to ureal
- */
- var formatOutputUReal = function (param) {
- return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
- };
- /**
- * Should be used to format output bool
- *
- * @method formatOutputBool
- * @param {SolidityParam}
- * @returns {Boolean} right-aligned input bytes formatted to bool
- */
- var formatOutputBool = function (param) {
- return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
- };
- /**
- * Should be used to format output bytes
- *
- * @method formatOutputBytes
- * @param {SolidityParam} left-aligned hex representation of string
- * @param {String} name type name
- * @returns {String} hex string
- */
- var formatOutputBytes = function (param, name) {
- var matches = name.match(/^bytes([0-9]*)/);
- var size = parseInt(matches[1]);
- return '0x' + param.staticPart().slice(0, 2 * size);
- };
- /**
- * Should be used to format output bytes
- *
- * @method formatOutputDynamicBytes
- * @param {SolidityParam} left-aligned hex representation of string
- * @returns {String} hex string
- */
- var formatOutputDynamicBytes = function (param) {
- var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
- return '0x' + param.dynamicPart().substr(64, length);
- };
- /**
- * Should be used to format output string
- *
- * @method formatOutputString
- * @param {SolidityParam} left-aligned hex representation of string
- * @returns {String} ascii string
- */
- var formatOutputString = function (param) {
- var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
- return utils.toUtf8(param.dynamicPart().substr(64, length));
- };
- /**
- * Should be used to format output address
- *
- * @method formatOutputAddress
- * @param {SolidityParam} right-aligned input bytes
- * @returns {String} address
- */
- var formatOutputAddress = function (param) {
- var value = param.staticPart();
- return "0x" + value.slice(value.length - 40, value.length);
- };
- module.exports = {
- formatInputInt: formatInputInt,
- formatInputBytes: formatInputBytes,
- formatInputDynamicBytes: formatInputDynamicBytes,
- formatInputString: formatInputString,
- formatInputBool: formatInputBool,
- formatInputReal: formatInputReal,
- formatOutputInt: formatOutputInt,
- formatOutputUInt: formatOutputUInt,
- formatOutputReal: formatOutputReal,
- formatOutputUReal: formatOutputUReal,
- formatOutputBool: formatOutputBool,
- formatOutputBytes: formatOutputBytes,
- formatOutputDynamicBytes: formatOutputDynamicBytes,
- formatOutputString: formatOutputString,
- formatOutputAddress: formatOutputAddress
- };
- },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeInt is a prootype that represents int type
- * It matches:
- * int
- * int[]
- * int[4]
- * int[][]
- * int[3][]
- * int[][6][], ...
- * int32
- * int64[]
- * int8[4]
- * int256[][]
- * int[3][]
- * int64[][6][], ...
- */
- var SolidityTypeInt = function () {
- this._inputFormatter = f.formatInputInt;
- this._outputFormatter = f.formatOutputInt;
- };
- SolidityTypeInt.prototype = new SolidityType({});
- SolidityTypeInt.prototype.constructor = SolidityTypeInt;
- SolidityTypeInt.prototype.isType = function (name) {
- return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
- };
- module.exports = SolidityTypeInt;
- },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file param.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var utils = require('../utils/utils');
- /**
- * SolidityParam object prototype.
- * Should be used when encoding, decoding solidity bytes
- */
- var SolidityParam = function (value, offset) {
- this.value = value || '';
- this.offset = offset; // offset in bytes
- };
- /**
- * This method should be used to get length of params's dynamic part
- *
- * @method dynamicPartLength
- * @returns {Number} length of dynamic part (in bytes)
- */
- SolidityParam.prototype.dynamicPartLength = function () {
- return this.dynamicPart().length / 2;
- };
- /**
- * This method should be used to create copy of solidity param with different offset
- *
- * @method withOffset
- * @param {Number} offset length in bytes
- * @returns {SolidityParam} new solidity param with applied offset
- */
- SolidityParam.prototype.withOffset = function (offset) {
- return new SolidityParam(this.value, offset);
- };
- /**
- * This method should be used to combine solidity params together
- * eg. when appending an array
- *
- * @method combine
- * @param {SolidityParam} param with which we should combine
- * @param {SolidityParam} result of combination
- */
- SolidityParam.prototype.combine = function (param) {
- return new SolidityParam(this.value + param.value);
- };
- /**
- * This method should be called to check if param has dynamic size.
- * If it has, it returns true, otherwise false
- *
- * @method isDynamic
- * @returns {Boolean}
- */
- SolidityParam.prototype.isDynamic = function () {
- return this.offset !== undefined;
- };
- /**
- * This method should be called to transform offset to bytes
- *
- * @method offsetAsBytes
- * @returns {String} bytes representation of offset
- */
- SolidityParam.prototype.offsetAsBytes = function () {
- return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
- };
- /**
- * This method should be called to get static part of param
- *
- * @method staticPart
- * @returns {String} offset if it is a dynamic param, otherwise value
- */
- SolidityParam.prototype.staticPart = function () {
- if (!this.isDynamic()) {
- return this.value;
- }
- return this.offsetAsBytes();
- };
- /**
- * This method should be called to get dynamic part of param
- *
- * @method dynamicPart
- * @returns {String} returns a value if it is a dynamic param, otherwise empty string
- */
- SolidityParam.prototype.dynamicPart = function () {
- return this.isDynamic() ? this.value : '';
- };
- /**
- * This method should be called to encode param
- *
- * @method encode
- * @returns {String}
- */
- SolidityParam.prototype.encode = function () {
- return this.staticPart() + this.dynamicPart();
- };
- /**
- * This method should be called to encode array of params
- *
- * @method encodeList
- * @param {Array[SolidityParam]} params
- * @returns {String}
- */
- SolidityParam.encodeList = function (params) {
-
- // updating offsets
- var totalOffset = params.length * 32;
- var offsetParams = params.map(function (param) {
- if (!param.isDynamic()) {
- return param;
- }
- var offset = totalOffset;
- totalOffset += param.dynamicPartLength();
- return param.withOffset(offset);
- });
- // encode everything!
- return offsetParams.reduce(function (result, param) {
- return result + param.dynamicPart();
- }, offsetParams.reduce(function (result, param) {
- return result + param.staticPart();
- }, ''));
- };
- module.exports = SolidityParam;
- },{"../utils/utils":20}],12:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeReal is a prootype that represents real type
- * It matches:
- * real
- * real[]
- * real[4]
- * real[][]
- * real[3][]
- * real[][6][], ...
- * real32
- * real64[]
- * real8[4]
- * real256[][]
- * real[3][]
- * real64[][6][], ...
- */
- var SolidityTypeReal = function () {
- this._inputFormatter = f.formatInputReal;
- this._outputFormatter = f.formatOutputReal;
- };
- SolidityTypeReal.prototype = new SolidityType({});
- SolidityTypeReal.prototype.constructor = SolidityTypeReal;
- SolidityTypeReal.prototype.isType = function (name) {
- return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
- };
- module.exports = SolidityTypeReal;
- },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- var SolidityTypeString = function () {
- this._inputFormatter = f.formatInputString;
- this._outputFormatter = f.formatOutputString;
- };
- SolidityTypeString.prototype = new SolidityType({});
- SolidityTypeString.prototype.constructor = SolidityTypeString;
- SolidityTypeString.prototype.isType = function (name) {
- return !!name.match(/^string(\[([0-9]*)\])*$/);
- };
- SolidityTypeString.prototype.isDynamicType = function () {
- return true;
- };
- module.exports = SolidityTypeString;
- },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityParam = require('./param');
- /**
- * SolidityType prototype is used to encode/decode solidity params of certain type
- */
- var SolidityType = function (config) {
- this._inputFormatter = config.inputFormatter;
- this._outputFormatter = config.outputFormatter;
- };
- /**
- * Should be used to determine if this SolidityType do match given name
- *
- * @method isType
- * @param {String} name
- * @return {Bool} true if type match this SolidityType, otherwise false
- */
- SolidityType.prototype.isType = function (name) {
- throw "this method should be overrwritten for type " + name;
- };
- /**
- * Should be used to determine what is the length of static part in given type
- *
- * @method staticPartLength
- * @param {String} name
- * @return {Number} length of static part in bytes
- */
- SolidityType.prototype.staticPartLength = function (name) {
- // If name isn't an array then treat it like a single element array.
- return (this.nestedTypes(name) || ['[1]'])
- .map(function (type) {
- // the length of the nested array
- return parseInt(type.slice(1, -1), 10) || 1;
- })
- .reduce(function (previous, current) {
- return previous * current;
- // all basic types are 32 bytes long
- }, 32);
- };
- /**
- * Should be used to determine if type is dynamic array
- * eg:
- * "type[]" => true
- * "type[4]" => false
- *
- * @method isDynamicArray
- * @param {String} name
- * @return {Bool} true if the type is dynamic array
- */
- SolidityType.prototype.isDynamicArray = function (name) {
- var nestedTypes = this.nestedTypes(name);
- return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
- };
- /**
- * Should be used to determine if type is static array
- * eg:
- * "type[]" => false
- * "type[4]" => true
- *
- * @method isStaticArray
- * @param {String} name
- * @return {Bool} true if the type is static array
- */
- SolidityType.prototype.isStaticArray = function (name) {
- var nestedTypes = this.nestedTypes(name);
- return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
- };
- /**
- * Should return length of static array
- * eg.
- * "int[32]" => 32
- * "int256[14]" => 14
- * "int[2][3]" => 3
- * "int" => 1
- * "int[1]" => 1
- * "int[]" => 1
- *
- * @method staticArrayLength
- * @param {String} name
- * @return {Number} static array length
- */
- SolidityType.prototype.staticArrayLength = function (name) {
- var nestedTypes = this.nestedTypes(name);
- if (nestedTypes) {
- return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
- }
- return 1;
- };
- /**
- * Should return nested type
- * eg.
- * "int[32]" => "int"
- * "int256[14]" => "int256"
- * "int[2][3]" => "int[2]"
- * "int" => "int"
- * "int[]" => "int"
- *
- * @method nestedName
- * @param {String} name
- * @return {String} nested name
- */
- SolidityType.prototype.nestedName = function (name) {
- // remove last [] in name
- var nestedTypes = this.nestedTypes(name);
- if (!nestedTypes) {
- return name;
- }
- return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
- };
- /**
- * Should return true if type has dynamic size by default
- * such types are "string", "bytes"
- *
- * @method isDynamicType
- * @param {String} name
- * @return {Bool} true if is dynamic, otherwise false
- */
- SolidityType.prototype.isDynamicType = function () {
- return false;
- };
- /**
- * Should return array of nested types
- * eg.
- * "int[2][3][]" => ["[2]", "[3]", "[]"]
- * "int[] => ["[]"]
- * "int" => null
- *
- * @method nestedTypes
- * @param {String} name
- * @return {Array} array of nested types
- */
- SolidityType.prototype.nestedTypes = function (name) {
- // return list of strings eg. "[]", "[3]", "[]", "[2]"
- return name.match(/(\[[0-9]*\])/g);
- };
- /**
- * Should be used to encode the value
- *
- * @method encode
- * @param {Object} value
- * @param {String} name
- * @return {String} encoded value
- */
- SolidityType.prototype.encode = function (value, name) {
- var self = this;
- if (this.isDynamicArray(name)) {
- return (function () {
- var length = value.length; // in int
- var nestedName = self.nestedName(name);
- var result = [];
- result.push(f.formatInputInt(length).encode());
- value.forEach(function (v) {
- result.push(self.encode(v, nestedName));
- });
- return result;
- })();
- } else if (this.isStaticArray(name)) {
- return (function () {
- var length = self.staticArrayLength(name); // in int
- var nestedName = self.nestedName(name);
- var result = [];
- for (var i = 0; i < length; i++) {
- result.push(self.encode(value[i], nestedName));
- }
- return result;
- })();
- }
- return this._inputFormatter(value, name).encode();
- };
- /**
- * Should be used to decode value from bytes
- *
- * @method decode
- * @param {String} bytes
- * @param {Number} offset in bytes
- * @param {String} name type name
- * @returns {Object} decoded value
- */
- SolidityType.prototype.decode = function (bytes, offset, name) {
- var self = this;
- if (this.isDynamicArray(name)) {
- return (function () {
- var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
- var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
- var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
- var nestedName = self.nestedName(name);
- var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
- var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
- var result = [];
- for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
- result.push(self.decode(bytes, arrayStart + i, nestedName));
- }
- return result;
- })();
- } else if (this.isStaticArray(name)) {
- return (function () {
- var length = self.staticArrayLength(name); // in int
- var arrayStart = offset; // in bytes
- var nestedName = self.nestedName(name);
- var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
- var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
- var result = [];
- for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
- result.push(self.decode(bytes, arrayStart + i, nestedName));
- }
- return result;
- })();
- } else if (this.isDynamicType(name)) {
- return (function () {
- var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
- var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64)); // in bytes
- var roundedLength = Math.floor((length + 31) / 32); // in int
- var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
- return self._outputFormatter(param, name);
- })();
- }
- var length = this.staticPartLength(name);
- var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
- return this._outputFormatter(param, name);
- };
- module.exports = SolidityType;
- },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeUInt is a prootype that represents uint type
- * It matches:
- * uint
- * uint[]
- * uint[4]
- * uint[][]
- * uint[3][]
- * uint[][6][], ...
- * uint32
- * uint64[]
- * uint8[4]
- * uint256[][]
- * uint[3][]
- * uint64[][6][], ...
- */
- var SolidityTypeUInt = function () {
- this._inputFormatter = f.formatInputInt;
- this._outputFormatter = f.formatOutputUInt;
- };
- SolidityTypeUInt.prototype = new SolidityType({});
- SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
- SolidityTypeUInt.prototype.isType = function (name) {
- return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
- };
- module.exports = SolidityTypeUInt;
- },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
- var f = require('./formatters');
- var SolidityType = require('./type');
- /**
- * SolidityTypeUReal is a prootype that represents ureal type
- * It matches:
- * ureal
- * ureal[]
- * ureal[4]
- * ureal[][]
- * ureal[3][]
- * ureal[][6][], ...
- * ureal32
- * ureal64[]
- * ureal8[4]
- * ureal256[][]
- * ureal[3][]
- * ureal64[][6][], ...
- */
- var SolidityTypeUReal = function () {
- this._inputFormatter = f.formatInputReal;
- this._outputFormatter = f.formatOutputUReal;
- };
- SolidityTypeUReal.prototype = new SolidityType({});
- SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
- SolidityTypeUReal.prototype.isType = function (name) {
- return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
- };
- module.exports = SolidityTypeUReal;
- },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
- 'use strict';
- // go env doesn't have and need XMLHttpRequest
- if (typeof XMLHttpRequest === 'undefined') {
- exports.XMLHttpRequest = {};
- } else {
- exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
- }
- },{}],18:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file config.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * @date 2015
- */
- /**
- * Utils
- *
- * @module utils
- */
- /**
- * Utility functions
- *
- * @class [utils] config
- * @constructor
- */
- /// required to define ETH_BIGNUMBER_ROUNDING_MODE
- var BigNumber = require('bignumber.js');
- var ETH_UNITS = [
- 'wei',
- 'kwei',
- 'Mwei',
- 'Gwei',
- 'szabo',
- 'finney',
- 'femtoether',
- 'picoether',
- 'nanoether',
- 'microether',
- 'milliether',
- 'nano',
- 'micro',
- 'milli',
- 'ether',
- 'grand',
- 'Mether',
- 'Gether',
- 'Tether',
- 'Pether',
- 'Eether',
- 'Zether',
- 'Yether',
- 'Nether',
- 'Dether',
- 'Vether',
- 'Uether'
- ];
- module.exports = {
- ETH_PADDING: 32,
- ETH_SIGNATURE_LENGTH: 4,
- ETH_UNITS: ETH_UNITS,
- ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
- ETH_POLLING_TIMEOUT: 1000/2,
- defaultBlock: 'latest',
- defaultAccount: undefined
- };
- },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file sha3.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var CryptoJS = require('crypto-js');
- var sha3 = require('crypto-js/sha3');
- module.exports = function (value, options) {
- if (options && options.encoding === 'hex') {
- if (value.length > 2 && value.substr(0, 2) === '0x') {
- value = value.substr(2);
- }
- value = CryptoJS.enc.Hex.parse(value);
- }
- return sha3(value, {
- outputLength: 256
- }).toString();
- };
- },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file utils.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- /**
- * Utils
- *
- * @module utils
- */
- /**
- * Utility functions
- *
- * @class [utils] utils
- * @constructor
- */
- var BigNumber = require('bignumber.js');
- var sha3 = require('./sha3.js');
- var utf8 = require('utf8');
- var unitMap = {
- 'noether': '0',
- 'wei': '1',
- 'kwei': '1000',
- 'Kwei': '1000',
- 'babbage': '1000',
- 'femtoether': '1000',
- 'mwei': '1000000',
- 'Mwei': '1000000',
- 'lovelace': '1000000',
- 'picoether': '1000000',
- 'gwei': '1000000000',
- 'Gwei': '1000000000',
- 'shannon': '1000000000',
- 'nanoether': '1000000000',
- 'nano': '1000000000',
- 'szabo': '1000000000000',
- 'microether': '1000000000000',
- 'micro': '1000000000000',
- 'finney': '1000000000000000',
- 'milliether': '1000000000000000',
- 'milli': '1000000000000000',
- 'ether': '1000000000000000000',
- 'kether': '1000000000000000000000',
- 'grand': '1000000000000000000000',
- 'mether': '1000000000000000000000000',
- 'gether': '1000000000000000000000000000',
- 'tether': '1000000000000000000000000000000'
- };
- /**
- * Should be called to pad string to expected length
- *
- * @method padLeft
- * @param {String} string to be padded
- * @param {Number} characters that result string should have
- * @param {String} sign, by default 0
- * @returns {String} right aligned string
- */
- var padLeft = function (string, chars, sign) {
- return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
- };
- /**
- * Should be called to pad string to expected length
- *
- * @method padRight
- * @param {String} string to be padded
- * @param {Number} characters that result string should have
- * @param {String} sign, by default 0
- * @returns {String} right aligned string
- */
- var padRight = function (string, chars, sign) {
- return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
- };
- /**
- * Should be called to get utf8 from it's hex representation
- *
- * @method toUtf8
- * @param {String} string in hex
- * @returns {String} ascii string representation of hex value
- */
- var toUtf8 = function(hex) {
- // Find termination
- var str = "";
- var i = 0, l = hex.length;
- if (hex.substring(0, 2) === '0x') {
- i = 2;
- }
- for (; i < l; i+=2) {
- var code = parseInt(hex.substr(i, 2), 16);
- if (code === 0)
- break;
- str += String.fromCharCode(code);
- }
- return utf8.decode(str);
- };
- /**
- * Should be called to get ascii from it's hex representation
- *
- * @method toAscii
- * @param {String} string in hex
- * @returns {String} ascii string representation of hex value
- */
- var toAscii = function(hex) {
- // Find termination
- var str = "";
- var i = 0, l = hex.length;
- if (hex.substring(0, 2) === '0x') {
- i = 2;
- }
- for (; i < l; i+=2) {
- var code = parseInt(hex.substr(i, 2), 16);
- str += String.fromCharCode(code);
- }
- return str;
- };
- /**
- * Should be called to get hex representation (prefixed by 0x) of utf8 string
- *
- * @method fromUtf8
- * @param {String} string
- * @param {Number} optional padding
- * @returns {String} hex representation of input string
- */
- var fromUtf8 = function(str) {
- str = utf8.encode(str);
- var hex = "";
- for(var i = 0; i < str.length; i++) {
- var code = str.charCodeAt(i);
- if (code === 0)
- break;
- var n = code.toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
- return "0x" + hex;
- };
- /**
- * Should be called to get hex representation (prefixed by 0x) of ascii string
- *
- * @method fromAscii
- * @param {String} string
- * @param {Number} optional padding
- * @returns {String} hex representation of input string
- */
- var fromAscii = function(str) {
- var hex = "";
- for(var i = 0; i < str.length; i++) {
- var code = str.charCodeAt(i);
- var n = code.toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
- return "0x" + hex;
- };
- /**
- * Should be used to create full function/event name from json abi
- *
- * @method transformToFullName
- * @param {Object} json-abi
- * @return {String} full fnction/event name
- */
- var transformToFullName = function (json) {
- if (json.name.indexOf('(') !== -1) {
- return json.name;
- }
- var typeName = json.inputs.map(function(i){return i.type; }).join();
- return json.name + '(' + typeName + ')';
- };
- /**
- * Should be called to get display name of contract function
- *
- * @method extractDisplayName
- * @param {String} name of function/event
- * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
- */
- var extractDisplayName = function (name) {
- var length = name.indexOf('(');
- return length !== -1 ? name.substr(0, length) : name;
- };
- /// @returns overloaded part of function/event name
- var extractTypeName = function (name) {
- /// TODO: make it invulnerable
- var length = name.indexOf('(');
- return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
- };
- /**
- * Converts value to it's decimal representation in string
- *
- * @method toDecimal
- * @param {String|Number|BigNumber}
- * @return {String}
- */
- var toDecimal = function (value) {
- return toBigNumber(value).toNumber();
- };
- /**
- * Converts value to it's hex representation
- *
- * @method fromDecimal
- * @param {String|Number|BigNumber}
- * @return {String}
- */
- var fromDecimal = function (value) {
- var number = toBigNumber(value);
- var result = number.toString(16);
- return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
- };
- /**
- * Auto converts any given value into it's hex representation.
- *
- * And even stringifys objects before.
- *
- * @method toHex
- * @param {String|Number|BigNumber|Object}
- * @return {String}
- */
- var toHex = function (val) {
- /*jshint maxcomplexity: 8 */
- if (isBoolean(val))
- return fromDecimal(+val);
- if (isBigNumber(val))
- return fromDecimal(val);
- if (isObject(val))
- return fromUtf8(JSON.stringify(val));
- // if its a negative number, pass it through fromDecimal
- if (isString(val)) {
- if (val.indexOf('-0x') === 0)
- return fromDecimal(val);
- else if(val.indexOf('0x') === 0)
- return val;
- else if (!isFinite(val))
- return fromAscii(val);
- }
- return fromDecimal(val);
- };
- /**
- * Returns value of unit in Wei
- *
- * @method getValueOfUnit
- * @param {String} unit the unit to convert to, default ether
- * @returns {BigNumber} value of the unit (in Wei)
- * @throws error if the unit is not correct:w
- */
- var getValueOfUnit = function (unit) {
- unit = unit ? unit.toLowerCase() : 'ether';
- var unitValue = unitMap[unit];
- if (unitValue === undefined) {
- throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
- }
- return new BigNumber(unitValue, 10);
- };
- /**
- * Takes a number of wei and converts it to any other ether unit.
- *
- * Possible units are:
- * SI Short SI Full Effigy Other
- * - kwei femtoether babbage
- * - mwei picoether lovelace
- * - gwei nanoether shannon nano
- * - -- microether szabo micro
- * - -- milliether finney milli
- * - ether -- --
- * - kether -- grand
- * - mether
- * - gether
- * - tether
- *
- * @method fromWei
- * @param {Number|String} number can be a number, number string or a HEX of a decimal
- * @param {String} unit the unit to convert to, default ether
- * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
- */
- var fromWei = function(number, unit) {
- var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
- return isBigNumber(number) ? returnValue : returnValue.toString(10);
- };
- /**
- * Takes a number of a unit and converts it to wei.
- *
- * Possible units are:
- * SI Short SI Full Effigy Other
- * - kwei femtoether babbage
- * - mwei picoether lovelace
- * - gwei nanoether shannon nano
- * - -- microether szabo micro
- * - -- microether szabo micro
- * - -- milliether finney milli
- * - ether -- --
- * - kether -- grand
- * - mether
- * - gether
- * - tether
- *
- * @method toWei
- * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
- * @param {String} unit the unit to convert from, default ether
- * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
- */
- var toWei = function(number, unit) {
- var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
- return isBigNumber(number) ? returnValue : returnValue.toString(10);
- };
- /**
- * Takes an input and transforms it into an bignumber
- *
- * @method toBigNumber
- * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
- * @return {BigNumber} BigNumber
- */
- var toBigNumber = function(number) {
- /*jshint maxcomplexity:5 */
- number = number || 0;
- if (isBigNumber(number))
- return number;
- if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
- return new BigNumber(number.replace('0x',''), 16);
- }
- return new BigNumber(number.toString(10), 10);
- };
- /**
- * Takes and input transforms it into bignumber and if it is negative value, into two's complement
- *
- * @method toTwosComplement
- * @param {Number|String|BigNumber}
- * @return {BigNumber}
- */
- var toTwosComplement = function (number) {
- var bigNumber = toBigNumber(number).round();
- if (bigNumber.lessThan(0)) {
- return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
- }
- return bigNumber;
- };
- /**
- * Checks if the given string is strictly an address
- *
- * @method isStrictAddress
- * @param {String} address the given HEX adress
- * @return {Boolean}
- */
- var isStrictAddress = function (address) {
- return /^0x[0-9a-f]{40}$/i.test(address);
- };
- /**
- * Checks if the given string is an address
- *
- * @method isAddress
- * @param {String} address the given HEX adress
- * @return {Boolean}
- */
- var isAddress = function (address) {
- if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
- // check if it has the basic requirements of an address
- return false;
- } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
- // If it's all small caps or all all caps, return true
- return true;
- } else {
- // Otherwise check each case
- return isChecksumAddress(address);
- }
- };
- /**
- * Checks if the given string is a checksummed address
- *
- * @method isChecksumAddress
- * @param {String} address the given HEX adress
- * @return {Boolean}
- */
- var isChecksumAddress = function (address) {
- // Check each case
- address = address.replace('0x','');
- var addressHash = sha3(address.toLowerCase());
- for (var i = 0; i < 40; i++ ) {
- // the nth letter should be uppercase if the nth digit of casemap is 1
- if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
- return false;
- }
- }
- return true;
- };
- /**
- * Makes a checksum address
- *
- * @method toChecksumAddress
- * @param {String} address the given HEX adress
- * @return {String}
- */
- var toChecksumAddress = function (address) {
- if (typeof address === 'undefined') return '';
- address = address.toLowerCase().replace('0x','');
- var addressHash = sha3(address);
- var checksumAddress = '0x';
- for (var i = 0; i < address.length; i++ ) {
- // If ith character is 9 to f then make it uppercase
- if (parseInt(addressHash[i], 16) > 7) {
- checksumAddress += address[i].toUpperCase();
- } else {
- checksumAddress += address[i];
- }
- }
- return checksumAddress;
- };
- /**
- * Transforms given string to valid 20 bytes-length addres with 0x prefix
- *
- * @method toAddress
- * @param {String} address
- * @return {String} formatted address
- */
- var toAddress = function (address) {
- if (isStrictAddress(address)) {
- return address;
- }
- if (/^[0-9a-f]{40}$/.test(address)) {
- return '0x' + address;
- }
- return '0x' + padLeft(toHex(address).substr(2), 40);
- };
- /**
- * Returns true if object is BigNumber, otherwise false
- *
- * @method isBigNumber
- * @param {Object}
- * @return {Boolean}
- */
- var isBigNumber = function (object) {
- return object instanceof BigNumber ||
- (object && object.constructor && object.constructor.name === 'BigNumber');
- };
- /**
- * Returns true if object is string, otherwise false
- *
- * @method isString
- * @param {Object}
- * @return {Boolean}
- */
- var isString = function (object) {
- return typeof object === 'string' ||
- (object && object.constructor && object.constructor.name === 'String');
- };
- /**
- * Returns true if object is function, otherwise false
- *
- * @method isFunction
- * @param {Object}
- * @return {Boolean}
- */
- var isFunction = function (object) {
- return typeof object === 'function';
- };
- /**
- * Returns true if object is Objet, otherwise false
- *
- * @method isObject
- * @param {Object}
- * @return {Boolean}
- */
- var isObject = function (object) {
- return typeof object === 'object';
- };
- /**
- * Returns true if object is boolean, otherwise false
- *
- * @method isBoolean
- * @param {Object}
- * @return {Boolean}
- */
- var isBoolean = function (object) {
- return typeof object === 'boolean';
- };
- /**
- * Returns true if object is array, otherwise false
- *
- * @method isArray
- * @param {Object}
- * @return {Boolean}
- */
- var isArray = function (object) {
- return object instanceof Array;
- };
- /**
- * Returns true if given string is valid json object
- *
- * @method isJson
- * @param {String}
- * @return {Boolean}
- */
- var isJson = function (str) {
- try {
- return !!JSON.parse(str);
- } catch (e) {
- return false;
- }
- };
- module.exports = {
- padLeft: padLeft,
- padRight: padRight,
- toHex: toHex,
- toDecimal: toDecimal,
- fromDecimal: fromDecimal,
- toUtf8: toUtf8,
- toAscii: toAscii,
- fromUtf8: fromUtf8,
- fromAscii: fromAscii,
- transformToFullName: transformToFullName,
- extractDisplayName: extractDisplayName,
- extractTypeName: extractTypeName,
- toWei: toWei,
- fromWei: fromWei,
- toBigNumber: toBigNumber,
- toTwosComplement: toTwosComplement,
- toAddress: toAddress,
- isBigNumber: isBigNumber,
- isStrictAddress: isStrictAddress,
- isAddress: isAddress,
- isChecksumAddress: isChecksumAddress,
- toChecksumAddress: toChecksumAddress,
- isFunction: isFunction,
- isString: isString,
- isObject: isObject,
- isBoolean: isBoolean,
- isArray: isArray,
- isJson: isJson
- };
- },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
- module.exports={
- "version": "0.18.2"
- }
- },{}],22:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file web3.js
- * @authors:
- * Jeffrey Wilcke <[email protected]>
- * Marek Kotewicz <[email protected]>
- * Marian Oancea <[email protected]>
- * Fabian Vogelsteller <[email protected]>
- * Gav Wood <[email protected]>
- * @date 2014
- */
- var RequestManager = require('./web3/requestmanager');
- var Iban = require('./web3/iban');
- var Eth = require('./web3/methods/eth');
- var DB = require('./web3/methods/db');
- var Shh = require('./web3/methods/shh');
- var Net = require('./web3/methods/net');
- var Personal = require('./web3/methods/personal');
- var Swarm = require('./web3/methods/swarm');
- var Settings = require('./web3/settings');
- var version = require('./version.json');
- var utils = require('./utils/utils');
- var sha3 = require('./utils/sha3');
- var extend = require('./web3/extend');
- var Batch = require('./web3/batch');
- var Property = require('./web3/property');
- var HttpProvider = require('./web3/httpprovider');
- var IpcProvider = require('./web3/ipcprovider');
- var BigNumber = require('bignumber.js');
- function Web3 (provider) {
- this._requestManager = new RequestManager(provider);
- this.currentProvider = provider;
- this.eth = new Eth(this);
- this.db = new DB(this);
- this.shh = new Shh(this);
- this.net = new Net(this);
- this.personal = new Personal(this);
- this.bzz = new Swarm(this);
- this.settings = new Settings();
- this.version = {
- api: version.version
- };
- this.providers = {
- HttpProvider: HttpProvider,
- IpcProvider: IpcProvider
- };
- this._extend = extend(this);
- this._extend({
- properties: properties()
- });
- }
- // expose providers on the class
- Web3.providers = {
- HttpProvider: HttpProvider,
- IpcProvider: IpcProvider
- };
- Web3.prototype.setProvider = function (provider) {
- this._requestManager.setProvider(provider);
- this.currentProvider = provider;
- };
- Web3.prototype.reset = function (keepIsSyncing) {
- this._requestManager.reset(keepIsSyncing);
- this.settings = new Settings();
- };
- Web3.prototype.BigNumber = BigNumber;
- Web3.prototype.toHex = utils.toHex;
- Web3.prototype.toAscii = utils.toAscii;
- Web3.prototype.toUtf8 = utils.toUtf8;
- Web3.prototype.fromAscii = utils.fromAscii;
- Web3.prototype.fromUtf8 = utils.fromUtf8;
- Web3.prototype.toDecimal = utils.toDecimal;
- Web3.prototype.fromDecimal = utils.fromDecimal;
- Web3.prototype.toBigNumber = utils.toBigNumber;
- Web3.prototype.toWei = utils.toWei;
- Web3.prototype.fromWei = utils.fromWei;
- Web3.prototype.isAddress = utils.isAddress;
- Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
- Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
- Web3.prototype.isIBAN = utils.isIBAN;
- Web3.prototype.sha3 = function(string, options) {
- return '0x' + sha3(string, options);
- };
- /**
- * Transforms direct icap to address
- */
- Web3.prototype.fromICAP = function (icap) {
- var iban = new Iban(icap);
- return iban.address();
- };
- var properties = function () {
- return [
- new Property({
- name: 'version.node',
- getter: 'web3_clientVersion'
- }),
- new Property({
- name: 'version.network',
- getter: 'net_version',
- inputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'version.ethereum',
- getter: 'eth_protocolVersion',
- inputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'version.whisper',
- getter: 'shh_version',
- inputFormatter: utils.toDecimal
- })
- ];
- };
- Web3.prototype.isConnected = function(){
- return (this.currentProvider && this.currentProvider.isConnected());
- };
- Web3.prototype.createBatch = function () {
- return new Batch(this);
- };
- module.exports = Web3;
- },{"./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){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file allevents.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2014
- */
- var sha3 = require('../utils/sha3');
- var SolidityEvent = require('./event');
- var formatters = require('./formatters');
- var utils = require('../utils/utils');
- var Filter = require('./filter');
- var watches = require('./methods/watches');
- var AllSolidityEvents = function (requestManager, json, address) {
- this._requestManager = requestManager;
- this._json = json;
- this._address = address;
- };
- AllSolidityEvents.prototype.encode = function (options) {
- options = options || {};
- var result = {};
- ['fromBlock', 'toBlock'].filter(function (f) {
- return options[f] !== undefined;
- }).forEach(function (f) {
- result[f] = formatters.inputBlockNumberFormatter(options[f]);
- });
- result.address = this._address;
- return result;
- };
- AllSolidityEvents.prototype.decode = function (data) {
- data.data = data.data || '';
- data.topics = data.topics || [];
- var eventTopic = data.topics[0].slice(2);
- var match = this._json.filter(function (j) {
- return eventTopic === sha3(utils.transformToFullName(j));
- })[0];
- if (!match) { // cannot find matching event?
- console.warn('cannot find event for log');
- return data;
- }
- var event = new SolidityEvent(this._requestManager, match, this._address);
- return event.decode(data);
- };
- AllSolidityEvents.prototype.execute = function (options, callback) {
- if (utils.isFunction(arguments[arguments.length - 1])) {
- callback = arguments[arguments.length - 1];
- if(arguments.length === 1)
- options = null;
- }
- var o = this.encode(options);
- var formatter = this.decode.bind(this);
- return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
- };
- AllSolidityEvents.prototype.attachToContract = function (contract) {
- var execute = this.execute.bind(this);
- contract.allEvents = execute;
- };
- module.exports = AllSolidityEvents;
- },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file batch.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var Jsonrpc = require('./jsonrpc');
- var errors = require('./errors');
- var Batch = function (web3) {
- this.requestManager = web3._requestManager;
- this.requests = [];
- };
- /**
- * Should be called to add create new request to batch request
- *
- * @method add
- * @param {Object} jsonrpc requet object
- */
- Batch.prototype.add = function (request) {
- this.requests.push(request);
- };
- /**
- * Should be called to execute batch request
- *
- * @method execute
- */
- Batch.prototype.execute = function () {
- var requests = this.requests;
- this.requestManager.sendBatch(requests, function (err, results) {
- results = results || [];
- requests.map(function (request, index) {
- return results[index] || {};
- }).forEach(function (result, index) {
- if (requests[index].callback) {
- if (!Jsonrpc.isValidResponse(result)) {
- return requests[index].callback(errors.InvalidResponse(result));
- }
- requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
- }
- });
- });
- };
- module.exports = Batch;
- },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file contract.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2014
- */
- var utils = require('../utils/utils');
- var coder = require('../solidity/coder');
- var SolidityEvent = require('./event');
- var SolidityFunction = require('./function');
- var AllEvents = require('./allevents');
- /**
- * Should be called to encode constructor params
- *
- * @method encodeConstructorParams
- * @param {Array} abi
- * @param {Array} constructor params
- */
- var encodeConstructorParams = function (abi, params) {
- return abi.filter(function (json) {
- return json.type === 'constructor' && json.inputs.length === params.length;
- }).map(function (json) {
- return json.inputs.map(function (input) {
- return input.type;
- });
- }).map(function (types) {
- return coder.encodeParams(types, params);
- })[0] || '';
- };
- /**
- * Should be called to add functions to contract object
- *
- * @method addFunctionsToContract
- * @param {Contract} contract
- * @param {Array} abi
- */
- var addFunctionsToContract = function (contract) {
- contract.abi.filter(function (json) {
- return json.type === 'function';
- }).map(function (json) {
- return new SolidityFunction(contract._eth, json, contract.address);
- }).forEach(function (f) {
- f.attachToContract(contract);
- });
- };
- /**
- * Should be called to add events to contract object
- *
- * @method addEventsToContract
- * @param {Contract} contract
- * @param {Array} abi
- */
- var addEventsToContract = function (contract) {
- var events = contract.abi.filter(function (json) {
- return json.type === 'event';
- });
- var All = new AllEvents(contract._eth._requestManager, events, contract.address);
- All.attachToContract(contract);
- events.map(function (json) {
- return new SolidityEvent(contract._eth._requestManager, json, contract.address);
- }).forEach(function (e) {
- e.attachToContract(contract);
- });
- };
- /**
- * Should be called to check if the contract gets properly deployed on the blockchain.
- *
- * @method checkForContractAddress
- * @param {Object} contract
- * @param {Function} callback
- * @returns {Undefined}
- */
- var checkForContractAddress = function(contract, callback){
- var count = 0,
- callbackFired = false;
- // wait for receipt
- var filter = contract._eth.filter('latest', function(e){
- if (!e && !callbackFired) {
- count++;
- // stop watching after 50 blocks (timeout)
- if (count > 50) {
- filter.stopWatching(function() {});
- callbackFired = true;
- if (callback)
- callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
- else
- throw new Error('Contract transaction couldn\'t be found after 50 blocks');
- } else {
- contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
- if(receipt && !callbackFired) {
- contract._eth.getCode(receipt.contractAddress, function(e, code){
- /*jshint maxcomplexity: 6 */
- if(callbackFired || !code)
- return;
- filter.stopWatching(function() {});
- callbackFired = true;
- if(code.length > 3) {
- // console.log('Contract code deployed!');
- contract.address = receipt.contractAddress;
- // attach events and methods again after we have
- addFunctionsToContract(contract);
- addEventsToContract(contract);
- // call callback for the second time
- if(callback)
- callback(null, contract);
- } else {
- if(callback)
- callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
- else
- throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
- }
- });
- }
- });
- }
- }
- });
- };
- /**
- * Should be called to create new ContractFactory instance
- *
- * @method ContractFactory
- * @param {Array} abi
- */
- var ContractFactory = function (eth, abi) {
- this.eth = eth;
- this.abi = abi;
- /**
- * Should be called to create new contract on a blockchain
- *
- * @method new
- * @param {Any} contract constructor param1 (optional)
- * @param {Any} contract constructor param2 (optional)
- * @param {Object} contract transaction object (required)
- * @param {Function} callback
- * @returns {Contract} returns contract instance
- */
- this.new = function () {
- /*jshint maxcomplexity: 7 */
-
- var contract = new Contract(this.eth, this.abi);
- // parse arguments
- var options = {}; // required!
- var callback;
- var args = Array.prototype.slice.call(arguments);
- if (utils.isFunction(args[args.length - 1])) {
- callback = args.pop();
- }
- var last = args[args.length - 1];
- if (utils.isObject(last) && !utils.isArray(last)) {
- options = args.pop();
- }
- if (options.value > 0) {
- var constructorAbi = abi.filter(function (json) {
- return json.type === 'constructor' && json.inputs.length === args.length;
- })[0] || {};
- if (!constructorAbi.payable) {
- throw new Error('Cannot send value to non-payable constructor');
- }
- }
- var bytes = encodeConstructorParams(this.abi, args);
- options.data += bytes;
- if (callback) {
- // wait for the contract address adn check if the code was deployed
- this.eth.sendTransaction(options, function (err, hash) {
- if (err) {
- callback(err);
- } else {
- // add the transaction hash
- contract.transactionHash = hash;
- // call callback for the first time
- callback(null, contract);
- checkForContractAddress(contract, callback);
- }
- });
- } else {
- var hash = this.eth.sendTransaction(options);
- // add the transaction hash
- contract.transactionHash = hash;
- checkForContractAddress(contract);
- }
- return contract;
- };
- this.new.getData = this.getData.bind(this);
- };
- /**
- * Should be called to create new ContractFactory
- *
- * @method contract
- * @param {Array} abi
- * @returns {ContractFactory} new contract factory
- */
- //var contract = function (abi) {
- //return new ContractFactory(abi);
- //};
- /**
- * Should be called to get access to existing contract on a blockchain
- *
- * @method at
- * @param {Address} contract address (required)
- * @param {Function} callback {optional)
- * @returns {Contract} returns contract if no callback was passed,
- * otherwise calls callback function (err, contract)
- */
- ContractFactory.prototype.at = function (address, callback) {
- var contract = new Contract(this.eth, this.abi, address);
- // this functions are not part of prototype,
- // because we dont want to spoil the interface
- addFunctionsToContract(contract);
- addEventsToContract(contract);
- if (callback) {
- callback(null, contract);
- }
- return contract;
- };
- /**
- * Gets the data, which is data to deploy plus constructor params
- *
- * @method getData
- */
- ContractFactory.prototype.getData = function () {
- var options = {}; // required!
- var args = Array.prototype.slice.call(arguments);
- var last = args[args.length - 1];
- if (utils.isObject(last) && !utils.isArray(last)) {
- options = args.pop();
- }
- var bytes = encodeConstructorParams(this.abi, args);
- options.data += bytes;
- return options.data;
- };
- /**
- * Should be called to create new contract instance
- *
- * @method Contract
- * @param {Array} abi
- * @param {Address} contract address
- */
- var Contract = function (eth, abi, address) {
- this._eth = eth;
- this.transactionHash = null;
- this.address = address;
- this.abi = abi;
- };
- module.exports = ContractFactory;
- },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file errors.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- module.exports = {
- InvalidNumberOfParams: function () {
- return new Error('Invalid number of input parameters');
- },
- InvalidConnection: function (host){
- return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
- },
- InvalidProvider: function () {
- return new Error('Provider not set or invalid');
- },
- InvalidResponse: function (result){
- var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
- return new Error(message);
- },
- ConnectionTimeout: function (ms){
- return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
- }
- };
- },{}],27:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file event.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2014
- */
- var utils = require('../utils/utils');
- var coder = require('../solidity/coder');
- var formatters = require('./formatters');
- var sha3 = require('../utils/sha3');
- var Filter = require('./filter');
- var watches = require('./methods/watches');
- /**
- * This prototype should be used to create event filters
- */
- var SolidityEvent = function (requestManager, json, address) {
- this._requestManager = requestManager;
- this._params = json.inputs;
- this._name = utils.transformToFullName(json);
- this._address = address;
- this._anonymous = json.anonymous;
- };
- /**
- * Should be used to get filtered param types
- *
- * @method types
- * @param {Bool} decide if returned typed should be indexed
- * @return {Array} array of types
- */
- SolidityEvent.prototype.types = function (indexed) {
- return this._params.filter(function (i) {
- return i.indexed === indexed;
- }).map(function (i) {
- return i.type;
- });
- };
- /**
- * Should be used to get event display name
- *
- * @method displayName
- * @return {String} event display name
- */
- SolidityEvent.prototype.displayName = function () {
- return utils.extractDisplayName(this._name);
- };
- /**
- * Should be used to get event type name
- *
- * @method typeName
- * @return {String} event type name
- */
- SolidityEvent.prototype.typeName = function () {
- return utils.extractTypeName(this._name);
- };
- /**
- * Should be used to get event signature
- *
- * @method signature
- * @return {String} event signature
- */
- SolidityEvent.prototype.signature = function () {
- return sha3(this._name);
- };
- /**
- * Should be used to encode indexed params and options to one final object
- *
- * @method encode
- * @param {Object} indexed
- * @param {Object} options
- * @return {Object} everything combined together and encoded
- */
- SolidityEvent.prototype.encode = function (indexed, options) {
- indexed = indexed || {};
- options = options || {};
- var result = {};
- ['fromBlock', 'toBlock'].filter(function (f) {
- return options[f] !== undefined;
- }).forEach(function (f) {
- result[f] = formatters.inputBlockNumberFormatter(options[f]);
- });
- result.topics = [];
- result.address = this._address;
- if (!this._anonymous) {
- result.topics.push('0x' + this.signature());
- }
- var indexedTopics = this._params.filter(function (i) {
- return i.indexed === true;
- }).map(function (i) {
- var value = indexed[i.name];
- if (value === undefined || value === null) {
- return null;
- }
-
- if (utils.isArray(value)) {
- return value.map(function (v) {
- return '0x' + coder.encodeParam(i.type, v);
- });
- }
- return '0x' + coder.encodeParam(i.type, value);
- });
- result.topics = result.topics.concat(indexedTopics);
- return result;
- };
- /**
- * Should be used to decode indexed params and options
- *
- * @method decode
- * @param {Object} data
- * @return {Object} result object with decoded indexed && not indexed params
- */
- SolidityEvent.prototype.decode = function (data) {
-
- data.data = data.data || '';
- data.topics = data.topics || [];
- var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
- var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
- var indexedParams = coder.decodeParams(this.types(true), indexedData);
- var notIndexedData = data.data.slice(2);
- var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
-
- var result = formatters.outputLogFormatter(data);
- result.event = this.displayName();
- result.address = data.address;
- result.args = this._params.reduce(function (acc, current) {
- acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
- return acc;
- }, {});
- delete result.data;
- delete result.topics;
- return result;
- };
- /**
- * Should be used to create new filter object from event
- *
- * @method execute
- * @param {Object} indexed
- * @param {Object} options
- * @return {Object} filter object
- */
- SolidityEvent.prototype.execute = function (indexed, options, callback) {
- if (utils.isFunction(arguments[arguments.length - 1])) {
- callback = arguments[arguments.length - 1];
- if(arguments.length === 2)
- options = null;
- if(arguments.length === 1) {
- options = null;
- indexed = {};
- }
- }
-
- var o = this.encode(indexed, options);
- var formatter = this.decode.bind(this);
- return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
- };
- /**
- * Should be used to attach event to contract object
- *
- * @method attachToContract
- * @param {Contract}
- */
- SolidityEvent.prototype.attachToContract = function (contract) {
- var execute = this.execute.bind(this);
- var displayName = this.displayName();
- if (!contract[displayName]) {
- contract[displayName] = execute;
- }
- contract[displayName][this.typeName()] = this.execute.bind(this, contract);
- };
- module.exports = SolidityEvent;
- },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
- var formatters = require('./formatters');
- var utils = require('./../utils/utils');
- var Method = require('./method');
- var Property = require('./property');
- // TODO: refactor, so the input params are not altered.
- // it's necessary to make same 'extension' work with multiple providers
- var extend = function (web3) {
- /* jshint maxcomplexity:5 */
- var ex = function (extension) {
- var extendedObject;
- if (extension.property) {
- if (!web3[extension.property]) {
- web3[extension.property] = {};
- }
- extendedObject = web3[extension.property];
- } else {
- extendedObject = web3;
- }
- if (extension.methods) {
- extension.methods.forEach(function (method) {
- method.attachToObject(extendedObject);
- method.setRequestManager(web3._requestManager);
- });
- }
- if (extension.properties) {
- extension.properties.forEach(function (property) {
- property.attachToObject(extendedObject);
- property.setRequestManager(web3._requestManager);
- });
- }
- };
- ex.formatters = formatters;
- ex.utils = utils;
- ex.Method = Method;
- ex.Property = Property;
- return ex;
- };
- module.exports = extend;
- },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file filter.js
- * @authors:
- * Jeffrey Wilcke <[email protected]>
- * Marek Kotewicz <[email protected]>
- * Marian Oancea <[email protected]>
- * Fabian Vogelsteller <[email protected]>
- * Gav Wood <[email protected]>
- * @date 2014
- */
- var formatters = require('./formatters');
- var utils = require('../utils/utils');
- /**
- * Converts a given topic to a hex string, but also allows null values.
- *
- * @param {Mixed} value
- * @return {String}
- */
- var toTopic = function(value){
- if(value === null || typeof value === 'undefined')
- return null;
- value = String(value);
- if(value.indexOf('0x') === 0)
- return value;
- else
- return utils.fromUtf8(value);
- };
- /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
- /// @param should be string or object
- /// @returns options string or object
- var getOptions = function (options) {
- if (utils.isString(options)) {
- return options;
- }
- options = options || {};
- // make sure topics, get converted to hex
- options.topics = options.topics || [];
- options.topics = options.topics.map(function(topic){
- return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
- });
- return {
- topics: options.topics,
- from: options.from,
- to: options.to,
- address: options.address,
- fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
- toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
- };
- };
- /**
- Adds the callback and sets up the methods, to iterate over the results.
- @method getLogsAtStart
- @param {Object} self
- @param {funciton}
- */
- var getLogsAtStart = function(self, callback){
- // call getFilterLogs for the first watch callback start
- if (!utils.isString(self.options)) {
- self.get(function (err, messages) {
- // don't send all the responses to all the watches again... just to self one
- if (err) {
- callback(err);
- }
- if(utils.isArray(messages)) {
- messages.forEach(function (message) {
- callback(null, message);
- });
- }
- });
- }
- };
- /**
- Adds the callback and sets up the methods, to iterate over the results.
- @method pollFilter
- @param {Object} self
- */
- var pollFilter = function(self) {
- var onMessage = function (error, messages) {
- if (error) {
- return self.callbacks.forEach(function (callback) {
- callback(error);
- });
- }
- if(utils.isArray(messages)) {
- messages.forEach(function (message) {
- message = self.formatter ? self.formatter(message) : message;
- self.callbacks.forEach(function (callback) {
- callback(null, message);
- });
- });
- }
- };
- self.requestManager.startPolling({
- method: self.implementation.poll.call,
- params: [self.filterId],
- }, self.filterId, onMessage, self.stopWatching.bind(self));
- };
- var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
- var self = this;
- var implementation = {};
- methods.forEach(function (method) {
- method.setRequestManager(requestManager);
- method.attachToObject(implementation);
- });
- this.requestManager = requestManager;
- this.options = getOptions(options);
- this.implementation = implementation;
- this.filterId = null;
- this.callbacks = [];
- this.getLogsCallbacks = [];
- this.pollFilters = [];
- this.formatter = formatter;
- this.implementation.newFilter(this.options, function(error, id){
- if(error) {
- self.callbacks.forEach(function(cb){
- cb(error);
- });
- filterCreationErrorCallback(error);
- } else {
- self.filterId = id;
- // check if there are get pending callbacks as a consequence
- // of calling get() with filterId unassigned.
- self.getLogsCallbacks.forEach(function (cb){
- self.get(cb);
- });
- self.getLogsCallbacks = [];
- // get filter logs for the already existing watch calls
- self.callbacks.forEach(function(cb){
- getLogsAtStart(self, cb);
- });
- if(self.callbacks.length > 0)
- pollFilter(self);
- // start to watch immediately
- if(typeof callback === 'function') {
- return self.watch(callback);
- }
- }
- });
- return this;
- };
- Filter.prototype.watch = function (callback) {
- this.callbacks.push(callback);
- if(this.filterId) {
- getLogsAtStart(this, callback);
- pollFilter(this);
- }
- return this;
- };
- Filter.prototype.stopWatching = function (callback) {
- this.requestManager.stopPolling(this.filterId);
- this.callbacks = [];
- // remove filter async
- if (callback) {
- this.implementation.uninstallFilter(this.filterId, callback);
- } else {
- return this.implementation.uninstallFilter(this.filterId);
- }
- };
- Filter.prototype.get = function (callback) {
- var self = this;
- if (utils.isFunction(callback)) {
- if (this.filterId === null) {
- // If filterId is not set yet, call it back
- // when newFilter() assigns it.
- this.getLogsCallbacks.push(callback);
- } else {
- this.implementation.getLogs(this.filterId, function(err, res){
- if (err) {
- callback(err);
- } else {
- callback(null, res.map(function (log) {
- return self.formatter ? self.formatter(log) : log;
- }));
- }
- });
- }
- } else {
- if (this.filterId === null) {
- throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
- }
- var logs = this.implementation.getLogs(this.filterId);
- return logs.map(function (log) {
- return self.formatter ? self.formatter(log) : log;
- });
- }
- return this;
- };
- module.exports = Filter;
- },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file formatters.js
- * @author Marek Kotewicz <[email protected]>
- * @author Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- var utils = require('../utils/utils');
- var config = require('../utils/config');
- var Iban = require('./iban');
- /**
- * Should the format output to a big number
- *
- * @method outputBigNumberFormatter
- * @param {String|Number|BigNumber}
- * @returns {BigNumber} object
- */
- var outputBigNumberFormatter = function (number) {
- return utils.toBigNumber(number);
- };
- var isPredefinedBlockNumber = function (blockNumber) {
- return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
- };
- var inputDefaultBlockNumberFormatter = function (blockNumber) {
- if (blockNumber === undefined) {
- return config.defaultBlock;
- }
- return inputBlockNumberFormatter(blockNumber);
- };
- var inputBlockNumberFormatter = function (blockNumber) {
- if (blockNumber === undefined) {
- return undefined;
- } else if (isPredefinedBlockNumber(blockNumber)) {
- return blockNumber;
- }
- return utils.toHex(blockNumber);
- };
- /**
- * Formats the input of a transaction and converts all values to HEX
- *
- * @method inputCallFormatter
- * @param {Object} transaction options
- * @returns object
- */
- var inputCallFormatter = function (options){
- options.from = options.from || config.defaultAccount;
- if (options.from) {
- options.from = inputAddressFormatter(options.from);
- }
- if (options.to) { // it might be contract creation
- options.to = inputAddressFormatter(options.to);
- }
- ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
- return options[key] !== undefined;
- }).forEach(function(key){
- options[key] = utils.fromDecimal(options[key]);
- });
- return options;
- };
- /**
- * Formats the input of a transaction and converts all values to HEX
- *
- * @method inputTransactionFormatter
- * @param {Object} transaction options
- * @returns object
- */
- var inputTransactionFormatter = function (options){
- options.from = options.from || config.defaultAccount;
- options.from = inputAddressFormatter(options.from);
- if (options.to) { // it might be contract creation
- options.to = inputAddressFormatter(options.to);
- }
- ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
- return options[key] !== undefined;
- }).forEach(function(key){
- options[key] = utils.fromDecimal(options[key]);
- });
- return options;
- };
- /**
- * Formats the output of a transaction to its proper values
- *
- * @method outputTransactionFormatter
- * @param {Object} tx
- * @returns {Object}
- */
- var outputTransactionFormatter = function (tx){
- if(tx.blockNumber !== null)
- tx.blockNumber = utils.toDecimal(tx.blockNumber);
- if(tx.transactionIndex !== null)
- tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
- tx.nonce = utils.toDecimal(tx.nonce);
- tx.gas = utils.toDecimal(tx.gas);
- tx.gasPrice = utils.toBigNumber(tx.gasPrice);
- tx.value = utils.toBigNumber(tx.value);
- return tx;
- };
- /**
- * Formats the output of a transaction receipt to its proper values
- *
- * @method outputTransactionReceiptFormatter
- * @param {Object} receipt
- * @returns {Object}
- */
- var outputTransactionReceiptFormatter = function (receipt){
- if(receipt.blockNumber !== null)
- receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
- if(receipt.transactionIndex !== null)
- receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
- receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
- receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
- if(utils.isArray(receipt.logs)) {
- receipt.logs = receipt.logs.map(function(log){
- return outputLogFormatter(log);
- });
- }
- return receipt;
- };
- /**
- * Formats the output of a block to its proper values
- *
- * @method outputBlockFormatter
- * @param {Object} block
- * @returns {Object}
- */
- var outputBlockFormatter = function(block) {
- // transform to number
- block.gasLimit = utils.toDecimal(block.gasLimit);
- block.gasUsed = utils.toDecimal(block.gasUsed);
- block.size = utils.toDecimal(block.size);
- block.timestamp = utils.toDecimal(block.timestamp);
- if(block.number !== null)
- block.number = utils.toDecimal(block.number);
- block.difficulty = utils.toBigNumber(block.difficulty);
- block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
- if (utils.isArray(block.transactions)) {
- block.transactions.forEach(function(item){
- if(!utils.isString(item))
- return outputTransactionFormatter(item);
- });
- }
- return block;
- };
- /**
- * Formats the output of a log
- *
- * @method outputLogFormatter
- * @param {Object} log object
- * @returns {Object} log
- */
- var outputLogFormatter = function(log) {
- if(log.blockNumber !== null)
- log.blockNumber = utils.toDecimal(log.blockNumber);
- if(log.transactionIndex !== null)
- log.transactionIndex = utils.toDecimal(log.transactionIndex);
- if(log.logIndex !== null)
- log.logIndex = utils.toDecimal(log.logIndex);
- return log;
- };
- /**
- * Formats the input of a whisper post and converts all values to HEX
- *
- * @method inputPostFormatter
- * @param {Object} transaction object
- * @returns {Object}
- */
- var inputPostFormatter = function(post) {
- // post.payload = utils.toHex(post.payload);
- post.ttl = utils.fromDecimal(post.ttl);
- post.workToProve = utils.fromDecimal(post.workToProve);
- post.priority = utils.fromDecimal(post.priority);
- // fallback
- if (!utils.isArray(post.topics)) {
- post.topics = post.topics ? [post.topics] : [];
- }
- // format the following options
- post.topics = post.topics.map(function(topic){
- // convert only if not hex
- return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
- });
- return post;
- };
- /**
- * Formats the output of a received post message
- *
- * @method outputPostFormatter
- * @param {Object}
- * @returns {Object}
- */
- var outputPostFormatter = function(post){
- post.expiry = utils.toDecimal(post.expiry);
- post.sent = utils.toDecimal(post.sent);
- post.ttl = utils.toDecimal(post.ttl);
- post.workProved = utils.toDecimal(post.workProved);
- // post.payloadRaw = post.payload;
- // post.payload = utils.toAscii(post.payload);
- // if (utils.isJson(post.payload)) {
- // post.payload = JSON.parse(post.payload);
- // }
- // format the following options
- if (!post.topics) {
- post.topics = [];
- }
- post.topics = post.topics.map(function(topic){
- return utils.toAscii(topic);
- });
- return post;
- };
- var inputAddressFormatter = function (address) {
- var iban = new Iban(address);
- if (iban.isValid() && iban.isDirect()) {
- return '0x' + iban.address();
- } else if (utils.isStrictAddress(address)) {
- return address;
- } else if (utils.isAddress(address)) {
- return '0x' + address;
- }
- throw new Error('invalid address');
- };
- var outputSyncingFormatter = function(result) {
- result.startingBlock = utils.toDecimal(result.startingBlock);
- result.currentBlock = utils.toDecimal(result.currentBlock);
- result.highestBlock = utils.toDecimal(result.highestBlock);
- if (result.knownStates) {
- result.knownStates = utils.toDecimal(result.knownStates);
- result.pulledStates = utils.toDecimal(result.pulledStates);
- }
- return result;
- };
- module.exports = {
- inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
- inputBlockNumberFormatter: inputBlockNumberFormatter,
- inputCallFormatter: inputCallFormatter,
- inputTransactionFormatter: inputTransactionFormatter,
- inputAddressFormatter: inputAddressFormatter,
- inputPostFormatter: inputPostFormatter,
- outputBigNumberFormatter: outputBigNumberFormatter,
- outputTransactionFormatter: outputTransactionFormatter,
- outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
- outputBlockFormatter: outputBlockFormatter,
- outputLogFormatter: outputLogFormatter,
- outputPostFormatter: outputPostFormatter,
- outputSyncingFormatter: outputSyncingFormatter
- };
- },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file function.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var coder = require('../solidity/coder');
- var utils = require('../utils/utils');
- var formatters = require('./formatters');
- var sha3 = require('../utils/sha3');
- /**
- * This prototype should be used to call/sendTransaction to solidity functions
- */
- var SolidityFunction = function (eth, json, address) {
- this._eth = eth;
- this._inputTypes = json.inputs.map(function (i) {
- return i.type;
- });
- this._outputTypes = json.outputs.map(function (i) {
- return i.type;
- });
- this._constant = json.constant;
- this._payable = json.payable;
- this._name = utils.transformToFullName(json);
- this._address = address;
- };
- SolidityFunction.prototype.extractCallback = function (args) {
- if (utils.isFunction(args[args.length - 1])) {
- return args.pop(); // modify the args array!
- }
- };
- SolidityFunction.prototype.extractDefaultBlock = function (args) {
- if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
- return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
- }
- };
- /**
- * Should be used to create payload from arguments
- *
- * @method toPayload
- * @param {Array} solidity function params
- * @param {Object} optional payload options
- */
- SolidityFunction.prototype.toPayload = function (args) {
- var options = {};
- if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
- options = args[args.length - 1];
- }
- options.to = this._address;
- options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
- return options;
- };
- /**
- * Should be used to get function signature
- *
- * @method signature
- * @return {String} function signature
- */
- SolidityFunction.prototype.signature = function () {
- return sha3(this._name).slice(0, 8);
- };
- SolidityFunction.prototype.unpackOutput = function (output) {
- if (!output) {
- return;
- }
- output = output.length >= 2 ? output.slice(2) : output;
- var result = coder.decodeParams(this._outputTypes, output);
- return result.length === 1 ? result[0] : result;
- };
- /**
- * Calls a contract function.
- *
- * @method call
- * @param {...Object} Contract function arguments
- * @param {function} If the last argument is a function, the contract function
- * call will be asynchronous, and the callback will be passed the
- * error and result.
- * @return {String} output bytes
- */
- SolidityFunction.prototype.call = function () {
- var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
- var callback = this.extractCallback(args);
- var defaultBlock = this.extractDefaultBlock(args);
- var payload = this.toPayload(args);
- if (!callback) {
- var output = this._eth.call(payload, defaultBlock);
- return this.unpackOutput(output);
- }
- var self = this;
- this._eth.call(payload, defaultBlock, function (error, output) {
- if (error) return callback(error, null);
- var unpacked = null;
- try {
- unpacked = self.unpackOutput(output);
- }
- catch (e) {
- error = e;
- }
- callback(error, unpacked);
- });
- };
- /**
- * Should be used to sendTransaction to solidity function
- *
- * @method sendTransaction
- */
- SolidityFunction.prototype.sendTransaction = function () {
- var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
- var callback = this.extractCallback(args);
- var payload = this.toPayload(args);
- if (payload.value > 0 && !this._payable) {
- throw new Error('Cannot send value to non-payable function');
- }
- if (!callback) {
- return this._eth.sendTransaction(payload);
- }
- this._eth.sendTransaction(payload, callback);
- };
- /**
- * Should be used to estimateGas of solidity function
- *
- * @method estimateGas
- */
- SolidityFunction.prototype.estimateGas = function () {
- var args = Array.prototype.slice.call(arguments);
- var callback = this.extractCallback(args);
- var payload = this.toPayload(args);
- if (!callback) {
- return this._eth.estimateGas(payload);
- }
- this._eth.estimateGas(payload, callback);
- };
- /**
- * Return the encoded data of the call
- *
- * @method getData
- * @return {String} the encoded data
- */
- SolidityFunction.prototype.getData = function () {
- var args = Array.prototype.slice.call(arguments);
- var payload = this.toPayload(args);
- return payload.data;
- };
- /**
- * Should be used to get function display name
- *
- * @method displayName
- * @return {String} display name of the function
- */
- SolidityFunction.prototype.displayName = function () {
- return utils.extractDisplayName(this._name);
- };
- /**
- * Should be used to get function type name
- *
- * @method typeName
- * @return {String} type name of the function
- */
- SolidityFunction.prototype.typeName = function () {
- return utils.extractTypeName(this._name);
- };
- /**
- * Should be called to get rpc requests from solidity function
- *
- * @method request
- * @returns {Object}
- */
- SolidityFunction.prototype.request = function () {
- var args = Array.prototype.slice.call(arguments);
- var callback = this.extractCallback(args);
- var payload = this.toPayload(args);
- var format = this.unpackOutput.bind(this);
- return {
- method: this._constant ? 'eth_call' : 'eth_sendTransaction',
- callback: callback,
- params: [payload],
- format: format
- };
- };
- /**
- * Should be called to execute function
- *
- * @method execute
- */
- SolidityFunction.prototype.execute = function () {
- var transaction = !this._constant;
- // send transaction
- if (transaction) {
- return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
- }
- // call
- return this.call.apply(this, Array.prototype.slice.call(arguments));
- };
- /**
- * Should be called to attach function to contract
- *
- * @method attachToContract
- * @param {Contract}
- */
- SolidityFunction.prototype.attachToContract = function (contract) {
- var execute = this.execute.bind(this);
- execute.request = this.request.bind(this);
- execute.call = this.call.bind(this);
- execute.sendTransaction = this.sendTransaction.bind(this);
- execute.estimateGas = this.estimateGas.bind(this);
- execute.getData = this.getData.bind(this);
- var displayName = this.displayName();
- if (!contract[displayName]) {
- contract[displayName] = execute;
- }
- contract[displayName][this.typeName()] = execute; // circular!!!!
- };
- module.exports = SolidityFunction;
- },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file httpprovider.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * Marian Oancea <[email protected]>
- * Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- var errors = require('./errors');
- // workaround to use httpprovider in different envs
- // browser
- if (typeof window !== 'undefined' && window.XMLHttpRequest) {
- XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
- // node
- } else {
- XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
- }
- var XHR2 = require('xhr2'); // jshint ignore: line
- /**
- * HttpProvider should be used to send rpc calls over http
- */
- var HttpProvider = function (host, timeout) {
- this.host = host || 'http://localhost:8545';
- this.timeout = timeout || 0;
- };
- /**
- * Should be called to prepare new XMLHttpRequest
- *
- * @method prepareRequest
- * @param {Boolean} true if request should be async
- * @return {XMLHttpRequest} object
- */
- HttpProvider.prototype.prepareRequest = function (async) {
- var request;
- if (async) {
- request = new XHR2();
- request.timeout = this.timeout;
- }else {
- request = new XMLHttpRequest();
- }
- request.open('POST', this.host, async);
- request.setRequestHeader('Content-Type','application/json');
- return request;
- };
- /**
- * Should be called to make sync request
- *
- * @method send
- * @param {Object} payload
- * @return {Object} result
- */
- HttpProvider.prototype.send = function (payload) {
- var request = this.prepareRequest(false);
- try {
- request.send(JSON.stringify(payload));
- } catch(error) {
- throw errors.InvalidConnection(this.host);
- }
- var result = request.responseText;
- try {
- result = JSON.parse(result);
- } catch(e) {
- throw errors.InvalidResponse(request.responseText);
- }
- return result;
- };
- /**
- * Should be used to make async request
- *
- * @method sendAsync
- * @param {Object} payload
- * @param {Function} callback triggered on end with (err, result)
- */
- HttpProvider.prototype.sendAsync = function (payload, callback) {
- var request = this.prepareRequest(true);
- request.onreadystatechange = function() {
- if (request.readyState === 4 && request.timeout !== 1) {
- var result = request.responseText;
- var error = null;
- try {
- result = JSON.parse(result);
- } catch(e) {
- error = errors.InvalidResponse(request.responseText);
- }
- callback(error, result);
- }
- };
- request.ontimeout = function() {
- callback(errors.ConnectionTimeout(this.timeout));
- };
- try {
- request.send(JSON.stringify(payload));
- } catch(error) {
- callback(errors.InvalidConnection(this.host));
- }
- };
- /**
- * Synchronously tries to make Http request
- *
- * @method isConnected
- * @return {Boolean} returns true if request haven't failed. Otherwise false
- */
- HttpProvider.prototype.isConnected = function() {
- try {
- this.send({
- id: 9999999999,
- jsonrpc: '2.0',
- method: 'net_listening',
- params: []
- });
- return true;
- } catch(e) {
- return false;
- }
- };
- module.exports = HttpProvider;
- },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file iban.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var BigNumber = require('bignumber.js');
- var padLeft = function (string, bytes) {
- var result = string;
- while (result.length < bytes * 2) {
- result = '0' + result;
- }
- return result;
- };
- /**
- * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
- * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
- *
- * @method iso13616Prepare
- * @param {String} iban the IBAN
- * @returns {String} the prepared IBAN
- */
- var iso13616Prepare = function (iban) {
- var A = 'A'.charCodeAt(0);
- var Z = 'Z'.charCodeAt(0);
- iban = iban.toUpperCase();
- iban = iban.substr(4) + iban.substr(0,4);
- return iban.split('').map(function(n){
- var code = n.charCodeAt(0);
- if (code >= A && code <= Z){
- // A = 10, B = 11, ... Z = 35
- return code - A + 10;
- } else {
- return n;
- }
- }).join('');
- };
- /**
- * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
- *
- * @method mod9710
- * @param {String} iban
- * @returns {Number}
- */
- var mod9710 = function (iban) {
- var remainder = iban,
- block;
- while (remainder.length > 2){
- block = remainder.slice(0, 9);
- remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
- }
- return parseInt(remainder, 10) % 97;
- };
- /**
- * This prototype should be used to create iban object from iban correct string
- *
- * @param {String} iban
- */
- var Iban = function (iban) {
- this._iban = iban;
- };
- /**
- * This method should be used to create iban object from ethereum address
- *
- * @method fromAddress
- * @param {String} address
- * @return {Iban} the IBAN object
- */
- Iban.fromAddress = function (address) {
- var asBn = new BigNumber(address, 16);
- var base36 = asBn.toString(36);
- var padded = padLeft(base36, 15);
- return Iban.fromBban(padded.toUpperCase());
- };
- /**
- * Convert the passed BBAN to an IBAN for this country specification.
- * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
- * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
- *
- * @method fromBban
- * @param {String} bban the BBAN to convert to IBAN
- * @returns {Iban} the IBAN object
- */
- Iban.fromBban = function (bban) {
- var countryCode = 'XE';
- var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
- var checkDigit = ('0' + (98 - remainder)).slice(-2);
- return new Iban(countryCode + checkDigit + bban);
- };
- /**
- * Should be used to create IBAN object for given institution and identifier
- *
- * @method createIndirect
- * @param {Object} options, required options are "institution" and "identifier"
- * @return {Iban} the IBAN object
- */
- Iban.createIndirect = function (options) {
- return Iban.fromBban('ETH' + options.institution + options.identifier);
- };
- /**
- * Thos method should be used to check if given string is valid iban object
- *
- * @method isValid
- * @param {String} iban string
- * @return {Boolean} true if it is valid IBAN
- */
- Iban.isValid = function (iban) {
- var i = new Iban(iban);
- return i.isValid();
- };
- /**
- * Should be called to check if iban is correct
- *
- * @method isValid
- * @returns {Boolean} true if it is, otherwise false
- */
- Iban.prototype.isValid = function () {
- return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
- mod9710(iso13616Prepare(this._iban)) === 1;
- };
- /**
- * Should be called to check if iban number is direct
- *
- * @method isDirect
- * @returns {Boolean} true if it is, otherwise false
- */
- Iban.prototype.isDirect = function () {
- return this._iban.length === 34 || this._iban.length === 35;
- };
- /**
- * Should be called to check if iban number if indirect
- *
- * @method isIndirect
- * @returns {Boolean} true if it is, otherwise false
- */
- Iban.prototype.isIndirect = function () {
- return this._iban.length === 20;
- };
- /**
- * Should be called to get iban checksum
- * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
- *
- * @method checksum
- * @returns {String} checksum
- */
- Iban.prototype.checksum = function () {
- return this._iban.substr(2, 2);
- };
- /**
- * Should be called to get institution identifier
- * eg. XREG
- *
- * @method institution
- * @returns {String} institution identifier
- */
- Iban.prototype.institution = function () {
- return this.isIndirect() ? this._iban.substr(7, 4) : '';
- };
- /**
- * Should be called to get client identifier within institution
- * eg. GAVOFYORK
- *
- * @method client
- * @returns {String} client identifier
- */
- Iban.prototype.client = function () {
- return this.isIndirect() ? this._iban.substr(11) : '';
- };
- /**
- * Should be called to get client direct address
- *
- * @method address
- * @returns {String} client direct address
- */
- Iban.prototype.address = function () {
- if (this.isDirect()) {
- var base36 = this._iban.substr(4);
- var asBn = new BigNumber(base36, 36);
- return padLeft(asBn.toString(16), 20);
- }
- return '';
- };
- Iban.prototype.toString = function () {
- return this._iban;
- };
- module.exports = Iban;
- },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file ipcprovider.js
- * @authors:
- * Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- "use strict";
- var utils = require('../utils/utils');
- var errors = require('./errors');
- var IpcProvider = function (path, net) {
- var _this = this;
- this.responseCallbacks = {};
- this.path = path;
-
- this.connection = net.connect({path: this.path});
- this.connection.on('error', function(e){
- console.error('IPC Connection Error', e);
- _this._timeout();
- });
- this.connection.on('end', function(){
- _this._timeout();
- });
- // LISTEN FOR CONNECTION RESPONSES
- this.connection.on('data', function(data) {
- /*jshint maxcomplexity: 6 */
- _this._parseResponse(data.toString()).forEach(function(result){
- var id = null;
- // get the id which matches the returned id
- if(utils.isArray(result)) {
- result.forEach(function(load){
- if(_this.responseCallbacks[load.id])
- id = load.id;
- });
- } else {
- id = result.id;
- }
- // fire the callback
- if(_this.responseCallbacks[id]) {
- _this.responseCallbacks[id](null, result);
- delete _this.responseCallbacks[id];
- }
- });
- });
- };
- /**
- Will parse the response and make an array out of it.
- @method _parseResponse
- @param {String} data
- */
- IpcProvider.prototype._parseResponse = function(data) {
- var _this = this,
- returnValues = [];
-
- // DE-CHUNKER
- var dechunkedData = data
- .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
- .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
- .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
- .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
- .split('|--|');
- dechunkedData.forEach(function(data){
- // prepend the last chunk
- if(_this.lastChunk)
- data = _this.lastChunk + data;
- var result = null;
- try {
- result = JSON.parse(data);
- } catch(e) {
- _this.lastChunk = data;
- // start timeout to cancel all requests
- clearTimeout(_this.lastChunkTimeout);
- _this.lastChunkTimeout = setTimeout(function(){
- _this._timeout();
- throw errors.InvalidResponse(data);
- }, 1000 * 15);
- return;
- }
- // cancel timeout and set chunk to null
- clearTimeout(_this.lastChunkTimeout);
- _this.lastChunk = null;
- if(result)
- returnValues.push(result);
- });
- return returnValues;
- };
- /**
- Get the adds a callback to the responseCallbacks object,
- which will be called if a response matching the response Id will arrive.
- @method _addResponseCallback
- */
- IpcProvider.prototype._addResponseCallback = function(payload, callback) {
- var id = payload.id || payload[0].id;
- var method = payload.method || payload[0].method;
- this.responseCallbacks[id] = callback;
- this.responseCallbacks[id].method = method;
- };
- /**
- Timeout all requests when the end/error event is fired
- @method _timeout
- */
- IpcProvider.prototype._timeout = function() {
- for(var key in this.responseCallbacks) {
- if(this.responseCallbacks.hasOwnProperty(key)){
- this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
- delete this.responseCallbacks[key];
- }
- }
- };
- /**
- Check if the current connection is still valid.
- @method isConnected
- */
- IpcProvider.prototype.isConnected = function() {
- var _this = this;
- // try reconnect, when connection is gone
- if(!_this.connection.writable)
- _this.connection.connect({path: _this.path});
- return !!this.connection.writable;
- };
- IpcProvider.prototype.send = function (payload) {
- if(this.connection.writeSync) {
- var result;
- // try reconnect, when connection is gone
- if(!this.connection.writable)
- this.connection.connect({path: this.path});
- var data = this.connection.writeSync(JSON.stringify(payload));
- try {
- result = JSON.parse(data);
- } catch(e) {
- throw errors.InvalidResponse(data);
- }
- return result;
- } else {
- throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
- }
- };
- IpcProvider.prototype.sendAsync = function (payload, callback) {
- // try reconnect, when connection is gone
- if(!this.connection.writable)
- this.connection.connect({path: this.path});
- this.connection.write(JSON.stringify(payload));
- this._addResponseCallback(payload, callback);
- };
- module.exports = IpcProvider;
- },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file jsonrpc.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * Aaron Kumavis <[email protected]>
- * @date 2015
- */
- // Initialize Jsonrpc as a simple object with utility functions.
- var Jsonrpc = {
- messageId: 0
- };
- /**
- * Should be called to valid json create payload object
- *
- * @method toPayload
- * @param {Function} method of jsonrpc call, required
- * @param {Array} params, an array of method params, optional
- * @returns {Object} valid jsonrpc payload object
- */
- Jsonrpc.toPayload = function (method, params) {
- if (!method)
- console.error('jsonrpc method should be specified!');
- // advance message ID
- Jsonrpc.messageId++;
- return {
- jsonrpc: '2.0',
- id: Jsonrpc.messageId,
- method: method,
- params: params || []
- };
- };
- /**
- * Should be called to check if jsonrpc response is valid
- *
- * @method isValidResponse
- * @param {Object}
- * @returns {Boolean} true if response is valid, otherwise false
- */
- Jsonrpc.isValidResponse = function (response) {
- return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
- function validateSingleMessage(message){
- return !!message &&
- !message.error &&
- message.jsonrpc === '2.0' &&
- typeof message.id === 'number' &&
- message.result !== undefined; // only undefined is not valid json object
- }
- };
- /**
- * Should be called to create batch payload object
- *
- * @method toBatchPayload
- * @param {Array} messages, an array of objects with method (required) and params (optional) fields
- * @returns {Array} batch payload
- */
- Jsonrpc.toBatchPayload = function (messages) {
- return messages.map(function (message) {
- return Jsonrpc.toPayload(message.method, message.params);
- });
- };
- module.exports = Jsonrpc;
- },{}],36:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file method.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var utils = require('../utils/utils');
- var errors = require('./errors');
- var Method = function (options) {
- this.name = options.name;
- this.call = options.call;
- this.params = options.params || 0;
- this.inputFormatter = options.inputFormatter;
- this.outputFormatter = options.outputFormatter;
- this.requestManager = null;
- };
- Method.prototype.setRequestManager = function (rm) {
- this.requestManager = rm;
- };
- /**
- * Should be used to determine name of the jsonrpc method based on arguments
- *
- * @method getCall
- * @param {Array} arguments
- * @return {String} name of jsonrpc method
- */
- Method.prototype.getCall = function (args) {
- return utils.isFunction(this.call) ? this.call(args) : this.call;
- };
- /**
- * Should be used to extract callback from array of arguments. Modifies input param
- *
- * @method extractCallback
- * @param {Array} arguments
- * @return {Function|Null} callback, if exists
- */
- Method.prototype.extractCallback = function (args) {
- if (utils.isFunction(args[args.length - 1])) {
- return args.pop(); // modify the args array!
- }
- };
- /**
- * Should be called to check if the number of arguments is correct
- *
- * @method validateArgs
- * @param {Array} arguments
- * @throws {Error} if it is not
- */
- Method.prototype.validateArgs = function (args) {
- if (args.length !== this.params) {
- throw errors.InvalidNumberOfParams();
- }
- };
- /**
- * Should be called to format input args of method
- *
- * @method formatInput
- * @param {Array}
- * @return {Array}
- */
- Method.prototype.formatInput = function (args) {
- if (!this.inputFormatter) {
- return args;
- }
- return this.inputFormatter.map(function (formatter, index) {
- return formatter ? formatter(args[index]) : args[index];
- });
- };
- /**
- * Should be called to format output(result) of method
- *
- * @method formatOutput
- * @param {Object}
- * @return {Object}
- */
- Method.prototype.formatOutput = function (result) {
- return this.outputFormatter && result ? this.outputFormatter(result) : result;
- };
- /**
- * Should create payload from given input args
- *
- * @method toPayload
- * @param {Array} args
- * @return {Object}
- */
- Method.prototype.toPayload = function (args) {
- var call = this.getCall(args);
- var callback = this.extractCallback(args);
- var params = this.formatInput(args);
- this.validateArgs(params);
- return {
- method: call,
- params: params,
- callback: callback
- };
- };
- Method.prototype.attachToObject = function (obj) {
- var func = this.buildCall();
- func.call = this.call; // TODO!!! that's ugly. filter.js uses it
- var name = this.name.split('.');
- if (name.length > 1) {
- obj[name[0]] = obj[name[0]] || {};
- obj[name[0]][name[1]] = func;
- } else {
- obj[name[0]] = func;
- }
- };
- Method.prototype.buildCall = function() {
- var method = this;
- var send = function () {
- var payload = method.toPayload(Array.prototype.slice.call(arguments));
- if (payload.callback) {
- return method.requestManager.sendAsync(payload, function (err, result) {
- payload.callback(err, method.formatOutput(result));
- });
- }
- return method.formatOutput(method.requestManager.send(payload));
- };
- send.request = this.request.bind(this);
- return send;
- };
- /**
- * Should be called to create pure JSONRPC request which can be used in batch request
- *
- * @method request
- * @param {...} params
- * @return {Object} jsonrpc request
- */
- Method.prototype.request = function () {
- var payload = this.toPayload(Array.prototype.slice.call(arguments));
- payload.format = this.formatOutput.bind(this);
- return payload;
- };
- module.exports = Method;
- },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file db.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var Method = require('../method');
- var DB = function (web3) {
- this._requestManager = web3._requestManager;
- var self = this;
-
- methods().forEach(function(method) {
- method.attachToObject(self);
- method.setRequestManager(web3._requestManager);
- });
- };
- var methods = function () {
- var putString = new Method({
- name: 'putString',
- call: 'db_putString',
- params: 3
- });
- var getString = new Method({
- name: 'getString',
- call: 'db_getString',
- params: 2
- });
- var putHex = new Method({
- name: 'putHex',
- call: 'db_putHex',
- params: 3
- });
- var getHex = new Method({
- name: 'getHex',
- call: 'db_getHex',
- params: 2
- });
- return [
- putString, getString, putHex, getHex
- ];
- };
- module.exports = DB;
- },{"../method":36}],38:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file eth.js
- * @author Marek Kotewicz <[email protected]>
- * @author Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- "use strict";
- var formatters = require('../formatters');
- var utils = require('../../utils/utils');
- var Method = require('../method');
- var Property = require('../property');
- var c = require('../../utils/config');
- var Contract = require('../contract');
- var watches = require('./watches');
- var Filter = require('../filter');
- var IsSyncing = require('../syncing');
- var namereg = require('../namereg');
- var Iban = require('../iban');
- var transfer = require('../transfer');
- var blockCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
- };
- var transactionFromBlockCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
- };
- var uncleCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
- };
- var getBlockTransactionCountCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
- };
- var uncleCountCall = function (args) {
- return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
- };
- function Eth(web3) {
- this._requestManager = web3._requestManager;
- var self = this;
- methods().forEach(function(method) {
- method.attachToObject(self);
- method.setRequestManager(self._requestManager);
- });
- properties().forEach(function(p) {
- p.attachToObject(self);
- p.setRequestManager(self._requestManager);
- });
- this.iban = Iban;
- this.sendIBANTransaction = transfer.bind(null, this);
- }
- Object.defineProperty(Eth.prototype, 'defaultBlock', {
- get: function () {
- return c.defaultBlock;
- },
- set: function (val) {
- c.defaultBlock = val;
- return val;
- }
- });
- Object.defineProperty(Eth.prototype, 'defaultAccount', {
- get: function () {
- return c.defaultAccount;
- },
- set: function (val) {
- c.defaultAccount = val;
- return val;
- }
- });
- var methods = function () {
- var getBalance = new Method({
- name: 'getBalance',
- call: 'eth_getBalance',
- params: 2,
- inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
- outputFormatter: formatters.outputBigNumberFormatter
- });
- var getStorageAt = new Method({
- name: 'getStorageAt',
- call: 'eth_getStorageAt',
- params: 3,
- inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
- });
- var getCode = new Method({
- name: 'getCode',
- call: 'eth_getCode',
- params: 2,
- inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
- });
- var getBlock = new Method({
- name: 'getBlock',
- call: blockCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
- outputFormatter: formatters.outputBlockFormatter
- });
- var getUncle = new Method({
- name: 'getUncle',
- call: uncleCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
- outputFormatter: formatters.outputBlockFormatter,
- });
- var getCompilers = new Method({
- name: 'getCompilers',
- call: 'eth_getCompilers',
- params: 0
- });
- var getBlockTransactionCount = new Method({
- name: 'getBlockTransactionCount',
- call: getBlockTransactionCountCall,
- params: 1,
- inputFormatter: [formatters.inputBlockNumberFormatter],
- outputFormatter: utils.toDecimal
- });
- var getBlockUncleCount = new Method({
- name: 'getBlockUncleCount',
- call: uncleCountCall,
- params: 1,
- inputFormatter: [formatters.inputBlockNumberFormatter],
- outputFormatter: utils.toDecimal
- });
- var getTransaction = new Method({
- name: 'getTransaction',
- call: 'eth_getTransactionByHash',
- params: 1,
- outputFormatter: formatters.outputTransactionFormatter
- });
- var getTransactionFromBlock = new Method({
- name: 'getTransactionFromBlock',
- call: transactionFromBlockCall,
- params: 2,
- inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
- outputFormatter: formatters.outputTransactionFormatter
- });
- var getTransactionReceipt = new Method({
- name: 'getTransactionReceipt',
- call: 'eth_getTransactionReceipt',
- params: 1,
- outputFormatter: formatters.outputTransactionReceiptFormatter
- });
- var getTransactionCount = new Method({
- name: 'getTransactionCount',
- call: 'eth_getTransactionCount',
- params: 2,
- inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
- outputFormatter: utils.toDecimal
- });
- var sendRawTransaction = new Method({
- name: 'sendRawTransaction',
- call: 'eth_sendRawTransaction',
- params: 1,
- inputFormatter: [null]
- });
- var sendTransaction = new Method({
- name: 'sendTransaction',
- call: 'eth_sendTransaction',
- params: 1,
- inputFormatter: [formatters.inputTransactionFormatter]
- });
- var sign = new Method({
- name: 'sign',
- call: 'eth_sign',
- params: 2,
- inputFormatter: [formatters.inputAddressFormatter, null]
- });
- var call = new Method({
- name: 'call',
- call: 'eth_call',
- params: 2,
- inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
- });
- var estimateGas = new Method({
- name: 'estimateGas',
- call: 'eth_estimateGas',
- params: 1,
- inputFormatter: [formatters.inputCallFormatter],
- outputFormatter: utils.toDecimal
- });
- var compileSolidity = new Method({
- name: 'compile.solidity',
- call: 'eth_compileSolidity',
- params: 1
- });
- var compileLLL = new Method({
- name: 'compile.lll',
- call: 'eth_compileLLL',
- params: 1
- });
- var compileSerpent = new Method({
- name: 'compile.serpent',
- call: 'eth_compileSerpent',
- params: 1
- });
- var submitWork = new Method({
- name: 'submitWork',
- call: 'eth_submitWork',
- params: 3
- });
- var getWork = new Method({
- name: 'getWork',
- call: 'eth_getWork',
- params: 0
- });
- return [
- getBalance,
- getStorageAt,
- getCode,
- getBlock,
- getUncle,
- getCompilers,
- getBlockTransactionCount,
- getBlockUncleCount,
- getTransaction,
- getTransactionFromBlock,
- getTransactionReceipt,
- getTransactionCount,
- call,
- estimateGas,
- sendRawTransaction,
- sendTransaction,
- sign,
- compileSolidity,
- compileLLL,
- compileSerpent,
- submitWork,
- getWork
- ];
- };
- var properties = function () {
- return [
- new Property({
- name: 'coinbase',
- getter: 'eth_coinbase'
- }),
- new Property({
- name: 'mining',
- getter: 'eth_mining'
- }),
- new Property({
- name: 'hashrate',
- getter: 'eth_hashrate',
- outputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'syncing',
- getter: 'eth_syncing',
- outputFormatter: formatters.outputSyncingFormatter
- }),
- new Property({
- name: 'gasPrice',
- getter: 'eth_gasPrice',
- outputFormatter: formatters.outputBigNumberFormatter
- }),
- new Property({
- name: 'accounts',
- getter: 'eth_accounts'
- }),
- new Property({
- name: 'blockNumber',
- getter: 'eth_blockNumber',
- outputFormatter: utils.toDecimal
- }),
- new Property({
- name: 'protocolVersion',
- getter: 'eth_protocolVersion'
- })
- ];
- };
- Eth.prototype.contract = function (abi) {
- var factory = new Contract(this, abi);
- return factory;
- };
- Eth.prototype.filter = function (fil, callback) {
- return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
- };
- Eth.prototype.namereg = function () {
- return this.contract(namereg.global.abi).at(namereg.global.address);
- };
- Eth.prototype.icapNamereg = function () {
- return this.contract(namereg.icap.abi).at(namereg.icap.address);
- };
- Eth.prototype.isSyncing = function (callback) {
- return new IsSyncing(this._requestManager, callback);
- };
- module.exports = Eth;
- },{"../../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){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file eth.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var utils = require('../../utils/utils');
- var Property = require('../property');
- var Net = function (web3) {
- this._requestManager = web3._requestManager;
- var self = this;
- properties().forEach(function(p) {
- p.attachToObject(self);
- p.setRequestManager(web3._requestManager);
- });
- };
- /// @returns an array of objects describing web3.eth api properties
- var properties = function () {
- return [
- new Property({
- name: 'listening',
- getter: 'net_listening'
- }),
- new Property({
- name: 'peerCount',
- getter: 'net_peerCount',
- outputFormatter: utils.toDecimal
- })
- ];
- };
- module.exports = Net;
- },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file eth.js
- * @author Marek Kotewicz <[email protected]>
- * @author Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- "use strict";
- var Method = require('../method');
- var Property = require('../property');
- var formatters = require('../formatters');
- function Personal(web3) {
- this._requestManager = web3._requestManager;
- var self = this;
- methods().forEach(function(method) {
- method.attachToObject(self);
- method.setRequestManager(self._requestManager);
- });
- properties().forEach(function(p) {
- p.attachToObject(self);
- p.setRequestManager(self._requestManager);
- });
- }
- var methods = function () {
- var newAccount = new Method({
- name: 'newAccount',
- call: 'personal_newAccount',
- params: 1,
- inputFormatter: [null]
- });
- var unlockAccount = new Method({
- name: 'unlockAccount',
- call: 'personal_unlockAccount',
- params: 3,
- inputFormatter: [formatters.inputAddressFormatter, null, null]
- });
- var sendTransaction = new Method({
- name: 'sendTransaction',
- call: 'personal_sendTransaction',
- params: 2,
- inputFormatter: [formatters.inputTransactionFormatter, null]
- });
- var lockAccount = new Method({
- name: 'lockAccount',
- call: 'personal_lockAccount',
- params: 1,
- inputFormatter: [formatters.inputAddressFormatter]
- });
- return [
- newAccount,
- unlockAccount,
- sendTransaction,
- lockAccount
- ];
- };
- var properties = function () {
- return [
- new Property({
- name: 'listAccounts',
- getter: 'personal_listAccounts'
- })
- ];
- };
- module.exports = Personal;
- },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file shh.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var Method = require('../method');
- var formatters = require('../formatters');
- var Filter = require('../filter');
- var watches = require('./watches');
- var Shh = function (web3) {
- this._requestManager = web3._requestManager;
- var self = this;
- methods().forEach(function(method) {
- method.attachToObject(self);
- method.setRequestManager(self._requestManager);
- });
- };
- Shh.prototype.filter = function (fil, callback) {
- return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
- };
- var methods = function () {
- var post = new Method({
- name: 'post',
- call: 'shh_post',
- params: 1,
- inputFormatter: [formatters.inputPostFormatter]
- });
- var newIdentity = new Method({
- name: 'newIdentity',
- call: 'shh_newIdentity',
- params: 0
- });
- var hasIdentity = new Method({
- name: 'hasIdentity',
- call: 'shh_hasIdentity',
- params: 1
- });
- var newGroup = new Method({
- name: 'newGroup',
- call: 'shh_newGroup',
- params: 0
- });
- var addToGroup = new Method({
- name: 'addToGroup',
- call: 'shh_addToGroup',
- params: 0
- });
- return [
- post,
- newIdentity,
- hasIdentity,
- newGroup,
- addToGroup
- ];
- };
- module.exports = Shh;
- },{"../filter":29,"../formatters":30,"../method":36,"./watches":43}],42:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file bzz.js
- * @author Alex Beregszaszi <[email protected]>
- * @date 2016
- *
- * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
- */
- "use strict";
- var Method = require('../method');
- var Property = require('../property');
- function Swarm(web3) {
- this._requestManager = web3._requestManager;
- var self = this;
- methods().forEach(function(method) {
- method.attachToObject(self);
- method.setRequestManager(self._requestManager);
- });
- properties().forEach(function(p) {
- p.attachToObject(self);
- p.setRequestManager(self._requestManager);
- });
- }
- var methods = function () {
- var blockNetworkRead = new Method({
- name: 'blockNetworkRead',
- call: 'bzz_blockNetworkRead',
- params: 1,
- inputFormatter: [null]
- });
- var syncEnabled = new Method({
- name: 'syncEnabled',
- call: 'bzz_syncEnabled',
- params: 1,
- inputFormatter: [null]
- });
- var swapEnabled = new Method({
- name: 'swapEnabled',
- call: 'bzz_swapEnabled',
- params: 1,
- inputFormatter: [null]
- });
- var download = new Method({
- name: 'download',
- call: 'bzz_download',
- params: 2,
- inputFormatter: [null, null]
- });
- var upload = new Method({
- name: 'upload',
- call: 'bzz_upload',
- params: 2,
- inputFormatter: [null, null]
- });
- var retrieve = new Method({
- name: 'retrieve',
- call: 'bzz_retrieve',
- params: 1,
- inputFormatter: [null]
- });
- var store = new Method({
- name: 'store',
- call: 'bzz_store',
- params: 2,
- inputFormatter: [null, null]
- });
- var get = new Method({
- name: 'get',
- call: 'bzz_get',
- params: 1,
- inputFormatter: [null]
- });
- var put = new Method({
- name: 'put',
- call: 'bzz_put',
- params: 2,
- inputFormatter: [null, null]
- });
- var modify = new Method({
- name: 'modify',
- call: 'bzz_modify',
- params: 4,
- inputFormatter: [null, null, null, null]
- });
- return [
- blockNetworkRead,
- syncEnabled,
- swapEnabled,
- download,
- upload,
- retrieve,
- store,
- get,
- put,
- modify
- ];
- };
- var properties = function () {
- return [
- new Property({
- name: 'hive',
- getter: 'bzz_hive'
- }),
- new Property({
- name: 'info',
- getter: 'bzz_info'
- })
- ];
- };
- module.exports = Swarm;
- },{"../method":36,"../property":45}],43:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file watches.js
- * @authors:
- * Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var Method = require('../method');
- /// @returns an array of objects describing web3.eth.filter api methods
- var eth = function () {
- var newFilterCall = function (args) {
- var type = args[0];
- switch(type) {
- case 'latest':
- args.shift();
- this.params = 0;
- return 'eth_newBlockFilter';
- case 'pending':
- args.shift();
- this.params = 0;
- return 'eth_newPendingTransactionFilter';
- default:
- return 'eth_newFilter';
- }
- };
- var newFilter = new Method({
- name: 'newFilter',
- call: newFilterCall,
- params: 1
- });
- var uninstallFilter = new Method({
- name: 'uninstallFilter',
- call: 'eth_uninstallFilter',
- params: 1
- });
- var getLogs = new Method({
- name: 'getLogs',
- call: 'eth_getFilterLogs',
- params: 1
- });
- var poll = new Method({
- name: 'poll',
- call: 'eth_getFilterChanges',
- params: 1
- });
- return [
- newFilter,
- uninstallFilter,
- getLogs,
- poll
- ];
- };
- /// @returns an array of objects describing web3.shh.watch api methods
- var shh = function () {
- var newFilter = new Method({
- name: 'newFilter',
- call: 'shh_newFilter',
- params: 1
- });
- var uninstallFilter = new Method({
- name: 'uninstallFilter',
- call: 'shh_uninstallFilter',
- params: 1
- });
- var getLogs = new Method({
- name: 'getLogs',
- call: 'shh_getMessages',
- params: 1
- });
- var poll = new Method({
- name: 'poll',
- call: 'shh_getFilterChanges',
- params: 1
- });
- return [
- newFilter,
- uninstallFilter,
- getLogs,
- poll
- ];
- };
- module.exports = {
- eth: eth,
- shh: shh
- };
- },{"../method":36}],44:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file namereg.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
- var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
- var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
- var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
- module.exports = {
- global: {
- abi: globalRegistrarAbi,
- address: globalNameregAddress
- },
- icap: {
- abi: icapRegistrarAbi,
- address: icapNameregAddress
- }
- };
- },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file property.js
- * @author Fabian Vogelsteller <[email protected]>
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var utils = require('../utils/utils');
- var Property = function (options) {
- this.name = options.name;
- this.getter = options.getter;
- this.setter = options.setter;
- this.outputFormatter = options.outputFormatter;
- this.inputFormatter = options.inputFormatter;
- this.requestManager = null;
- };
- Property.prototype.setRequestManager = function (rm) {
- this.requestManager = rm;
- };
- /**
- * Should be called to format input args of method
- *
- * @method formatInput
- * @param {Array}
- * @return {Array}
- */
- Property.prototype.formatInput = function (arg) {
- return this.inputFormatter ? this.inputFormatter(arg) : arg;
- };
- /**
- * Should be called to format output(result) of method
- *
- * @method formatOutput
- * @param {Object}
- * @return {Object}
- */
- Property.prototype.formatOutput = function (result) {
- return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
- };
- /**
- * Should be used to extract callback from array of arguments. Modifies input param
- *
- * @method extractCallback
- * @param {Array} arguments
- * @return {Function|Null} callback, if exists
- */
- Property.prototype.extractCallback = function (args) {
- if (utils.isFunction(args[args.length - 1])) {
- return args.pop(); // modify the args array!
- }
- };
- /**
- * Should attach function to method
- *
- * @method attachToObject
- * @param {Object}
- * @param {Function}
- */
- Property.prototype.attachToObject = function (obj) {
- var proto = {
- get: this.buildGet(),
- enumerable: true
- };
- var names = this.name.split('.');
- var name = names[0];
- if (names.length > 1) {
- obj[names[0]] = obj[names[0]] || {};
- obj = obj[names[0]];
- name = names[1];
- }
- Object.defineProperty(obj, name, proto);
- obj[asyncGetterName(name)] = this.buildAsyncGet();
- };
- var asyncGetterName = function (name) {
- return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
- };
- Property.prototype.buildGet = function () {
- var property = this;
- return function get() {
- return property.formatOutput(property.requestManager.send({
- method: property.getter
- }));
- };
- };
- Property.prototype.buildAsyncGet = function () {
- var property = this;
- var get = function (callback) {
- property.requestManager.sendAsync({
- method: property.getter
- }, function (err, result) {
- callback(err, property.formatOutput(result));
- });
- };
- get.request = this.request.bind(this);
- return get;
- };
- /**
- * Should be called to create pure JSONRPC request which can be used in batch request
- *
- * @method request
- * @param {...} params
- * @return {Object} jsonrpc request
- */
- Property.prototype.request = function () {
- var payload = {
- method: this.getter,
- params: [],
- callback: this.extractCallback(Array.prototype.slice.call(arguments))
- };
- payload.format = this.formatOutput.bind(this);
- return payload;
- };
- module.exports = Property;
- },{"../utils/utils":20}],46:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file requestmanager.js
- * @author Jeffrey Wilcke <[email protected]>
- * @author Marek Kotewicz <[email protected]>
- * @author Marian Oancea <[email protected]>
- * @author Fabian Vogelsteller <[email protected]>
- * @author Gav Wood <[email protected]>
- * @date 2014
- */
- var Jsonrpc = require('./jsonrpc');
- var utils = require('../utils/utils');
- var c = require('../utils/config');
- var errors = require('./errors');
- /**
- * It's responsible for passing messages to providers
- * It's also responsible for polling the ethereum node for incoming messages
- * Default poll timeout is 1 second
- * Singleton
- */
- var RequestManager = function (provider) {
- this.provider = provider;
- this.polls = {};
- this.timeout = null;
- };
- /**
- * Should be used to synchronously send request
- *
- * @method send
- * @param {Object} data
- * @return {Object}
- */
- RequestManager.prototype.send = function (data) {
- if (!this.provider) {
- console.error(errors.InvalidProvider());
- return null;
- }
- var payload = Jsonrpc.toPayload(data.method, data.params);
- var result = this.provider.send(payload);
- if (!Jsonrpc.isValidResponse(result)) {
- throw errors.InvalidResponse(result);
- }
- return result.result;
- };
- /**
- * Should be used to asynchronously send request
- *
- * @method sendAsync
- * @param {Object} data
- * @param {Function} callback
- */
- RequestManager.prototype.sendAsync = function (data, callback) {
- if (!this.provider) {
- return callback(errors.InvalidProvider());
- }
- var payload = Jsonrpc.toPayload(data.method, data.params);
- this.provider.sendAsync(payload, function (err, result) {
- if (err) {
- return callback(err);
- }
-
- if (!Jsonrpc.isValidResponse(result)) {
- return callback(errors.InvalidResponse(result));
- }
- callback(null, result.result);
- });
- };
- /**
- * Should be called to asynchronously send batch request
- *
- * @method sendBatch
- * @param {Array} batch data
- * @param {Function} callback
- */
- RequestManager.prototype.sendBatch = function (data, callback) {
- if (!this.provider) {
- return callback(errors.InvalidProvider());
- }
- var payload = Jsonrpc.toBatchPayload(data);
- this.provider.sendAsync(payload, function (err, results) {
- if (err) {
- return callback(err);
- }
- if (!utils.isArray(results)) {
- return callback(errors.InvalidResponse(results));
- }
- callback(err, results);
- });
- };
- /**
- * Should be used to set provider of request manager
- *
- * @method setProvider
- * @param {Object}
- */
- RequestManager.prototype.setProvider = function (p) {
- this.provider = p;
- };
- /**
- * Should be used to start polling
- *
- * @method startPolling
- * @param {Object} data
- * @param {Number} pollId
- * @param {Function} callback
- * @param {Function} uninstall
- *
- * @todo cleanup number of params
- */
- RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
- this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
- // start polling
- if (!this.timeout) {
- this.poll();
- }
- };
- /**
- * Should be used to stop polling for filter with given id
- *
- * @method stopPolling
- * @param {Number} pollId
- */
- RequestManager.prototype.stopPolling = function (pollId) {
- delete this.polls[pollId];
- // stop polling
- if(Object.keys(this.polls).length === 0 && this.timeout) {
- clearTimeout(this.timeout);
- this.timeout = null;
- }
- };
- /**
- * Should be called to reset the polling mechanism of the request manager
- *
- * @method reset
- */
- RequestManager.prototype.reset = function (keepIsSyncing) {
- /*jshint maxcomplexity:5 */
- for (var key in this.polls) {
- // remove all polls, except sync polls,
- // they need to be removed manually by calling syncing.stopWatching()
- if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
- this.polls[key].uninstall();
- delete this.polls[key];
- }
- }
- // stop polling
- if(Object.keys(this.polls).length === 0 && this.timeout) {
- clearTimeout(this.timeout);
- this.timeout = null;
- }
- };
- /**
- * Should be called to poll for changes on filter with given id
- *
- * @method poll
- */
- RequestManager.prototype.poll = function () {
- /*jshint maxcomplexity: 6 */
- this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
- if (Object.keys(this.polls).length === 0) {
- return;
- }
- if (!this.provider) {
- console.error(errors.InvalidProvider());
- return;
- }
- var pollsData = [];
- var pollsIds = [];
- for (var key in this.polls) {
- pollsData.push(this.polls[key].data);
- pollsIds.push(key);
- }
- if (pollsData.length === 0) {
- return;
- }
- var payload = Jsonrpc.toBatchPayload(pollsData);
-
- // map the request id to they poll id
- var pollsIdMap = {};
- payload.forEach(function(load, index){
- pollsIdMap[load.id] = pollsIds[index];
- });
- var self = this;
- this.provider.sendAsync(payload, function (error, results) {
- // TODO: console log?
- if (error) {
- return;
- }
- if (!utils.isArray(results)) {
- throw errors.InvalidResponse(results);
- }
- results.map(function (result) {
- var id = pollsIdMap[result.id];
- // make sure the filter is still installed after arrival of the request
- if (self.polls[id]) {
- result.callback = self.polls[id].callback;
- return result;
- } else
- return false;
- }).filter(function (result) {
- return !!result;
- }).filter(function (result) {
- var valid = Jsonrpc.isValidResponse(result);
- if (!valid) {
- result.callback(errors.InvalidResponse(result));
- }
- return valid;
- }).forEach(function (result) {
- result.callback(null, result.result);
- });
- });
- };
- module.exports = RequestManager;
- },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
- var Settings = function () {
- this.defaultBlock = 'latest';
- this.defaultAccount = undefined;
- };
- module.exports = Settings;
- },{}],48:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /** @file syncing.js
- * @authors:
- * Fabian Vogelsteller <[email protected]>
- * @date 2015
- */
- var formatters = require('./formatters');
- var utils = require('../utils/utils');
- var count = 1;
- /**
- Adds the callback and sets up the methods, to iterate over the results.
- @method pollSyncing
- @param {Object} self
- */
- var pollSyncing = function(self) {
- var onMessage = function (error, sync) {
- if (error) {
- return self.callbacks.forEach(function (callback) {
- callback(error);
- });
- }
- if(utils.isObject(sync) && sync.startingBlock)
- sync = formatters.outputSyncingFormatter(sync);
- self.callbacks.forEach(function (callback) {
- if (self.lastSyncState !== sync) {
-
- // call the callback with true first so the app can stop anything, before receiving the sync data
- if(!self.lastSyncState && utils.isObject(sync))
- callback(null, true);
-
- // call on the next CPU cycle, so the actions of the sync stop can be processes first
- setTimeout(function() {
- callback(null, sync);
- }, 0);
-
- self.lastSyncState = sync;
- }
- });
- };
- self.requestManager.startPolling({
- method: 'eth_syncing',
- params: [],
- }, self.pollId, onMessage, self.stopWatching.bind(self));
- };
- var IsSyncing = function (requestManager, callback) {
- this.requestManager = requestManager;
- this.pollId = 'syncPoll_'+ count++;
- this.callbacks = [];
- this.addCallback(callback);
- this.lastSyncState = false;
- pollSyncing(this);
- return this;
- };
- IsSyncing.prototype.addCallback = function (callback) {
- if(callback)
- this.callbacks.push(callback);
- return this;
- };
- IsSyncing.prototype.stopWatching = function () {
- this.requestManager.stopPolling(this.pollId);
- this.callbacks = [];
- };
- module.exports = IsSyncing;
- },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
- /*
- This file is part of web3.js.
- web3.js is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- web3.js is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with web3.js. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * @file transfer.js
- * @author Marek Kotewicz <[email protected]>
- * @date 2015
- */
- var Iban = require('./iban');
- var exchangeAbi = require('../contracts/SmartExchange.json');
- /**
- * Should be used to make Iban transfer
- *
- * @method transfer
- * @param {String} from
- * @param {String} to iban
- * @param {Value} value to be tranfered
- * @param {Function} callback, callback
- */
- var transfer = function (eth, from, to, value, callback) {
- var iban = new Iban(to);
- if (!iban.isValid()) {
- throw new Error('invalid iban address');
- }
- if (iban.isDirect()) {
- return transferToAddress(eth, from, iban.address(), value, callback);
- }
-
- if (!callback) {
- var address = eth.icapNamereg().addr(iban.institution());
- return deposit(eth, from, address, value, iban.client());
- }
- eth.icapNamereg().addr(iban.institution(), function (err, address) {
- return deposit(eth, from, address, value, iban.client(), callback);
- });
-
- };
- /**
- * Should be used to transfer funds to certain address
- *
- * @method transferToAddress
- * @param {String} from
- * @param {String} to
- * @param {Value} value to be tranfered
- * @param {Function} callback, callback
- */
- var transferToAddress = function (eth, from, to, value, callback) {
- return eth.sendTransaction({
- address: to,
- from: from,
- value: value
- }, callback);
- };
- /**
- * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
- *
- * @method deposit
- * @param {String} from
- * @param {String} to
- * @param {Value} value to be transfered
- * @param {String} client unique identifier
- * @param {Function} callback, callback
- */
- var deposit = function (eth, from, to, value, client, callback) {
- var abi = exchangeAbi;
- return eth.contract(abi).at(to).deposit(client, {
- from: from,
- value: value
- }, callback);
- };
- module.exports = transfer;
- },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
- },{}],51:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var BlockCipher = C_lib.BlockCipher;
- var C_algo = C.algo;
- // Lookup tables
- var SBOX = [];
- var INV_SBOX = [];
- var SUB_MIX_0 = [];
- var SUB_MIX_1 = [];
- var SUB_MIX_2 = [];
- var SUB_MIX_3 = [];
- var INV_SUB_MIX_0 = [];
- var INV_SUB_MIX_1 = [];
- var INV_SUB_MIX_2 = [];
- var INV_SUB_MIX_3 = [];
- // Compute lookup tables
- (function () {
- // Compute double table
- var d = [];
- for (var i = 0; i < 256; i++) {
- if (i < 128) {
- d[i] = i << 1;
- } else {
- d[i] = (i << 1) ^ 0x11b;
- }
- }
- // Walk GF(2^8)
- var x = 0;
- var xi = 0;
- for (var i = 0; i < 256; i++) {
- // Compute sbox
- var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
- sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
- SBOX[x] = sx;
- INV_SBOX[sx] = x;
- // Compute multiplication
- var x2 = d[x];
- var x4 = d[x2];
- var x8 = d[x4];
- // Compute sub bytes, mix columns tables
- var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
- SUB_MIX_0[x] = (t << 24) | (t >>> 8);
- SUB_MIX_1[x] = (t << 16) | (t >>> 16);
- SUB_MIX_2[x] = (t << 8) | (t >>> 24);
- SUB_MIX_3[x] = t;
- // Compute inv sub bytes, inv mix columns tables
- var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
- INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
- INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
- INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
- INV_SUB_MIX_3[sx] = t;
- // Compute next counter
- if (!x) {
- x = xi = 1;
- } else {
- x = x2 ^ d[d[d[x8 ^ x2]]];
- xi ^= d[d[xi]];
- }
- }
- }());
- // Precomputed Rcon lookup
- var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
- /**
- * AES block cipher algorithm.
- */
- var AES = C_algo.AES = BlockCipher.extend({
- _doReset: function () {
- // Skip reset of nRounds has been set before and key did not change
- if (this._nRounds && this._keyPriorReset === this._key) {
- return;
- }
- // Shortcuts
- var key = this._keyPriorReset = this._key;
- var keyWords = key.words;
- var keySize = key.sigBytes / 4;
- // Compute number of rounds
- var nRounds = this._nRounds = keySize + 6;
- // Compute number of key schedule rows
- var ksRows = (nRounds + 1) * 4;
- // Compute key schedule
- var keySchedule = this._keySchedule = [];
- for (var ksRow = 0; ksRow < ksRows; ksRow++) {
- if (ksRow < keySize) {
- keySchedule[ksRow] = keyWords[ksRow];
- } else {
- var t = keySchedule[ksRow - 1];
- if (!(ksRow % keySize)) {
- // Rot word
- t = (t << 8) | (t >>> 24);
- // Sub word
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
- // Mix Rcon
- t ^= RCON[(ksRow / keySize) | 0] << 24;
- } else if (keySize > 6 && ksRow % keySize == 4) {
- // Sub word
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
- }
- keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
- }
- }
- // Compute inv key schedule
- var invKeySchedule = this._invKeySchedule = [];
- for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
- var ksRow = ksRows - invKsRow;
- if (invKsRow % 4) {
- var t = keySchedule[ksRow];
- } else {
- var t = keySchedule[ksRow - 4];
- }
- if (invKsRow < 4 || ksRow <= 4) {
- invKeySchedule[invKsRow] = t;
- } else {
- invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
- INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
- }
- }
- },
- encryptBlock: function (M, offset) {
- this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
- },
- decryptBlock: function (M, offset) {
- // Swap 2nd and 4th rows
- var t = M[offset + 1];
- M[offset + 1] = M[offset + 3];
- M[offset + 3] = t;
- this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
- // Inv swap 2nd and 4th rows
- var t = M[offset + 1];
- M[offset + 1] = M[offset + 3];
- M[offset + 3] = t;
- },
- _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
- // Shortcut
- var nRounds = this._nRounds;
- // Get input, add round key
- var s0 = M[offset] ^ keySchedule[0];
- var s1 = M[offset + 1] ^ keySchedule[1];
- var s2 = M[offset + 2] ^ keySchedule[2];
- var s3 = M[offset + 3] ^ keySchedule[3];
- // Key schedule row counter
- var ksRow = 4;
- // Rounds
- for (var round = 1; round < nRounds; round++) {
- // Shift rows, sub bytes, mix columns, add round key
- 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++];
- 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++];
- 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++];
- 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++];
- // Update state
- s0 = t0;
- s1 = t1;
- s2 = t2;
- s3 = t3;
- }
- // Shift rows, sub bytes, add round key
- var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
- var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
- var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
- var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
- // Set output
- M[offset] = t0;
- M[offset + 1] = t1;
- M[offset + 2] = t2;
- M[offset + 3] = t3;
- },
- keySize: 256/32
- });
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
- */
- C.AES = BlockCipher._createHelper(AES);
- }());
- return CryptoJS.AES;
- }));
- },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Cipher core components.
- */
- CryptoJS.lib.Cipher || (function (undefined) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var WordArray = C_lib.WordArray;
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
- var C_enc = C.enc;
- var Utf8 = C_enc.Utf8;
- var Base64 = C_enc.Base64;
- var C_algo = C.algo;
- var EvpKDF = C_algo.EvpKDF;
- /**
- * Abstract base cipher template.
- *
- * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
- * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
- * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
- * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
- */
- var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
- /**
- * Configuration options.
- *
- * @property {WordArray} iv The IV to use for this operation.
- */
- cfg: Base.extend(),
- /**
- * Creates this cipher in encryption mode.
- *
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {Cipher} A cipher instance.
- *
- * @static
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
- */
- createEncryptor: function (key, cfg) {
- return this.create(this._ENC_XFORM_MODE, key, cfg);
- },
- /**
- * Creates this cipher in decryption mode.
- *
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {Cipher} A cipher instance.
- *
- * @static
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
- */
- createDecryptor: function (key, cfg) {
- return this.create(this._DEC_XFORM_MODE, key, cfg);
- },
- /**
- * Initializes a newly created cipher.
- *
- * @param {number} xformMode Either the encryption or decryption transormation mode constant.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @example
- *
- * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
- */
- init: function (xformMode, key, cfg) {
- // Apply config defaults
- this.cfg = this.cfg.extend(cfg);
- // Store transform mode and key
- this._xformMode = xformMode;
- this._key = key;
- // Set initial values
- this.reset();
- },
- /**
- * Resets this cipher to its initial state.
- *
- * @example
- *
- * cipher.reset();
- */
- reset: function () {
- // Reset data buffer
- BufferedBlockAlgorithm.reset.call(this);
- // Perform concrete-cipher logic
- this._doReset();
- },
- /**
- * Adds data to be encrypted or decrypted.
- *
- * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
- *
- * @return {WordArray} The data after processing.
- *
- * @example
- *
- * var encrypted = cipher.process('data');
- * var encrypted = cipher.process(wordArray);
- */
- process: function (dataUpdate) {
- // Append
- this._append(dataUpdate);
- // Process available blocks
- return this._process();
- },
- /**
- * Finalizes the encryption or decryption process.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
- *
- * @return {WordArray} The data after final processing.
- *
- * @example
- *
- * var encrypted = cipher.finalize();
- * var encrypted = cipher.finalize('data');
- * var encrypted = cipher.finalize(wordArray);
- */
- finalize: function (dataUpdate) {
- // Final data update
- if (dataUpdate) {
- this._append(dataUpdate);
- }
- // Perform concrete-cipher logic
- var finalProcessedData = this._doFinalize();
- return finalProcessedData;
- },
- keySize: 128/32,
- ivSize: 128/32,
- _ENC_XFORM_MODE: 1,
- _DEC_XFORM_MODE: 2,
- /**
- * Creates shortcut functions to a cipher's object interface.
- *
- * @param {Cipher} cipher The cipher to create a helper for.
- *
- * @return {Object} An object with encrypt and decrypt shortcut functions.
- *
- * @static
- *
- * @example
- *
- * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
- */
- _createHelper: (function () {
- function selectCipherStrategy(key) {
- if (typeof key == 'string') {
- return PasswordBasedCipher;
- } else {
- return SerializableCipher;
- }
- }
- return function (cipher) {
- return {
- encrypt: function (message, key, cfg) {
- return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
- },
- decrypt: function (ciphertext, key, cfg) {
- return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
- }
- };
- };
- }())
- });
- /**
- * Abstract base stream cipher template.
- *
- * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
- */
- var StreamCipher = C_lib.StreamCipher = Cipher.extend({
- _doFinalize: function () {
- // Process partial blocks
- var finalProcessedBlocks = this._process(!!'flush');
- return finalProcessedBlocks;
- },
- blockSize: 1
- });
- /**
- * Mode namespace.
- */
- var C_mode = C.mode = {};
- /**
- * Abstract base block cipher mode template.
- */
- var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
- /**
- * Creates this mode for encryption.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @static
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
- */
- createEncryptor: function (cipher, iv) {
- return this.Encryptor.create(cipher, iv);
- },
- /**
- * Creates this mode for decryption.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @static
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
- */
- createDecryptor: function (cipher, iv) {
- return this.Decryptor.create(cipher, iv);
- },
- /**
- * Initializes a newly created mode.
- *
- * @param {Cipher} cipher A block cipher instance.
- * @param {Array} iv The IV words.
- *
- * @example
- *
- * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
- */
- init: function (cipher, iv) {
- this._cipher = cipher;
- this._iv = iv;
- }
- });
- /**
- * Cipher Block Chaining mode.
- */
- var CBC = C_mode.CBC = (function () {
- /**
- * Abstract base CBC mode.
- */
- var CBC = BlockCipherMode.extend();
- /**
- * CBC encryptor.
- */
- CBC.Encryptor = CBC.extend({
- /**
- * Processes the data block at offset.
- *
- * @param {Array} words The data words to operate on.
- * @param {number} offset The offset where the block starts.
- *
- * @example
- *
- * mode.processBlock(data.words, offset);
- */
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- // XOR and encrypt
- xorBlock.call(this, words, offset, blockSize);
- cipher.encryptBlock(words, offset);
- // Remember this block to use with next block
- this._prevBlock = words.slice(offset, offset + blockSize);
- }
- });
- /**
- * CBC decryptor.
- */
- CBC.Decryptor = CBC.extend({
- /**
- * Processes the data block at offset.
- *
- * @param {Array} words The data words to operate on.
- * @param {number} offset The offset where the block starts.
- *
- * @example
- *
- * mode.processBlock(data.words, offset);
- */
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- // Remember this block to use with next block
- var thisBlock = words.slice(offset, offset + blockSize);
- // Decrypt and XOR
- cipher.decryptBlock(words, offset);
- xorBlock.call(this, words, offset, blockSize);
- // This block becomes the previous block
- this._prevBlock = thisBlock;
- }
- });
- function xorBlock(words, offset, blockSize) {
- // Shortcut
- var iv = this._iv;
- // Choose mixing block
- if (iv) {
- var block = iv;
- // Remove IV for subsequent blocks
- this._iv = undefined;
- } else {
- var block = this._prevBlock;
- }
- // XOR blocks
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= block[i];
- }
- }
- return CBC;
- }());
- /**
- * Padding namespace.
- */
- var C_pad = C.pad = {};
- /**
- * PKCS #5/7 padding strategy.
- */
- var Pkcs7 = C_pad.Pkcs7 = {
- /**
- * Pads data using the algorithm defined in PKCS #5/7.
- *
- * @param {WordArray} data The data to pad.
- * @param {number} blockSize The multiple that the data should be padded to.
- *
- * @static
- *
- * @example
- *
- * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
- */
- pad: function (data, blockSize) {
- // Shortcut
- var blockSizeBytes = blockSize * 4;
- // Count padding bytes
- var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
- // Create padding word
- var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
- // Create padding
- var paddingWords = [];
- for (var i = 0; i < nPaddingBytes; i += 4) {
- paddingWords.push(paddingWord);
- }
- var padding = WordArray.create(paddingWords, nPaddingBytes);
- // Add padding
- data.concat(padding);
- },
- /**
- * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
- *
- * @param {WordArray} data The data to unpad.
- *
- * @static
- *
- * @example
- *
- * CryptoJS.pad.Pkcs7.unpad(wordArray);
- */
- unpad: function (data) {
- // Get number of padding bytes from last byte
- var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
- // Remove padding
- data.sigBytes -= nPaddingBytes;
- }
- };
- /**
- * Abstract base block cipher template.
- *
- * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
- */
- var BlockCipher = C_lib.BlockCipher = Cipher.extend({
- /**
- * Configuration options.
- *
- * @property {Mode} mode The block mode to use. Default: CBC
- * @property {Padding} padding The padding strategy to use. Default: Pkcs7
- */
- cfg: Cipher.cfg.extend({
- mode: CBC,
- padding: Pkcs7
- }),
- reset: function () {
- // Reset cipher
- Cipher.reset.call(this);
- // Shortcuts
- var cfg = this.cfg;
- var iv = cfg.iv;
- var mode = cfg.mode;
- // Reset block mode
- if (this._xformMode == this._ENC_XFORM_MODE) {
- var modeCreator = mode.createEncryptor;
- } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
- var modeCreator = mode.createDecryptor;
- // Keep at least one block in the buffer for unpadding
- this._minBufferSize = 1;
- }
- this._mode = modeCreator.call(mode, this, iv && iv.words);
- },
- _doProcessBlock: function (words, offset) {
- this._mode.processBlock(words, offset);
- },
- _doFinalize: function () {
- // Shortcut
- var padding = this.cfg.padding;
- // Finalize
- if (this._xformMode == this._ENC_XFORM_MODE) {
- // Pad data
- padding.pad(this._data, this.blockSize);
- // Process final blocks
- var finalProcessedBlocks = this._process(!!'flush');
- } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
- // Process final blocks
- var finalProcessedBlocks = this._process(!!'flush');
- // Unpad data
- padding.unpad(finalProcessedBlocks);
- }
- return finalProcessedBlocks;
- },
- blockSize: 128/32
- });
- /**
- * A collection of cipher parameters.
- *
- * @property {WordArray} ciphertext The raw ciphertext.
- * @property {WordArray} key The key to this ciphertext.
- * @property {WordArray} iv The IV used in the ciphering operation.
- * @property {WordArray} salt The salt used with a key derivation function.
- * @property {Cipher} algorithm The cipher algorithm.
- * @property {Mode} mode The block mode used in the ciphering operation.
- * @property {Padding} padding The padding scheme used in the ciphering operation.
- * @property {number} blockSize The block size of the cipher.
- * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
- */
- var CipherParams = C_lib.CipherParams = Base.extend({
- /**
- * Initializes a newly created cipher params object.
- *
- * @param {Object} cipherParams An object with any of the possible cipher parameters.
- *
- * @example
- *
- * var cipherParams = CryptoJS.lib.CipherParams.create({
- * ciphertext: ciphertextWordArray,
- * key: keyWordArray,
- * iv: ivWordArray,
- * salt: saltWordArray,
- * algorithm: CryptoJS.algo.AES,
- * mode: CryptoJS.mode.CBC,
- * padding: CryptoJS.pad.PKCS7,
- * blockSize: 4,
- * formatter: CryptoJS.format.OpenSSL
- * });
- */
- init: function (cipherParams) {
- this.mixIn(cipherParams);
- },
- /**
- * Converts this cipher params object to a string.
- *
- * @param {Format} formatter (Optional) The formatting strategy to use.
- *
- * @return {string} The stringified cipher params.
- *
- * @throws Error If neither the formatter nor the default formatter is set.
- *
- * @example
- *
- * var string = cipherParams + '';
- * var string = cipherParams.toString();
- * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
- */
- toString: function (formatter) {
- return (formatter || this.formatter).stringify(this);
- }
- });
- /**
- * Format namespace.
- */
- var C_format = C.format = {};
- /**
- * OpenSSL formatting strategy.
- */
- var OpenSSLFormatter = C_format.OpenSSL = {
- /**
- * Converts a cipher params object to an OpenSSL-compatible string.
- *
- * @param {CipherParams} cipherParams The cipher params object.
- *
- * @return {string} The OpenSSL-compatible string.
- *
- * @static
- *
- * @example
- *
- * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
- */
- stringify: function (cipherParams) {
- // Shortcuts
- var ciphertext = cipherParams.ciphertext;
- var salt = cipherParams.salt;
- // Format
- if (salt) {
- var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
- } else {
- var wordArray = ciphertext;
- }
- return wordArray.toString(Base64);
- },
- /**
- * Converts an OpenSSL-compatible string to a cipher params object.
- *
- * @param {string} openSSLStr The OpenSSL-compatible string.
- *
- * @return {CipherParams} The cipher params object.
- *
- * @static
- *
- * @example
- *
- * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
- */
- parse: function (openSSLStr) {
- // Parse base64
- var ciphertext = Base64.parse(openSSLStr);
- // Shortcut
- var ciphertextWords = ciphertext.words;
- // Test for salt
- if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
- // Extract salt
- var salt = WordArray.create(ciphertextWords.slice(2, 4));
- // Remove salt from ciphertext
- ciphertextWords.splice(0, 4);
- ciphertext.sigBytes -= 16;
- }
- return CipherParams.create({ ciphertext: ciphertext, salt: salt });
- }
- };
- /**
- * A cipher wrapper that returns ciphertext as a serializable cipher params object.
- */
- var SerializableCipher = C_lib.SerializableCipher = Base.extend({
- /**
- * Configuration options.
- *
- * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
- */
- cfg: Base.extend({
- format: OpenSSLFormatter
- }),
- /**
- * Encrypts a message.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {WordArray|string} message The message to encrypt.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {CipherParams} A cipher params object.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
- * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- */
- encrypt: function (cipher, message, key, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Encrypt
- var encryptor = cipher.createEncryptor(key, cfg);
- var ciphertext = encryptor.finalize(message);
- // Shortcut
- var cipherCfg = encryptor.cfg;
- // Create and return serializable cipher params
- return CipherParams.create({
- ciphertext: ciphertext,
- key: key,
- iv: cipherCfg.iv,
- algorithm: cipher,
- mode: cipherCfg.mode,
- padding: cipherCfg.padding,
- blockSize: cipher.blockSize,
- formatter: cfg.format
- });
- },
- /**
- * Decrypts serialized ciphertext.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
- * @param {WordArray} key The key.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {WordArray} The plaintext.
- *
- * @static
- *
- * @example
- *
- * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
- */
- decrypt: function (cipher, ciphertext, key, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Convert string to CipherParams
- ciphertext = this._parse(ciphertext, cfg.format);
- // Decrypt
- var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
- return plaintext;
- },
- /**
- * Converts serialized ciphertext to CipherParams,
- * else assumed CipherParams already and returns ciphertext unchanged.
- *
- * @param {CipherParams|string} ciphertext The ciphertext.
- * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
- *
- * @return {CipherParams} The unserialized ciphertext.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
- */
- _parse: function (ciphertext, format) {
- if (typeof ciphertext == 'string') {
- return format.parse(ciphertext, this);
- } else {
- return ciphertext;
- }
- }
- });
- /**
- * Key derivation function namespace.
- */
- var C_kdf = C.kdf = {};
- /**
- * OpenSSL key derivation function.
- */
- var OpenSSLKdf = C_kdf.OpenSSL = {
- /**
- * Derives a key and IV from a password.
- *
- * @param {string} password The password to derive from.
- * @param {number} keySize The size in words of the key to generate.
- * @param {number} ivSize The size in words of the IV to generate.
- * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
- *
- * @return {CipherParams} A cipher params object with the key, IV, and salt.
- *
- * @static
- *
- * @example
- *
- * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
- * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
- */
- execute: function (password, keySize, ivSize, salt) {
- // Generate random salt
- if (!salt) {
- salt = WordArray.random(64/8);
- }
- // Derive key and IV
- var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
- // Separate key and IV
- var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
- key.sigBytes = keySize * 4;
- // Return params
- return CipherParams.create({ key: key, iv: iv, salt: salt });
- }
- };
- /**
- * A serializable cipher wrapper that derives the key from a password,
- * and returns ciphertext as a serializable cipher params object.
- */
- var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
- /**
- * Configuration options.
- *
- * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
- */
- cfg: SerializableCipher.cfg.extend({
- kdf: OpenSSLKdf
- }),
- /**
- * Encrypts a message using a password.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {WordArray|string} message The message to encrypt.
- * @param {string} password The password.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {CipherParams} A cipher params object.
- *
- * @static
- *
- * @example
- *
- * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
- * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
- */
- encrypt: function (cipher, message, password, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Derive key and other params
- var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
- // Add IV to config
- cfg.iv = derivedParams.iv;
- // Encrypt
- var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
- // Mix in derived params
- ciphertext.mixIn(derivedParams);
- return ciphertext;
- },
- /**
- * Decrypts serialized ciphertext using a password.
- *
- * @param {Cipher} cipher The cipher algorithm to use.
- * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
- * @param {string} password The password.
- * @param {Object} cfg (Optional) The configuration options to use for this operation.
- *
- * @return {WordArray} The plaintext.
- *
- * @static
- *
- * @example
- *
- * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
- * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
- */
- decrypt: function (cipher, ciphertext, password, cfg) {
- // Apply config defaults
- cfg = this.cfg.extend(cfg);
- // Convert string to CipherParams
- ciphertext = this._parse(ciphertext, cfg.format);
- // Derive key and other params
- var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
- // Add IV to config
- cfg.iv = derivedParams.iv;
- // Decrypt
- var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
- return plaintext;
- }
- });
- }());
- }));
- },{"./core":53}],53:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory();
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define([], factory);
- }
- else {
- // Global (browser)
- root.CryptoJS = factory();
- }
- }(this, function () {
- /**
- * CryptoJS core components.
- */
- var CryptoJS = CryptoJS || (function (Math, undefined) {
- /*
- * Local polyfil of Object.create
- */
- var create = Object.create || (function () {
- function F() {};
- return function (obj) {
- var subtype;
- F.prototype = obj;
- subtype = new F();
- F.prototype = null;
- return subtype;
- };
- }())
- /**
- * CryptoJS namespace.
- */
- var C = {};
- /**
- * Library namespace.
- */
- var C_lib = C.lib = {};
- /**
- * Base object for prototypal inheritance.
- */
- var Base = C_lib.Base = (function () {
- return {
- /**
- * Creates a new object that inherits from this object.
- *
- * @param {Object} overrides Properties to copy into the new object.
- *
- * @return {Object} The new object.
- *
- * @static
- *
- * @example
- *
- * var MyType = CryptoJS.lib.Base.extend({
- * field: 'value',
- *
- * method: function () {
- * }
- * });
- */
- extend: function (overrides) {
- // Spawn
- var subtype = create(this);
- // Augment
- if (overrides) {
- subtype.mixIn(overrides);
- }
- // Create default initializer
- if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
- subtype.init = function () {
- subtype.$super.init.apply(this, arguments);
- };
- }
- // Initializer's prototype is the subtype object
- subtype.init.prototype = subtype;
- // Reference supertype
- subtype.$super = this;
- return subtype;
- },
- /**
- * Extends this object and runs the init method.
- * Arguments to create() will be passed to init().
- *
- * @return {Object} The new object.
- *
- * @static
- *
- * @example
- *
- * var instance = MyType.create();
- */
- create: function () {
- var instance = this.extend();
- instance.init.apply(instance, arguments);
- return instance;
- },
- /**
- * Initializes a newly created object.
- * Override this method to add some logic when your objects are created.
- *
- * @example
- *
- * var MyType = CryptoJS.lib.Base.extend({
- * init: function () {
- * // ...
- * }
- * });
- */
- init: function () {
- },
- /**
- * Copies properties into this object.
- *
- * @param {Object} properties The properties to mix in.
- *
- * @example
- *
- * MyType.mixIn({
- * field: 'value'
- * });
- */
- mixIn: function (properties) {
- for (var propertyName in properties) {
- if (properties.hasOwnProperty(propertyName)) {
- this[propertyName] = properties[propertyName];
- }
- }
- // IE won't copy toString using the loop above
- if (properties.hasOwnProperty('toString')) {
- this.toString = properties.toString;
- }
- },
- /**
- * Creates a copy of this object.
- *
- * @return {Object} The clone.
- *
- * @example
- *
- * var clone = instance.clone();
- */
- clone: function () {
- return this.init.prototype.extend(this);
- }
- };
- }());
- /**
- * An array of 32-bit words.
- *
- * @property {Array} words The array of 32-bit words.
- * @property {number} sigBytes The number of significant bytes in this word array.
- */
- var WordArray = C_lib.WordArray = Base.extend({
- /**
- * Initializes a newly created word array.
- *
- * @param {Array} words (Optional) An array of 32-bit words.
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
- *
- * @example
- *
- * var wordArray = CryptoJS.lib.WordArray.create();
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
- */
- init: function (words, sigBytes) {
- words = this.words = words || [];
- if (sigBytes != undefined) {
- this.sigBytes = sigBytes;
- } else {
- this.sigBytes = words.length * 4;
- }
- },
- /**
- * Converts this word array to a string.
- *
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
- *
- * @return {string} The stringified word array.
- *
- * @example
- *
- * var string = wordArray + '';
- * var string = wordArray.toString();
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
- */
- toString: function (encoder) {
- return (encoder || Hex).stringify(this);
- },
- /**
- * Concatenates a word array to this word array.
- *
- * @param {WordArray} wordArray The word array to append.
- *
- * @return {WordArray} This word array.
- *
- * @example
- *
- * wordArray1.concat(wordArray2);
- */
- concat: function (wordArray) {
- // Shortcuts
- var thisWords = this.words;
- var thatWords = wordArray.words;
- var thisSigBytes = this.sigBytes;
- var thatSigBytes = wordArray.sigBytes;
- // Clamp excess bits
- this.clamp();
- // Concat
- if (thisSigBytes % 4) {
- // Copy one byte at a time
- for (var i = 0; i < thatSigBytes; i++) {
- var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
- }
- } else {
- // Copy one word at a time
- for (var i = 0; i < thatSigBytes; i += 4) {
- thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
- }
- }
- this.sigBytes += thatSigBytes;
- // Chainable
- return this;
- },
- /**
- * Removes insignificant bits.
- *
- * @example
- *
- * wordArray.clamp();
- */
- clamp: function () {
- // Shortcuts
- var words = this.words;
- var sigBytes = this.sigBytes;
- // Clamp
- words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
- words.length = Math.ceil(sigBytes / 4);
- },
- /**
- * Creates a copy of this word array.
- *
- * @return {WordArray} The clone.
- *
- * @example
- *
- * var clone = wordArray.clone();
- */
- clone: function () {
- var clone = Base.clone.call(this);
- clone.words = this.words.slice(0);
- return clone;
- },
- /**
- * Creates a word array filled with random bytes.
- *
- * @param {number} nBytes The number of random bytes to generate.
- *
- * @return {WordArray} The random word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.lib.WordArray.random(16);
- */
- random: function (nBytes) {
- var words = [];
- var r = (function (m_w) {
- var m_w = m_w;
- var m_z = 0x3ade68b1;
- var mask = 0xffffffff;
- return function () {
- m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
- m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
- var result = ((m_z << 0x10) + m_w) & mask;
- result /= 0x100000000;
- result += 0.5;
- return result * (Math.random() > .5 ? 1 : -1);
- }
- });
- for (var i = 0, rcache; i < nBytes; i += 4) {
- var _r = r((rcache || Math.random()) * 0x100000000);
- rcache = _r() * 0x3ade67b7;
- words.push((_r() * 0x100000000) | 0);
- }
- return new WordArray.init(words, nBytes);
- }
- });
- /**
- * Encoder namespace.
- */
- var C_enc = C.enc = {};
- /**
- * Hex encoding strategy.
- */
- var Hex = C_enc.Hex = {
- /**
- * Converts a word array to a hex string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The hex string.
- *
- * @static
- *
- * @example
- *
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var hexChars = [];
- for (var i = 0; i < sigBytes; i++) {
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- hexChars.push((bite >>> 4).toString(16));
- hexChars.push((bite & 0x0f).toString(16));
- }
- return hexChars.join('');
- },
- /**
- * Converts a hex string to a word array.
- *
- * @param {string} hexStr The hex string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
- */
- parse: function (hexStr) {
- // Shortcut
- var hexStrLength = hexStr.length;
- // Convert
- var words = [];
- for (var i = 0; i < hexStrLength; i += 2) {
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
- }
- return new WordArray.init(words, hexStrLength / 2);
- }
- };
- /**
- * Latin1 encoding strategy.
- */
- var Latin1 = C_enc.Latin1 = {
- /**
- * Converts a word array to a Latin1 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The Latin1 string.
- *
- * @static
- *
- * @example
- *
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var latin1Chars = [];
- for (var i = 0; i < sigBytes; i++) {
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- latin1Chars.push(String.fromCharCode(bite));
- }
- return latin1Chars.join('');
- },
- /**
- * Converts a Latin1 string to a word array.
- *
- * @param {string} latin1Str The Latin1 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
- */
- parse: function (latin1Str) {
- // Shortcut
- var latin1StrLength = latin1Str.length;
- // Convert
- var words = [];
- for (var i = 0; i < latin1StrLength; i++) {
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
- }
- return new WordArray.init(words, latin1StrLength);
- }
- };
- /**
- * UTF-8 encoding strategy.
- */
- var Utf8 = C_enc.Utf8 = {
- /**
- * Converts a word array to a UTF-8 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The UTF-8 string.
- *
- * @static
- *
- * @example
- *
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
- */
- stringify: function (wordArray) {
- try {
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
- } catch (e) {
- throw new Error('Malformed UTF-8 data');
- }
- },
- /**
- * Converts a UTF-8 string to a word array.
- *
- * @param {string} utf8Str The UTF-8 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
- */
- parse: function (utf8Str) {
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
- }
- };
- /**
- * Abstract buffered block algorithm template.
- *
- * The property blockSize must be implemented in a concrete subtype.
- *
- * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
- */
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
- /**
- * Resets this block algorithm's data buffer to its initial state.
- *
- * @example
- *
- * bufferedBlockAlgorithm.reset();
- */
- reset: function () {
- // Initial values
- this._data = new WordArray.init();
- this._nDataBytes = 0;
- },
- /**
- * Adds new data to this block algorithm's buffer.
- *
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
- *
- * @example
- *
- * bufferedBlockAlgorithm._append('data');
- * bufferedBlockAlgorithm._append(wordArray);
- */
- _append: function (data) {
- // Convert string to WordArray, else assume WordArray already
- if (typeof data == 'string') {
- data = Utf8.parse(data);
- }
- // Append
- this._data.concat(data);
- this._nDataBytes += data.sigBytes;
- },
- /**
- * Processes available data blocks.
- *
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
- *
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
- *
- * @return {WordArray} The processed data.
- *
- * @example
- *
- * var processedData = bufferedBlockAlgorithm._process();
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
- */
- _process: function (doFlush) {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var dataSigBytes = data.sigBytes;
- var blockSize = this.blockSize;
- var blockSizeBytes = blockSize * 4;
- // Count blocks ready
- var nBlocksReady = dataSigBytes / blockSizeBytes;
- if (doFlush) {
- // Round up to include partial blocks
- nBlocksReady = Math.ceil(nBlocksReady);
- } else {
- // Round down to include only full blocks,
- // less the number of blocks that must remain in the buffer
- nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
- }
- // Count words ready
- var nWordsReady = nBlocksReady * blockSize;
- // Count bytes ready
- var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
- // Process blocks
- if (nWordsReady) {
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
- // Perform concrete-algorithm logic
- this._doProcessBlock(dataWords, offset);
- }
- // Remove processed words
- var processedWords = dataWords.splice(0, nWordsReady);
- data.sigBytes -= nBytesReady;
- }
- // Return processed words
- return new WordArray.init(processedWords, nBytesReady);
- },
- /**
- * Creates a copy of this object.
- *
- * @return {Object} The clone.
- *
- * @example
- *
- * var clone = bufferedBlockAlgorithm.clone();
- */
- clone: function () {
- var clone = Base.clone.call(this);
- clone._data = this._data.clone();
- return clone;
- },
- _minBufferSize: 0
- });
- /**
- * Abstract hasher template.
- *
- * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
- */
- var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
- /**
- * Configuration options.
- */
- cfg: Base.extend(),
- /**
- * Initializes a newly created hasher.
- *
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
- *
- * @example
- *
- * var hasher = CryptoJS.algo.SHA256.create();
- */
- init: function (cfg) {
- // Apply config defaults
- this.cfg = this.cfg.extend(cfg);
- // Set initial values
- this.reset();
- },
- /**
- * Resets this hasher to its initial state.
- *
- * @example
- *
- * hasher.reset();
- */
- reset: function () {
- // Reset data buffer
- BufferedBlockAlgorithm.reset.call(this);
- // Perform concrete-hasher logic
- this._doReset();
- },
- /**
- * Updates this hasher with a message.
- *
- * @param {WordArray|string} messageUpdate The message to append.
- *
- * @return {Hasher} This hasher.
- *
- * @example
- *
- * hasher.update('message');
- * hasher.update(wordArray);
- */
- update: function (messageUpdate) {
- // Append
- this._append(messageUpdate);
- // Update the hash
- this._process();
- // Chainable
- return this;
- },
- /**
- * Finalizes the hash computation.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
- *
- * @return {WordArray} The hash.
- *
- * @example
- *
- * var hash = hasher.finalize();
- * var hash = hasher.finalize('message');
- * var hash = hasher.finalize(wordArray);
- */
- finalize: function (messageUpdate) {
- // Final message update
- if (messageUpdate) {
- this._append(messageUpdate);
- }
- // Perform concrete-hasher logic
- var hash = this._doFinalize();
- return hash;
- },
- blockSize: 512/32,
- /**
- * Creates a shortcut function to a hasher's object interface.
- *
- * @param {Hasher} hasher The hasher to create a helper for.
- *
- * @return {Function} The shortcut function.
- *
- * @static
- *
- * @example
- *
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
- */
- _createHelper: function (hasher) {
- return function (message, cfg) {
- return new hasher.init(cfg).finalize(message);
- };
- },
- /**
- * Creates a shortcut function to the HMAC's object interface.
- *
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
- *
- * @return {Function} The shortcut function.
- *
- * @static
- *
- * @example
- *
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
- */
- _createHmacHelper: function (hasher) {
- return function (message, key) {
- return new C_algo.HMAC.init(hasher, key).finalize(message);
- };
- }
- });
- /**
- * Algorithm namespace.
- */
- var C_algo = C.algo = {};
- return C;
- }(Math));
- return CryptoJS;
- }));
- },{}],54:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var C_enc = C.enc;
- /**
- * Base64 encoding strategy.
- */
- var Base64 = C_enc.Base64 = {
- /**
- * Converts a word array to a Base64 string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The Base64 string.
- *
- * @static
- *
- * @example
- *
- * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- var map = this._map;
- // Clamp excess bits
- wordArray.clamp();
- // Convert
- var base64Chars = [];
- for (var i = 0; i < sigBytes; i += 3) {
- var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
- var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
- var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
- var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
- for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
- base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
- }
- }
- // Add padding
- var paddingChar = map.charAt(64);
- if (paddingChar) {
- while (base64Chars.length % 4) {
- base64Chars.push(paddingChar);
- }
- }
- return base64Chars.join('');
- },
- /**
- * Converts a Base64 string to a word array.
- *
- * @param {string} base64Str The Base64 string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Base64.parse(base64String);
- */
- parse: function (base64Str) {
- // Shortcuts
- var base64StrLength = base64Str.length;
- var map = this._map;
- var reverseMap = this._reverseMap;
- if (!reverseMap) {
- reverseMap = this._reverseMap = [];
- for (var j = 0; j < map.length; j++) {
- reverseMap[map.charCodeAt(j)] = j;
- }
- }
- // Ignore padding
- var paddingChar = map.charAt(64);
- if (paddingChar) {
- var paddingIndex = base64Str.indexOf(paddingChar);
- if (paddingIndex !== -1) {
- base64StrLength = paddingIndex;
- }
- }
- // Convert
- return parseLoop(base64Str, base64StrLength, reverseMap);
- },
- _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
- };
- function parseLoop(base64Str, base64StrLength, reverseMap) {
- var words = [];
- var nBytes = 0;
- for (var i = 0; i < base64StrLength; i++) {
- if (i % 4) {
- var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
- var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
- words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
- nBytes++;
- }
- }
- return WordArray.create(words, nBytes);
- }
- }());
- return CryptoJS.enc.Base64;
- }));
- },{"./core":53}],55:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var C_enc = C.enc;
- /**
- * UTF-16 BE encoding strategy.
- */
- var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
- /**
- * Converts a word array to a UTF-16 BE string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The UTF-16 BE string.
- *
- * @static
- *
- * @example
- *
- * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var utf16Chars = [];
- for (var i = 0; i < sigBytes; i += 2) {
- var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
- utf16Chars.push(String.fromCharCode(codePoint));
- }
- return utf16Chars.join('');
- },
- /**
- * Converts a UTF-16 BE string to a word array.
- *
- * @param {string} utf16Str The UTF-16 BE string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
- */
- parse: function (utf16Str) {
- // Shortcut
- var utf16StrLength = utf16Str.length;
- // Convert
- var words = [];
- for (var i = 0; i < utf16StrLength; i++) {
- words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
- }
- return WordArray.create(words, utf16StrLength * 2);
- }
- };
- /**
- * UTF-16 LE encoding strategy.
- */
- C_enc.Utf16LE = {
- /**
- * Converts a word array to a UTF-16 LE string.
- *
- * @param {WordArray} wordArray The word array.
- *
- * @return {string} The UTF-16 LE string.
- *
- * @static
- *
- * @example
- *
- * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
- */
- stringify: function (wordArray) {
- // Shortcuts
- var words = wordArray.words;
- var sigBytes = wordArray.sigBytes;
- // Convert
- var utf16Chars = [];
- for (var i = 0; i < sigBytes; i += 2) {
- var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
- utf16Chars.push(String.fromCharCode(codePoint));
- }
- return utf16Chars.join('');
- },
- /**
- * Converts a UTF-16 LE string to a word array.
- *
- * @param {string} utf16Str The UTF-16 LE string.
- *
- * @return {WordArray} The word array.
- *
- * @static
- *
- * @example
- *
- * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
- */
- parse: function (utf16Str) {
- // Shortcut
- var utf16StrLength = utf16Str.length;
- // Convert
- var words = [];
- for (var i = 0; i < utf16StrLength; i++) {
- words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
- }
- return WordArray.create(words, utf16StrLength * 2);
- }
- };
- function swapEndian(word) {
- return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
- }
- }());
- return CryptoJS.enc.Utf16;
- }));
- },{"./core":53}],56:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./sha1", "./hmac"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var WordArray = C_lib.WordArray;
- var C_algo = C.algo;
- var MD5 = C_algo.MD5;
- /**
- * This key derivation function is meant to conform with EVP_BytesToKey.
- * www.openssl.org/docs/crypto/EVP_BytesToKey.html
- */
- var EvpKDF = C_algo.EvpKDF = Base.extend({
- /**
- * Configuration options.
- *
- * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
- * @property {Hasher} hasher The hash algorithm to use. Default: MD5
- * @property {number} iterations The number of iterations to perform. Default: 1
- */
- cfg: Base.extend({
- keySize: 128/32,
- hasher: MD5,
- iterations: 1
- }),
- /**
- * Initializes a newly created key derivation function.
- *
- * @param {Object} cfg (Optional) The configuration options to use for the derivation.
- *
- * @example
- *
- * var kdf = CryptoJS.algo.EvpKDF.create();
- * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
- * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
- */
- init: function (cfg) {
- this.cfg = this.cfg.extend(cfg);
- },
- /**
- * Derives a key from a password.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- *
- * @return {WordArray} The derived key.
- *
- * @example
- *
- * var key = kdf.compute(password, salt);
- */
- compute: function (password, salt) {
- // Shortcut
- var cfg = this.cfg;
- // Init hasher
- var hasher = cfg.hasher.create();
- // Initial values
- var derivedKey = WordArray.create();
- // Shortcuts
- var derivedKeyWords = derivedKey.words;
- var keySize = cfg.keySize;
- var iterations = cfg.iterations;
- // Generate key
- while (derivedKeyWords.length < keySize) {
- if (block) {
- hasher.update(block);
- }
- var block = hasher.update(password).finalize(salt);
- hasher.reset();
- // Iterations
- for (var i = 1; i < iterations; i++) {
- block = hasher.finalize(block);
- hasher.reset();
- }
- derivedKey.concat(block);
- }
- derivedKey.sigBytes = keySize * 4;
- return derivedKey;
- }
- });
- /**
- * Derives a key from a password.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- * @param {Object} cfg (Optional) The configuration options to use for this computation.
- *
- * @return {WordArray} The derived key.
- *
- * @static
- *
- * @example
- *
- * var key = CryptoJS.EvpKDF(password, salt);
- * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
- * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
- */
- C.EvpKDF = function (password, salt, cfg) {
- return EvpKDF.create(cfg).compute(password, salt);
- };
- }());
- return CryptoJS.EvpKDF;
- }));
- },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (undefined) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var CipherParams = C_lib.CipherParams;
- var C_enc = C.enc;
- var Hex = C_enc.Hex;
- var C_format = C.format;
- var HexFormatter = C_format.Hex = {
- /**
- * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
- *
- * @param {CipherParams} cipherParams The cipher params object.
- *
- * @return {string} The hexadecimally encoded string.
- *
- * @static
- *
- * @example
- *
- * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
- */
- stringify: function (cipherParams) {
- return cipherParams.ciphertext.toString(Hex);
- },
- /**
- * Converts a hexadecimally encoded ciphertext string to a cipher params object.
- *
- * @param {string} input The hexadecimally encoded string.
- *
- * @return {CipherParams} The cipher params object.
- *
- * @static
- *
- * @example
- *
- * var cipherParams = CryptoJS.format.Hex.parse(hexString);
- */
- parse: function (input) {
- var ciphertext = Hex.parse(input);
- return CipherParams.create({ ciphertext: ciphertext });
- }
- };
- }());
- return CryptoJS.format.Hex;
- }));
- },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var C_enc = C.enc;
- var Utf8 = C_enc.Utf8;
- var C_algo = C.algo;
- /**
- * HMAC algorithm.
- */
- var HMAC = C_algo.HMAC = Base.extend({
- /**
- * Initializes a newly created HMAC.
- *
- * @param {Hasher} hasher The hash algorithm to use.
- * @param {WordArray|string} key The secret key.
- *
- * @example
- *
- * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
- */
- init: function (hasher, key) {
- // Init hasher
- hasher = this._hasher = new hasher.init();
- // Convert string to WordArray, else assume WordArray already
- if (typeof key == 'string') {
- key = Utf8.parse(key);
- }
- // Shortcuts
- var hasherBlockSize = hasher.blockSize;
- var hasherBlockSizeBytes = hasherBlockSize * 4;
- // Allow arbitrary length keys
- if (key.sigBytes > hasherBlockSizeBytes) {
- key = hasher.finalize(key);
- }
- // Clamp excess bits
- key.clamp();
- // Clone key for inner and outer pads
- var oKey = this._oKey = key.clone();
- var iKey = this._iKey = key.clone();
- // Shortcuts
- var oKeyWords = oKey.words;
- var iKeyWords = iKey.words;
- // XOR keys with pad constants
- for (var i = 0; i < hasherBlockSize; i++) {
- oKeyWords[i] ^= 0x5c5c5c5c;
- iKeyWords[i] ^= 0x36363636;
- }
- oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
- // Set initial values
- this.reset();
- },
- /**
- * Resets this HMAC to its initial state.
- *
- * @example
- *
- * hmacHasher.reset();
- */
- reset: function () {
- // Shortcut
- var hasher = this._hasher;
- // Reset
- hasher.reset();
- hasher.update(this._iKey);
- },
- /**
- * Updates this HMAC with a message.
- *
- * @param {WordArray|string} messageUpdate The message to append.
- *
- * @return {HMAC} This HMAC instance.
- *
- * @example
- *
- * hmacHasher.update('message');
- * hmacHasher.update(wordArray);
- */
- update: function (messageUpdate) {
- this._hasher.update(messageUpdate);
- // Chainable
- return this;
- },
- /**
- * Finalizes the HMAC computation.
- * Note that the finalize operation is effectively a destructive, read-once operation.
- *
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
- *
- * @return {WordArray} The HMAC.
- *
- * @example
- *
- * var hmac = hmacHasher.finalize();
- * var hmac = hmacHasher.finalize('message');
- * var hmac = hmacHasher.finalize(wordArray);
- */
- finalize: function (messageUpdate) {
- // Shortcut
- var hasher = this._hasher;
- // Compute HMAC
- var innerHash = hasher.finalize(messageUpdate);
- hasher.reset();
- var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
- return hmac;
- }
- });
- }());
- }));
- },{"./core":53}],59:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- 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"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- 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);
- }
- else {
- // Global (browser)
- root.CryptoJS = factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- return CryptoJS;
- }));
- },{"./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){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Check if typed arrays are supported
- if (typeof ArrayBuffer != 'function') {
- return;
- }
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- // Reference original init
- var superInit = WordArray.init;
- // Augment WordArray.init to handle typed arrays
- var subInit = WordArray.init = function (typedArray) {
- // Convert buffers to uint8
- if (typedArray instanceof ArrayBuffer) {
- typedArray = new Uint8Array(typedArray);
- }
- // Convert other array views to uint8
- if (
- typedArray instanceof Int8Array ||
- (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
- typedArray instanceof Int16Array ||
- typedArray instanceof Uint16Array ||
- typedArray instanceof Int32Array ||
- typedArray instanceof Uint32Array ||
- typedArray instanceof Float32Array ||
- typedArray instanceof Float64Array
- ) {
- typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
- }
- // Handle Uint8Array
- if (typedArray instanceof Uint8Array) {
- // Shortcut
- var typedArrayByteLength = typedArray.byteLength;
- // Extract bytes
- var words = [];
- for (var i = 0; i < typedArrayByteLength; i++) {
- words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
- }
- // Initialize this word array
- superInit.call(this, words, typedArrayByteLength);
- } else {
- // Else call normal init
- superInit.apply(this, arguments);
- }
- };
- subInit.prototype = WordArray;
- }());
- return CryptoJS.lib.WordArray;
- }));
- },{"./core":53}],61:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (Math) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Constants table
- var T = [];
- // Compute constants
- (function () {
- for (var i = 0; i < 64; i++) {
- T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
- }
- }());
- /**
- * MD5 hash algorithm.
- */
- var MD5 = C_algo.MD5 = Hasher.extend({
- _doReset: function () {
- this._hash = new WordArray.init([
- 0x67452301, 0xefcdab89,
- 0x98badcfe, 0x10325476
- ]);
- },
- _doProcessBlock: function (M, offset) {
- // Swap endian
- for (var i = 0; i < 16; i++) {
- // Shortcuts
- var offset_i = offset + i;
- var M_offset_i = M[offset_i];
- M[offset_i] = (
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
- );
- }
- // Shortcuts
- var H = this._hash.words;
- var M_offset_0 = M[offset + 0];
- var M_offset_1 = M[offset + 1];
- var M_offset_2 = M[offset + 2];
- var M_offset_3 = M[offset + 3];
- var M_offset_4 = M[offset + 4];
- var M_offset_5 = M[offset + 5];
- var M_offset_6 = M[offset + 6];
- var M_offset_7 = M[offset + 7];
- var M_offset_8 = M[offset + 8];
- var M_offset_9 = M[offset + 9];
- var M_offset_10 = M[offset + 10];
- var M_offset_11 = M[offset + 11];
- var M_offset_12 = M[offset + 12];
- var M_offset_13 = M[offset + 13];
- var M_offset_14 = M[offset + 14];
- var M_offset_15 = M[offset + 15];
- // Working varialbes
- var a = H[0];
- var b = H[1];
- var c = H[2];
- var d = H[3];
- // Computation
- a = FF(a, b, c, d, M_offset_0, 7, T[0]);
- d = FF(d, a, b, c, M_offset_1, 12, T[1]);
- c = FF(c, d, a, b, M_offset_2, 17, T[2]);
- b = FF(b, c, d, a, M_offset_3, 22, T[3]);
- a = FF(a, b, c, d, M_offset_4, 7, T[4]);
- d = FF(d, a, b, c, M_offset_5, 12, T[5]);
- c = FF(c, d, a, b, M_offset_6, 17, T[6]);
- b = FF(b, c, d, a, M_offset_7, 22, T[7]);
- a = FF(a, b, c, d, M_offset_8, 7, T[8]);
- d = FF(d, a, b, c, M_offset_9, 12, T[9]);
- c = FF(c, d, a, b, M_offset_10, 17, T[10]);
- b = FF(b, c, d, a, M_offset_11, 22, T[11]);
- a = FF(a, b, c, d, M_offset_12, 7, T[12]);
- d = FF(d, a, b, c, M_offset_13, 12, T[13]);
- c = FF(c, d, a, b, M_offset_14, 17, T[14]);
- b = FF(b, c, d, a, M_offset_15, 22, T[15]);
- a = GG(a, b, c, d, M_offset_1, 5, T[16]);
- d = GG(d, a, b, c, M_offset_6, 9, T[17]);
- c = GG(c, d, a, b, M_offset_11, 14, T[18]);
- b = GG(b, c, d, a, M_offset_0, 20, T[19]);
- a = GG(a, b, c, d, M_offset_5, 5, T[20]);
- d = GG(d, a, b, c, M_offset_10, 9, T[21]);
- c = GG(c, d, a, b, M_offset_15, 14, T[22]);
- b = GG(b, c, d, a, M_offset_4, 20, T[23]);
- a = GG(a, b, c, d, M_offset_9, 5, T[24]);
- d = GG(d, a, b, c, M_offset_14, 9, T[25]);
- c = GG(c, d, a, b, M_offset_3, 14, T[26]);
- b = GG(b, c, d, a, M_offset_8, 20, T[27]);
- a = GG(a, b, c, d, M_offset_13, 5, T[28]);
- d = GG(d, a, b, c, M_offset_2, 9, T[29]);
- c = GG(c, d, a, b, M_offset_7, 14, T[30]);
- b = GG(b, c, d, a, M_offset_12, 20, T[31]);
- a = HH(a, b, c, d, M_offset_5, 4, T[32]);
- d = HH(d, a, b, c, M_offset_8, 11, T[33]);
- c = HH(c, d, a, b, M_offset_11, 16, T[34]);
- b = HH(b, c, d, a, M_offset_14, 23, T[35]);
- a = HH(a, b, c, d, M_offset_1, 4, T[36]);
- d = HH(d, a, b, c, M_offset_4, 11, T[37]);
- c = HH(c, d, a, b, M_offset_7, 16, T[38]);
- b = HH(b, c, d, a, M_offset_10, 23, T[39]);
- a = HH(a, b, c, d, M_offset_13, 4, T[40]);
- d = HH(d, a, b, c, M_offset_0, 11, T[41]);
- c = HH(c, d, a, b, M_offset_3, 16, T[42]);
- b = HH(b, c, d, a, M_offset_6, 23, T[43]);
- a = HH(a, b, c, d, M_offset_9, 4, T[44]);
- d = HH(d, a, b, c, M_offset_12, 11, T[45]);
- c = HH(c, d, a, b, M_offset_15, 16, T[46]);
- b = HH(b, c, d, a, M_offset_2, 23, T[47]);
- a = II(a, b, c, d, M_offset_0, 6, T[48]);
- d = II(d, a, b, c, M_offset_7, 10, T[49]);
- c = II(c, d, a, b, M_offset_14, 15, T[50]);
- b = II(b, c, d, a, M_offset_5, 21, T[51]);
- a = II(a, b, c, d, M_offset_12, 6, T[52]);
- d = II(d, a, b, c, M_offset_3, 10, T[53]);
- c = II(c, d, a, b, M_offset_10, 15, T[54]);
- b = II(b, c, d, a, M_offset_1, 21, T[55]);
- a = II(a, b, c, d, M_offset_8, 6, T[56]);
- d = II(d, a, b, c, M_offset_15, 10, T[57]);
- c = II(c, d, a, b, M_offset_6, 15, T[58]);
- b = II(b, c, d, a, M_offset_13, 21, T[59]);
- a = II(a, b, c, d, M_offset_4, 6, T[60]);
- d = II(d, a, b, c, M_offset_11, 10, T[61]);
- c = II(c, d, a, b, M_offset_2, 15, T[62]);
- b = II(b, c, d, a, M_offset_9, 21, T[63]);
- // Intermediate hash value
- H[0] = (H[0] + a) | 0;
- H[1] = (H[1] + b) | 0;
- H[2] = (H[2] + c) | 0;
- H[3] = (H[3] + d) | 0;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
- var nBitsTotalL = nBitsTotal;
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
- (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
- (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
- );
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
- (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
- (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
- );
- data.sigBytes = (dataWords.length + 1) * 4;
- // Hash final blocks
- this._process();
- // Shortcuts
- var hash = this._hash;
- var H = hash.words;
- // Swap endian
- for (var i = 0; i < 4; i++) {
- // Shortcut
- var H_i = H[i];
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
- }
- // Return final computed hash
- return hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- function FF(a, b, c, d, x, s, t) {
- var n = a + ((b & c) | (~b & d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function GG(a, b, c, d, x, s, t) {
- var n = a + ((b & d) | (c & ~d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function HH(a, b, c, d, x, s, t) {
- var n = a + (b ^ c ^ d) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- function II(a, b, c, d, x, s, t) {
- var n = a + (c ^ (b | ~d)) + x + t;
- return ((n << s) | (n >>> (32 - s))) + b;
- }
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.MD5('message');
- * var hash = CryptoJS.MD5(wordArray);
- */
- C.MD5 = Hasher._createHelper(MD5);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacMD5(message, key);
- */
- C.HmacMD5 = Hasher._createHmacHelper(MD5);
- }(Math));
- return CryptoJS.MD5;
- }));
- },{"./core":53}],62:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Cipher Feedback block mode.
- */
- CryptoJS.mode.CFB = (function () {
- var CFB = CryptoJS.lib.BlockCipherMode.extend();
- CFB.Encryptor = CFB.extend({
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
- // Remember this block to use with next block
- this._prevBlock = words.slice(offset, offset + blockSize);
- }
- });
- CFB.Decryptor = CFB.extend({
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher;
- var blockSize = cipher.blockSize;
- // Remember this block to use with next block
- var thisBlock = words.slice(offset, offset + blockSize);
- generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
- // This block becomes the previous block
- this._prevBlock = thisBlock;
- }
- });
- function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
- // Shortcut
- var iv = this._iv;
- // Generate keystream
- if (iv) {
- var keystream = iv.slice(0);
- // Remove IV for subsequent blocks
- this._iv = undefined;
- } else {
- var keystream = this._prevBlock;
- }
- cipher.encryptBlock(keystream, 0);
- // Encrypt
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= keystream[i];
- }
- }
- return CFB;
- }());
- return CryptoJS.mode.CFB;
- }));
- },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /** @preserve
- * Counter block mode compatible with Dr Brian Gladman fileenc.c
- * derived from CryptoJS.mode.CTR
- * Jan Hruby [email protected]
- */
- CryptoJS.mode.CTRGladman = (function () {
- var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
- function incWord(word)
- {
- if (((word >> 24) & 0xff) === 0xff) { //overflow
- var b1 = (word >> 16)&0xff;
- var b2 = (word >> 8)&0xff;
- var b3 = word & 0xff;
- if (b1 === 0xff) // overflow b1
- {
- b1 = 0;
- if (b2 === 0xff)
- {
- b2 = 0;
- if (b3 === 0xff)
- {
- b3 = 0;
- }
- else
- {
- ++b3;
- }
- }
- else
- {
- ++b2;
- }
- }
- else
- {
- ++b1;
- }
- word = 0;
- word += (b1 << 16);
- word += (b2 << 8);
- word += b3;
- }
- else
- {
- word += (0x01 << 24);
- }
- return word;
- }
- function incCounter(counter)
- {
- if ((counter[0] = incWord(counter[0])) === 0)
- {
- // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
- counter[1] = incWord(counter[1]);
- }
- return counter;
- }
- var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher
- var blockSize = cipher.blockSize;
- var iv = this._iv;
- var counter = this._counter;
- // Generate keystream
- if (iv) {
- counter = this._counter = iv.slice(0);
- // Remove IV for subsequent blocks
- this._iv = undefined;
- }
- incCounter(counter);
- var keystream = counter.slice(0);
- cipher.encryptBlock(keystream, 0);
- // Encrypt
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= keystream[i];
- }
- }
- });
- CTRGladman.Decryptor = Encryptor;
- return CTRGladman;
- }());
- return CryptoJS.mode.CTRGladman;
- }));
- },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Counter block mode.
- */
- CryptoJS.mode.CTR = (function () {
- var CTR = CryptoJS.lib.BlockCipherMode.extend();
- var Encryptor = CTR.Encryptor = CTR.extend({
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher
- var blockSize = cipher.blockSize;
- var iv = this._iv;
- var counter = this._counter;
- // Generate keystream
- if (iv) {
- counter = this._counter = iv.slice(0);
- // Remove IV for subsequent blocks
- this._iv = undefined;
- }
- var keystream = counter.slice(0);
- cipher.encryptBlock(keystream, 0);
- // Increment counter
- counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
- // Encrypt
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= keystream[i];
- }
- }
- });
- CTR.Decryptor = Encryptor;
- return CTR;
- }());
- return CryptoJS.mode.CTR;
- }));
- },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Electronic Codebook block mode.
- */
- CryptoJS.mode.ECB = (function () {
- var ECB = CryptoJS.lib.BlockCipherMode.extend();
- ECB.Encryptor = ECB.extend({
- processBlock: function (words, offset) {
- this._cipher.encryptBlock(words, offset);
- }
- });
- ECB.Decryptor = ECB.extend({
- processBlock: function (words, offset) {
- this._cipher.decryptBlock(words, offset);
- }
- });
- return ECB;
- }());
- return CryptoJS.mode.ECB;
- }));
- },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Output Feedback block mode.
- */
- CryptoJS.mode.OFB = (function () {
- var OFB = CryptoJS.lib.BlockCipherMode.extend();
- var Encryptor = OFB.Encryptor = OFB.extend({
- processBlock: function (words, offset) {
- // Shortcuts
- var cipher = this._cipher
- var blockSize = cipher.blockSize;
- var iv = this._iv;
- var keystream = this._keystream;
- // Generate keystream
- if (iv) {
- keystream = this._keystream = iv.slice(0);
- // Remove IV for subsequent blocks
- this._iv = undefined;
- }
- cipher.encryptBlock(keystream, 0);
- // Encrypt
- for (var i = 0; i < blockSize; i++) {
- words[offset + i] ^= keystream[i];
- }
- }
- });
- OFB.Decryptor = Encryptor;
- return OFB;
- }());
- return CryptoJS.mode.OFB;
- }));
- },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * ANSI X.923 padding strategy.
- */
- CryptoJS.pad.AnsiX923 = {
- pad: function (data, blockSize) {
- // Shortcuts
- var dataSigBytes = data.sigBytes;
- var blockSizeBytes = blockSize * 4;
- // Count padding bytes
- var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
- // Compute last byte position
- var lastBytePos = dataSigBytes + nPaddingBytes - 1;
- // Pad
- data.clamp();
- data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
- data.sigBytes += nPaddingBytes;
- },
- unpad: function (data) {
- // Get number of padding bytes from last byte
- var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
- // Remove padding
- data.sigBytes -= nPaddingBytes;
- }
- };
- return CryptoJS.pad.Ansix923;
- }));
- },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * ISO 10126 padding strategy.
- */
- CryptoJS.pad.Iso10126 = {
- pad: function (data, blockSize) {
- // Shortcut
- var blockSizeBytes = blockSize * 4;
- // Count padding bytes
- var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
- // Pad
- data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
- concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
- },
- unpad: function (data) {
- // Get number of padding bytes from last byte
- var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
- // Remove padding
- data.sigBytes -= nPaddingBytes;
- }
- };
- return CryptoJS.pad.Iso10126;
- }));
- },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * ISO/IEC 9797-1 Padding Method 2.
- */
- CryptoJS.pad.Iso97971 = {
- pad: function (data, blockSize) {
- // Add 0x80 byte
- data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
- // Zero pad the rest
- CryptoJS.pad.ZeroPadding.pad(data, blockSize);
- },
- unpad: function (data) {
- // Remove zero padding
- CryptoJS.pad.ZeroPadding.unpad(data);
- // Remove one more byte -- the 0x80 byte
- data.sigBytes--;
- }
- };
- return CryptoJS.pad.Iso97971;
- }));
- },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * A noop padding strategy.
- */
- CryptoJS.pad.NoPadding = {
- pad: function () {
- },
- unpad: function () {
- }
- };
- return CryptoJS.pad.NoPadding;
- }));
- },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /**
- * Zero padding strategy.
- */
- CryptoJS.pad.ZeroPadding = {
- pad: function (data, blockSize) {
- // Shortcut
- var blockSizeBytes = blockSize * 4;
- // Pad
- data.clamp();
- data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
- },
- unpad: function (data) {
- // Shortcut
- var dataWords = data.words;
- // Unpad
- var i = data.sigBytes - 1;
- while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
- i--;
- }
- data.sigBytes = i + 1;
- }
- };
- return CryptoJS.pad.ZeroPadding;
- }));
- },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./sha1", "./hmac"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var WordArray = C_lib.WordArray;
- var C_algo = C.algo;
- var SHA1 = C_algo.SHA1;
- var HMAC = C_algo.HMAC;
- /**
- * Password-Based Key Derivation Function 2 algorithm.
- */
- var PBKDF2 = C_algo.PBKDF2 = Base.extend({
- /**
- * Configuration options.
- *
- * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
- * @property {Hasher} hasher The hasher to use. Default: SHA1
- * @property {number} iterations The number of iterations to perform. Default: 1
- */
- cfg: Base.extend({
- keySize: 128/32,
- hasher: SHA1,
- iterations: 1
- }),
- /**
- * Initializes a newly created key derivation function.
- *
- * @param {Object} cfg (Optional) The configuration options to use for the derivation.
- *
- * @example
- *
- * var kdf = CryptoJS.algo.PBKDF2.create();
- * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
- * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
- */
- init: function (cfg) {
- this.cfg = this.cfg.extend(cfg);
- },
- /**
- * Computes the Password-Based Key Derivation Function 2.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- *
- * @return {WordArray} The derived key.
- *
- * @example
- *
- * var key = kdf.compute(password, salt);
- */
- compute: function (password, salt) {
- // Shortcut
- var cfg = this.cfg;
- // Init HMAC
- var hmac = HMAC.create(cfg.hasher, password);
- // Initial values
- var derivedKey = WordArray.create();
- var blockIndex = WordArray.create([0x00000001]);
- // Shortcuts
- var derivedKeyWords = derivedKey.words;
- var blockIndexWords = blockIndex.words;
- var keySize = cfg.keySize;
- var iterations = cfg.iterations;
- // Generate key
- while (derivedKeyWords.length < keySize) {
- var block = hmac.update(salt).finalize(blockIndex);
- hmac.reset();
- // Shortcuts
- var blockWords = block.words;
- var blockWordsLength = blockWords.length;
- // Iterations
- var intermediate = block;
- for (var i = 1; i < iterations; i++) {
- intermediate = hmac.finalize(intermediate);
- hmac.reset();
- // Shortcut
- var intermediateWords = intermediate.words;
- // XOR intermediate with block
- for (var j = 0; j < blockWordsLength; j++) {
- blockWords[j] ^= intermediateWords[j];
- }
- }
- derivedKey.concat(block);
- blockIndexWords[0]++;
- }
- derivedKey.sigBytes = keySize * 4;
- return derivedKey;
- }
- });
- /**
- * Computes the Password-Based Key Derivation Function 2.
- *
- * @param {WordArray|string} password The password.
- * @param {WordArray|string} salt A salt.
- * @param {Object} cfg (Optional) The configuration options to use for this computation.
- *
- * @return {WordArray} The derived key.
- *
- * @static
- *
- * @example
- *
- * var key = CryptoJS.PBKDF2(password, salt);
- * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
- * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
- */
- C.PBKDF2 = function (password, salt, cfg) {
- return PBKDF2.create(cfg).compute(password, salt);
- };
- }());
- return CryptoJS.PBKDF2;
- }));
- },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var StreamCipher = C_lib.StreamCipher;
- var C_algo = C.algo;
- // Reusable objects
- var S = [];
- var C_ = [];
- var G = [];
- /**
- * Rabbit stream cipher algorithm.
- *
- * This is a legacy version that neglected to convert the key to little-endian.
- * This error doesn't affect the cipher's security,
- * but it does affect its compatibility with other implementations.
- */
- var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
- _doReset: function () {
- // Shortcuts
- var K = this._key.words;
- var iv = this.cfg.iv;
- // Generate initial state values
- var X = this._X = [
- K[0], (K[3] << 16) | (K[2] >>> 16),
- K[1], (K[0] << 16) | (K[3] >>> 16),
- K[2], (K[1] << 16) | (K[0] >>> 16),
- K[3], (K[2] << 16) | (K[1] >>> 16)
- ];
- // Generate initial counter values
- var C = this._C = [
- (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
- (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
- (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
- (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
- ];
- // Carry bit
- this._b = 0;
- // Iterate the system four times
- for (var i = 0; i < 4; i++) {
- nextState.call(this);
- }
- // Modify the counters
- for (var i = 0; i < 8; i++) {
- C[i] ^= X[(i + 4) & 7];
- }
- // IV setup
- if (iv) {
- // Shortcuts
- var IV = iv.words;
- var IV_0 = IV[0];
- var IV_1 = IV[1];
- // Generate four subvectors
- var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
- var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
- var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
- var i3 = (i2 << 16) | (i0 & 0x0000ffff);
- // Modify counter values
- C[0] ^= i0;
- C[1] ^= i1;
- C[2] ^= i2;
- C[3] ^= i3;
- C[4] ^= i0;
- C[5] ^= i1;
- C[6] ^= i2;
- C[7] ^= i3;
- // Iterate the system four times
- for (var i = 0; i < 4; i++) {
- nextState.call(this);
- }
- }
- },
- _doProcessBlock: function (M, offset) {
- // Shortcut
- var X = this._X;
- // Iterate the system
- nextState.call(this);
- // Generate four keystream words
- S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
- S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
- S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
- S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
- for (var i = 0; i < 4; i++) {
- // Swap endian
- S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
- (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
- // Encrypt
- M[offset + i] ^= S[i];
- }
- },
- blockSize: 128/32,
- ivSize: 64/32
- });
- function nextState() {
- // Shortcuts
- var X = this._X;
- var C = this._C;
- // Save old counter values
- for (var i = 0; i < 8; i++) {
- C_[i] = C[i];
- }
- // Calculate new counter values
- C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
- C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
- C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
- C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
- C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
- C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
- C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
- C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
- this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
- // Calculate the g-values
- for (var i = 0; i < 8; i++) {
- var gx = X[i] + C[i];
- // Construct high and low argument for squaring
- var ga = gx & 0xffff;
- var gb = gx >>> 16;
- // Calculate high and low result of squaring
- var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
- var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
- // High XOR low
- G[i] = gh ^ gl;
- }
- // Calculate new state values
- X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
- X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
- X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
- X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
- X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
- X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
- X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
- X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
- }
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
- */
- C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
- }());
- return CryptoJS.RabbitLegacy;
- }));
- },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var StreamCipher = C_lib.StreamCipher;
- var C_algo = C.algo;
- // Reusable objects
- var S = [];
- var C_ = [];
- var G = [];
- /**
- * Rabbit stream cipher algorithm
- */
- var Rabbit = C_algo.Rabbit = StreamCipher.extend({
- _doReset: function () {
- // Shortcuts
- var K = this._key.words;
- var iv = this.cfg.iv;
- // Swap endian
- for (var i = 0; i < 4; i++) {
- K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
- (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
- }
- // Generate initial state values
- var X = this._X = [
- K[0], (K[3] << 16) | (K[2] >>> 16),
- K[1], (K[0] << 16) | (K[3] >>> 16),
- K[2], (K[1] << 16) | (K[0] >>> 16),
- K[3], (K[2] << 16) | (K[1] >>> 16)
- ];
- // Generate initial counter values
- var C = this._C = [
- (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
- (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
- (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
- (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
- ];
- // Carry bit
- this._b = 0;
- // Iterate the system four times
- for (var i = 0; i < 4; i++) {
- nextState.call(this);
- }
- // Modify the counters
- for (var i = 0; i < 8; i++) {
- C[i] ^= X[(i + 4) & 7];
- }
- // IV setup
- if (iv) {
- // Shortcuts
- var IV = iv.words;
- var IV_0 = IV[0];
- var IV_1 = IV[1];
- // Generate four subvectors
- var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
- var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
- var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
- var i3 = (i2 << 16) | (i0 & 0x0000ffff);
- // Modify counter values
- C[0] ^= i0;
- C[1] ^= i1;
- C[2] ^= i2;
- C[3] ^= i3;
- C[4] ^= i0;
- C[5] ^= i1;
- C[6] ^= i2;
- C[7] ^= i3;
- // Iterate the system four times
- for (var i = 0; i < 4; i++) {
- nextState.call(this);
- }
- }
- },
- _doProcessBlock: function (M, offset) {
- // Shortcut
- var X = this._X;
- // Iterate the system
- nextState.call(this);
- // Generate four keystream words
- S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
- S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
- S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
- S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
- for (var i = 0; i < 4; i++) {
- // Swap endian
- S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
- (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
- // Encrypt
- M[offset + i] ^= S[i];
- }
- },
- blockSize: 128/32,
- ivSize: 64/32
- });
- function nextState() {
- // Shortcuts
- var X = this._X;
- var C = this._C;
- // Save old counter values
- for (var i = 0; i < 8; i++) {
- C_[i] = C[i];
- }
- // Calculate new counter values
- C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
- C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
- C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
- C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
- C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
- C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
- C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
- C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
- this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
- // Calculate the g-values
- for (var i = 0; i < 8; i++) {
- var gx = X[i] + C[i];
- // Construct high and low argument for squaring
- var ga = gx & 0xffff;
- var gb = gx >>> 16;
- // Calculate high and low result of squaring
- var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
- var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
- // High XOR low
- G[i] = gh ^ gl;
- }
- // Calculate new state values
- X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
- X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
- X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
- X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
- X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
- X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
- X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
- X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
- }
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
- */
- C.Rabbit = StreamCipher._createHelper(Rabbit);
- }());
- return CryptoJS.Rabbit;
- }));
- },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var StreamCipher = C_lib.StreamCipher;
- var C_algo = C.algo;
- /**
- * RC4 stream cipher algorithm.
- */
- var RC4 = C_algo.RC4 = StreamCipher.extend({
- _doReset: function () {
- // Shortcuts
- var key = this._key;
- var keyWords = key.words;
- var keySigBytes = key.sigBytes;
- // Init sbox
- var S = this._S = [];
- for (var i = 0; i < 256; i++) {
- S[i] = i;
- }
- // Key setup
- for (var i = 0, j = 0; i < 256; i++) {
- var keyByteIndex = i % keySigBytes;
- var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
- j = (j + S[i] + keyByte) % 256;
- // Swap
- var t = S[i];
- S[i] = S[j];
- S[j] = t;
- }
- // Counters
- this._i = this._j = 0;
- },
- _doProcessBlock: function (M, offset) {
- M[offset] ^= generateKeystreamWord.call(this);
- },
- keySize: 256/32,
- ivSize: 0
- });
- function generateKeystreamWord() {
- // Shortcuts
- var S = this._S;
- var i = this._i;
- var j = this._j;
- // Generate keystream word
- var keystreamWord = 0;
- for (var n = 0; n < 4; n++) {
- i = (i + 1) % 256;
- j = (j + S[i]) % 256;
- // Swap
- var t = S[i];
- S[i] = S[j];
- S[j] = t;
- keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
- }
- // Update counters
- this._i = i;
- this._j = j;
- return keystreamWord;
- }
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
- */
- C.RC4 = StreamCipher._createHelper(RC4);
- /**
- * Modified RC4 stream cipher algorithm.
- */
- var RC4Drop = C_algo.RC4Drop = RC4.extend({
- /**
- * Configuration options.
- *
- * @property {number} drop The number of keystream words to drop. Default 192
- */
- cfg: RC4.cfg.extend({
- drop: 192
- }),
- _doReset: function () {
- RC4._doReset.call(this);
- // Drop
- for (var i = this.cfg.drop; i > 0; i--) {
- generateKeystreamWord.call(this);
- }
- }
- });
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
- */
- C.RC4Drop = StreamCipher._createHelper(RC4Drop);
- }());
- return CryptoJS.RC4;
- }));
- },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- /** @preserve
- (c) 2012 by Cédric Mesnil. All rights reserved.
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- - 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.
- 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.
- */
- (function (Math) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Constants table
- var _zl = WordArray.create([
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
- var _zr = WordArray.create([
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
- var _sl = WordArray.create([
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
- var _sr = WordArray.create([
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
- var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
- var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
- /**
- * RIPEMD160 hash algorithm.
- */
- var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
- _doReset: function () {
- this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
- },
- _doProcessBlock: function (M, offset) {
- // Swap endian
- for (var i = 0; i < 16; i++) {
- // Shortcuts
- var offset_i = offset + i;
- var M_offset_i = M[offset_i];
- // Swap
- M[offset_i] = (
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
- );
- }
- // Shortcut
- var H = this._hash.words;
- var hl = _hl.words;
- var hr = _hr.words;
- var zl = _zl.words;
- var zr = _zr.words;
- var sl = _sl.words;
- var sr = _sr.words;
- // Working variables
- var al, bl, cl, dl, el;
- var ar, br, cr, dr, er;
- ar = al = H[0];
- br = bl = H[1];
- cr = cl = H[2];
- dr = dl = H[3];
- er = el = H[4];
- // Computation
- var t;
- for (var i = 0; i < 80; i += 1) {
- t = (al + M[offset+zl[i]])|0;
- if (i<16){
- t += f1(bl,cl,dl) + hl[0];
- } else if (i<32) {
- t += f2(bl,cl,dl) + hl[1];
- } else if (i<48) {
- t += f3(bl,cl,dl) + hl[2];
- } else if (i<64) {
- t += f4(bl,cl,dl) + hl[3];
- } else {// if (i<80) {
- t += f5(bl,cl,dl) + hl[4];
- }
- t = t|0;
- t = rotl(t,sl[i]);
- t = (t+el)|0;
- al = el;
- el = dl;
- dl = rotl(cl, 10);
- cl = bl;
- bl = t;
- t = (ar + M[offset+zr[i]])|0;
- if (i<16){
- t += f5(br,cr,dr) + hr[0];
- } else if (i<32) {
- t += f4(br,cr,dr) + hr[1];
- } else if (i<48) {
- t += f3(br,cr,dr) + hr[2];
- } else if (i<64) {
- t += f2(br,cr,dr) + hr[3];
- } else {// if (i<80) {
- t += f1(br,cr,dr) + hr[4];
- }
- t = t|0;
- t = rotl(t,sr[i]) ;
- t = (t+er)|0;
- ar = er;
- er = dr;
- dr = rotl(cr, 10);
- cr = br;
- br = t;
- }
- // Intermediate hash value
- t = (H[1] + cl + dr)|0;
- H[1] = (H[2] + dl + er)|0;
- H[2] = (H[3] + el + ar)|0;
- H[3] = (H[4] + al + br)|0;
- H[4] = (H[0] + bl + cr)|0;
- H[0] = t;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
- (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
- (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
- );
- data.sigBytes = (dataWords.length + 1) * 4;
- // Hash final blocks
- this._process();
- // Shortcuts
- var hash = this._hash;
- var H = hash.words;
- // Swap endian
- for (var i = 0; i < 5; i++) {
- // Shortcut
- var H_i = H[i];
- // Swap
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
- }
- // Return final computed hash
- return hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- function f1(x, y, z) {
- return ((x) ^ (y) ^ (z));
- }
- function f2(x, y, z) {
- return (((x)&(y)) | ((~x)&(z)));
- }
- function f3(x, y, z) {
- return (((x) | (~(y))) ^ (z));
- }
- function f4(x, y, z) {
- return (((x) & (z)) | ((y)&(~(z))));
- }
- function f5(x, y, z) {
- return ((x) ^ ((y) |(~(z))));
- }
- function rotl(x,n) {
- return (x<<n) | (x>>>(32-n));
- }
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.RIPEMD160('message');
- * var hash = CryptoJS.RIPEMD160(wordArray);
- */
- C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacRIPEMD160(message, key);
- */
- C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
- }(Math));
- return CryptoJS.RIPEMD160;
- }));
- },{"./core":53}],77:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Reusable object
- var W = [];
- /**
- * SHA-1 hash algorithm.
- */
- var SHA1 = C_algo.SHA1 = Hasher.extend({
- _doReset: function () {
- this._hash = new WordArray.init([
- 0x67452301, 0xefcdab89,
- 0x98badcfe, 0x10325476,
- 0xc3d2e1f0
- ]);
- },
- _doProcessBlock: function (M, offset) {
- // Shortcut
- var H = this._hash.words;
- // Working variables
- var a = H[0];
- var b = H[1];
- var c = H[2];
- var d = H[3];
- var e = H[4];
- // Computation
- for (var i = 0; i < 80; i++) {
- if (i < 16) {
- W[i] = M[offset + i] | 0;
- } else {
- var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
- W[i] = (n << 1) | (n >>> 31);
- }
- var t = ((a << 5) | (a >>> 27)) + e + W[i];
- if (i < 20) {
- t += ((b & c) | (~b & d)) + 0x5a827999;
- } else if (i < 40) {
- t += (b ^ c ^ d) + 0x6ed9eba1;
- } else if (i < 60) {
- t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
- } else /* if (i < 80) */ {
- t += (b ^ c ^ d) - 0x359d3e2a;
- }
- e = d;
- d = c;
- c = (b << 30) | (b >>> 2);
- b = a;
- a = t;
- }
- // Intermediate hash value
- H[0] = (H[0] + a) | 0;
- H[1] = (H[1] + b) | 0;
- H[2] = (H[2] + c) | 0;
- H[3] = (H[3] + d) | 0;
- H[4] = (H[4] + e) | 0;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
- data.sigBytes = dataWords.length * 4;
- // Hash final blocks
- this._process();
- // Return final computed hash
- return this._hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA1('message');
- * var hash = CryptoJS.SHA1(wordArray);
- */
- C.SHA1 = Hasher._createHelper(SHA1);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA1(message, key);
- */
- C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
- }());
- return CryptoJS.SHA1;
- }));
- },{"./core":53}],78:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./sha256"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./sha256"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var C_algo = C.algo;
- var SHA256 = C_algo.SHA256;
- /**
- * SHA-224 hash algorithm.
- */
- var SHA224 = C_algo.SHA224 = SHA256.extend({
- _doReset: function () {
- this._hash = new WordArray.init([
- 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
- 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
- ]);
- },
- _doFinalize: function () {
- var hash = SHA256._doFinalize.call(this);
- hash.sigBytes -= 4;
- return hash;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA224('message');
- * var hash = CryptoJS.SHA224(wordArray);
- */
- C.SHA224 = SHA256._createHelper(SHA224);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA224(message, key);
- */
- C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
- }());
- return CryptoJS.SHA224;
- }));
- },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (Math) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_algo = C.algo;
- // Initialization and round constants tables
- var H = [];
- var K = [];
- // Compute constants
- (function () {
- function isPrime(n) {
- var sqrtN = Math.sqrt(n);
- for (var factor = 2; factor <= sqrtN; factor++) {
- if (!(n % factor)) {
- return false;
- }
- }
- return true;
- }
- function getFractionalBits(n) {
- return ((n - (n | 0)) * 0x100000000) | 0;
- }
- var n = 2;
- var nPrime = 0;
- while (nPrime < 64) {
- if (isPrime(n)) {
- if (nPrime < 8) {
- H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
- }
- K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
- nPrime++;
- }
- n++;
- }
- }());
- // Reusable object
- var W = [];
- /**
- * SHA-256 hash algorithm.
- */
- var SHA256 = C_algo.SHA256 = Hasher.extend({
- _doReset: function () {
- this._hash = new WordArray.init(H.slice(0));
- },
- _doProcessBlock: function (M, offset) {
- // Shortcut
- var H = this._hash.words;
- // Working variables
- var a = H[0];
- var b = H[1];
- var c = H[2];
- var d = H[3];
- var e = H[4];
- var f = H[5];
- var g = H[6];
- var h = H[7];
- // Computation
- for (var i = 0; i < 64; i++) {
- if (i < 16) {
- W[i] = M[offset + i] | 0;
- } else {
- var gamma0x = W[i - 15];
- var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
- ((gamma0x << 14) | (gamma0x >>> 18)) ^
- (gamma0x >>> 3);
- var gamma1x = W[i - 2];
- var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
- ((gamma1x << 13) | (gamma1x >>> 19)) ^
- (gamma1x >>> 10);
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
- }
- var ch = (e & f) ^ (~e & g);
- var maj = (a & b) ^ (a & c) ^ (b & c);
- var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
- var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
- var t1 = h + sigma1 + ch + K[i] + W[i];
- var t2 = sigma0 + maj;
- h = g;
- g = f;
- f = e;
- e = (d + t1) | 0;
- d = c;
- c = b;
- b = a;
- a = (t1 + t2) | 0;
- }
- // Intermediate hash value
- H[0] = (H[0] + a) | 0;
- H[1] = (H[1] + b) | 0;
- H[2] = (H[2] + c) | 0;
- H[3] = (H[3] + d) | 0;
- H[4] = (H[4] + e) | 0;
- H[5] = (H[5] + f) | 0;
- H[6] = (H[6] + g) | 0;
- H[7] = (H[7] + h) | 0;
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
- data.sigBytes = dataWords.length * 4;
- // Hash final blocks
- this._process();
- // Return final computed hash
- return this._hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA256('message');
- * var hash = CryptoJS.SHA256(wordArray);
- */
- C.SHA256 = Hasher._createHelper(SHA256);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA256(message, key);
- */
- C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
- }(Math));
- return CryptoJS.SHA256;
- }));
- },{"./core":53}],80:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./x64-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./x64-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (Math) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var Hasher = C_lib.Hasher;
- var C_x64 = C.x64;
- var X64Word = C_x64.Word;
- var C_algo = C.algo;
- // Constants tables
- var RHO_OFFSETS = [];
- var PI_INDEXES = [];
- var ROUND_CONSTANTS = [];
- // Compute Constants
- (function () {
- // Compute rho offset constants
- var x = 1, y = 0;
- for (var t = 0; t < 24; t++) {
- RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
- var newX = y % 5;
- var newY = (2 * x + 3 * y) % 5;
- x = newX;
- y = newY;
- }
- // Compute pi index constants
- for (var x = 0; x < 5; x++) {
- for (var y = 0; y < 5; y++) {
- PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
- }
- }
- // Compute round constants
- var LFSR = 0x01;
- for (var i = 0; i < 24; i++) {
- var roundConstantMsw = 0;
- var roundConstantLsw = 0;
- for (var j = 0; j < 7; j++) {
- if (LFSR & 0x01) {
- var bitPosition = (1 << j) - 1;
- if (bitPosition < 32) {
- roundConstantLsw ^= 1 << bitPosition;
- } else /* if (bitPosition >= 32) */ {
- roundConstantMsw ^= 1 << (bitPosition - 32);
- }
- }
- // Compute next LFSR
- if (LFSR & 0x80) {
- // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
- LFSR = (LFSR << 1) ^ 0x71;
- } else {
- LFSR <<= 1;
- }
- }
- ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
- }
- }());
- // Reusable objects for temporary values
- var T = [];
- (function () {
- for (var i = 0; i < 25; i++) {
- T[i] = X64Word.create();
- }
- }());
- /**
- * SHA-3 hash algorithm.
- */
- var SHA3 = C_algo.SHA3 = Hasher.extend({
- /**
- * Configuration options.
- *
- * @property {number} outputLength
- * The desired number of bits in the output hash.
- * Only values permitted are: 224, 256, 384, 512.
- * Default: 512
- */
- cfg: Hasher.cfg.extend({
- outputLength: 512
- }),
- _doReset: function () {
- var state = this._state = []
- for (var i = 0; i < 25; i++) {
- state[i] = new X64Word.init();
- }
- this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
- },
- _doProcessBlock: function (M, offset) {
- // Shortcuts
- var state = this._state;
- var nBlockSizeLanes = this.blockSize / 2;
- // Absorb
- for (var i = 0; i < nBlockSizeLanes; i++) {
- // Shortcuts
- var M2i = M[offset + 2 * i];
- var M2i1 = M[offset + 2 * i + 1];
- // Swap endian
- M2i = (
- (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
- (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
- );
- M2i1 = (
- (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
- (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
- );
- // Absorb message into state
- var lane = state[i];
- lane.high ^= M2i1;
- lane.low ^= M2i;
- }
- // Rounds
- for (var round = 0; round < 24; round++) {
- // Theta
- for (var x = 0; x < 5; x++) {
- // Mix column lanes
- var tMsw = 0, tLsw = 0;
- for (var y = 0; y < 5; y++) {
- var lane = state[x + 5 * y];
- tMsw ^= lane.high;
- tLsw ^= lane.low;
- }
- // Temporary values
- var Tx = T[x];
- Tx.high = tMsw;
- Tx.low = tLsw;
- }
- for (var x = 0; x < 5; x++) {
- // Shortcuts
- var Tx4 = T[(x + 4) % 5];
- var Tx1 = T[(x + 1) % 5];
- var Tx1Msw = Tx1.high;
- var Tx1Lsw = Tx1.low;
- // Mix surrounding columns
- var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
- var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
- for (var y = 0; y < 5; y++) {
- var lane = state[x + 5 * y];
- lane.high ^= tMsw;
- lane.low ^= tLsw;
- }
- }
- // Rho Pi
- for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
- // Shortcuts
- var lane = state[laneIndex];
- var laneMsw = lane.high;
- var laneLsw = lane.low;
- var rhoOffset = RHO_OFFSETS[laneIndex];
- // Rotate lanes
- if (rhoOffset < 32) {
- var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
- var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
- } else /* if (rhoOffset >= 32) */ {
- var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
- var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
- }
- // Transpose lanes
- var TPiLane = T[PI_INDEXES[laneIndex]];
- TPiLane.high = tMsw;
- TPiLane.low = tLsw;
- }
- // Rho pi at x = y = 0
- var T0 = T[0];
- var state0 = state[0];
- T0.high = state0.high;
- T0.low = state0.low;
- // Chi
- for (var x = 0; x < 5; x++) {
- for (var y = 0; y < 5; y++) {
- // Shortcuts
- var laneIndex = x + 5 * y;
- var lane = state[laneIndex];
- var TLane = T[laneIndex];
- var Tx1Lane = T[((x + 1) % 5) + 5 * y];
- var Tx2Lane = T[((x + 2) % 5) + 5 * y];
- // Mix rows
- lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
- lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
- }
- }
- // Iota
- var lane = state[0];
- var roundConstant = ROUND_CONSTANTS[round];
- lane.high ^= roundConstant.high;
- lane.low ^= roundConstant.low;;
- }
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- var blockSizeBits = this.blockSize * 32;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
- dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
- data.sigBytes = dataWords.length * 4;
- // Hash final blocks
- this._process();
- // Shortcuts
- var state = this._state;
- var outputLengthBytes = this.cfg.outputLength / 8;
- var outputLengthLanes = outputLengthBytes / 8;
- // Squeeze
- var hashWords = [];
- for (var i = 0; i < outputLengthLanes; i++) {
- // Shortcuts
- var lane = state[i];
- var laneMsw = lane.high;
- var laneLsw = lane.low;
- // Swap endian
- laneMsw = (
- (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
- (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
- );
- laneLsw = (
- (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
- (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
- );
- // Squeeze state to retrieve hash
- hashWords.push(laneLsw);
- hashWords.push(laneMsw);
- }
- // Return final computed hash
- return new WordArray.init(hashWords, outputLengthBytes);
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- var state = clone._state = this._state.slice(0);
- for (var i = 0; i < 25; i++) {
- state[i] = state[i].clone();
- }
- return clone;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA3('message');
- * var hash = CryptoJS.SHA3(wordArray);
- */
- C.SHA3 = Hasher._createHelper(SHA3);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA3(message, key);
- */
- C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
- }(Math));
- return CryptoJS.SHA3;
- }));
- },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./x64-core", "./sha512"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_x64 = C.x64;
- var X64Word = C_x64.Word;
- var X64WordArray = C_x64.WordArray;
- var C_algo = C.algo;
- var SHA512 = C_algo.SHA512;
- /**
- * SHA-384 hash algorithm.
- */
- var SHA384 = C_algo.SHA384 = SHA512.extend({
- _doReset: function () {
- this._hash = new X64WordArray.init([
- new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
- new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
- new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
- new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
- ]);
- },
- _doFinalize: function () {
- var hash = SHA512._doFinalize.call(this);
- hash.sigBytes -= 16;
- return hash;
- }
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA384('message');
- * var hash = CryptoJS.SHA384(wordArray);
- */
- C.SHA384 = SHA512._createHelper(SHA384);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA384(message, key);
- */
- C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
- }());
- return CryptoJS.SHA384;
- }));
- },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./x64-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./x64-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Hasher = C_lib.Hasher;
- var C_x64 = C.x64;
- var X64Word = C_x64.Word;
- var X64WordArray = C_x64.WordArray;
- var C_algo = C.algo;
- function X64Word_create() {
- return X64Word.create.apply(X64Word, arguments);
- }
- // Constants
- var K = [
- X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
- X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
- X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
- X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
- X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
- X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
- X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
- X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
- X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
- X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
- X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
- X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
- X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
- X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
- X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
- X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
- X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
- X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
- X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
- X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
- X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
- X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
- X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
- X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
- X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
- X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
- X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
- X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
- X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
- X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
- X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
- X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
- X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
- X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
- X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
- X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
- X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
- X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
- X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
- X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
- ];
- // Reusable objects
- var W = [];
- (function () {
- for (var i = 0; i < 80; i++) {
- W[i] = X64Word_create();
- }
- }());
- /**
- * SHA-512 hash algorithm.
- */
- var SHA512 = C_algo.SHA512 = Hasher.extend({
- _doReset: function () {
- this._hash = new X64WordArray.init([
- new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
- new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
- new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
- new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
- ]);
- },
- _doProcessBlock: function (M, offset) {
- // Shortcuts
- var H = this._hash.words;
- var H0 = H[0];
- var H1 = H[1];
- var H2 = H[2];
- var H3 = H[3];
- var H4 = H[4];
- var H5 = H[5];
- var H6 = H[6];
- var H7 = H[7];
- var H0h = H0.high;
- var H0l = H0.low;
- var H1h = H1.high;
- var H1l = H1.low;
- var H2h = H2.high;
- var H2l = H2.low;
- var H3h = H3.high;
- var H3l = H3.low;
- var H4h = H4.high;
- var H4l = H4.low;
- var H5h = H5.high;
- var H5l = H5.low;
- var H6h = H6.high;
- var H6l = H6.low;
- var H7h = H7.high;
- var H7l = H7.low;
- // Working variables
- var ah = H0h;
- var al = H0l;
- var bh = H1h;
- var bl = H1l;
- var ch = H2h;
- var cl = H2l;
- var dh = H3h;
- var dl = H3l;
- var eh = H4h;
- var el = H4l;
- var fh = H5h;
- var fl = H5l;
- var gh = H6h;
- var gl = H6l;
- var hh = H7h;
- var hl = H7l;
- // Rounds
- for (var i = 0; i < 80; i++) {
- // Shortcut
- var Wi = W[i];
- // Extend message
- if (i < 16) {
- var Wih = Wi.high = M[offset + i * 2] | 0;
- var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
- } else {
- // Gamma0
- var gamma0x = W[i - 15];
- var gamma0xh = gamma0x.high;
- var gamma0xl = gamma0x.low;
- var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
- var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
- // Gamma1
- var gamma1x = W[i - 2];
- var gamma1xh = gamma1x.high;
- var gamma1xl = gamma1x.low;
- var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
- var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
- // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
- var Wi7 = W[i - 7];
- var Wi7h = Wi7.high;
- var Wi7l = Wi7.low;
- var Wi16 = W[i - 16];
- var Wi16h = Wi16.high;
- var Wi16l = Wi16.low;
- var Wil = gamma0l + Wi7l;
- var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
- var Wil = Wil + gamma1l;
- var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
- var Wil = Wil + Wi16l;
- var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
- Wi.high = Wih;
- Wi.low = Wil;
- }
- var chh = (eh & fh) ^ (~eh & gh);
- var chl = (el & fl) ^ (~el & gl);
- var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
- var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
- var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
- var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
- var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
- var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
- // t1 = h + sigma1 + ch + K[i] + W[i]
- var Ki = K[i];
- var Kih = Ki.high;
- var Kil = Ki.low;
- var t1l = hl + sigma1l;
- var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
- var t1l = t1l + chl;
- var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
- var t1l = t1l + Kil;
- var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
- var t1l = t1l + Wil;
- var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
- // t2 = sigma0 + maj
- var t2l = sigma0l + majl;
- var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
- // Update working variables
- hh = gh;
- hl = gl;
- gh = fh;
- gl = fl;
- fh = eh;
- fl = el;
- el = (dl + t1l) | 0;
- eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
- dh = ch;
- dl = cl;
- ch = bh;
- cl = bl;
- bh = ah;
- bl = al;
- al = (t1l + t2l) | 0;
- ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
- }
- // Intermediate hash value
- H0l = H0.low = (H0l + al);
- H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
- H1l = H1.low = (H1l + bl);
- H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
- H2l = H2.low = (H2l + cl);
- H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
- H3l = H3.low = (H3l + dl);
- H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
- H4l = H4.low = (H4l + el);
- H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
- H5l = H5.low = (H5l + fl);
- H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
- H6l = H6.low = (H6l + gl);
- H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
- H7l = H7.low = (H7l + hl);
- H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
- },
- _doFinalize: function () {
- // Shortcuts
- var data = this._data;
- var dataWords = data.words;
- var nBitsTotal = this._nDataBytes * 8;
- var nBitsLeft = data.sigBytes * 8;
- // Add padding
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
- dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
- dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
- data.sigBytes = dataWords.length * 4;
- // Hash final blocks
- this._process();
- // Convert hash to 32-bit word array before returning
- var hash = this._hash.toX32();
- // Return final computed hash
- return hash;
- },
- clone: function () {
- var clone = Hasher.clone.call(this);
- clone._hash = this._hash.clone();
- return clone;
- },
- blockSize: 1024/32
- });
- /**
- * Shortcut function to the hasher's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- *
- * @return {WordArray} The hash.
- *
- * @static
- *
- * @example
- *
- * var hash = CryptoJS.SHA512('message');
- * var hash = CryptoJS.SHA512(wordArray);
- */
- C.SHA512 = Hasher._createHelper(SHA512);
- /**
- * Shortcut function to the HMAC's object interface.
- *
- * @param {WordArray|string} message The message to hash.
- * @param {WordArray|string} key The secret key.
- *
- * @return {WordArray} The HMAC.
- *
- * @static
- *
- * @example
- *
- * var hmac = CryptoJS.HmacSHA512(message, key);
- */
- C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
- }());
- return CryptoJS.SHA512;
- }));
- },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
- ;(function (root, factory, undef) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function () {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var WordArray = C_lib.WordArray;
- var BlockCipher = C_lib.BlockCipher;
- var C_algo = C.algo;
- // Permuted Choice 1 constants
- var PC1 = [
- 57, 49, 41, 33, 25, 17, 9, 1,
- 58, 50, 42, 34, 26, 18, 10, 2,
- 59, 51, 43, 35, 27, 19, 11, 3,
- 60, 52, 44, 36, 63, 55, 47, 39,
- 31, 23, 15, 7, 62, 54, 46, 38,
- 30, 22, 14, 6, 61, 53, 45, 37,
- 29, 21, 13, 5, 28, 20, 12, 4
- ];
- // Permuted Choice 2 constants
- var PC2 = [
- 14, 17, 11, 24, 1, 5,
- 3, 28, 15, 6, 21, 10,
- 23, 19, 12, 4, 26, 8,
- 16, 7, 27, 20, 13, 2,
- 41, 52, 31, 37, 47, 55,
- 30, 40, 51, 45, 33, 48,
- 44, 49, 39, 56, 34, 53,
- 46, 42, 50, 36, 29, 32
- ];
- // Cumulative bit shift constants
- var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
- // SBOXes and round permutation constants
- var SBOX_P = [
- {
- 0x0: 0x808200,
- 0x10000000: 0x8000,
- 0x20000000: 0x808002,
- 0x30000000: 0x2,
- 0x40000000: 0x200,
- 0x50000000: 0x808202,
- 0x60000000: 0x800202,
- 0x70000000: 0x800000,
- 0x80000000: 0x202,
- 0x90000000: 0x800200,
- 0xa0000000: 0x8200,
- 0xb0000000: 0x808000,
- 0xc0000000: 0x8002,
- 0xd0000000: 0x800002,
- 0xe0000000: 0x0,
- 0xf0000000: 0x8202,
- 0x8000000: 0x0,
- 0x18000000: 0x808202,
- 0x28000000: 0x8202,
- 0x38000000: 0x8000,
- 0x48000000: 0x808200,
- 0x58000000: 0x200,
- 0x68000000: 0x808002,
- 0x78000000: 0x2,
- 0x88000000: 0x800200,
- 0x98000000: 0x8200,
- 0xa8000000: 0x808000,
- 0xb8000000: 0x800202,
- 0xc8000000: 0x800002,
- 0xd8000000: 0x8002,
- 0xe8000000: 0x202,
- 0xf8000000: 0x800000,
- 0x1: 0x8000,
- 0x10000001: 0x2,
- 0x20000001: 0x808200,
- 0x30000001: 0x800000,
- 0x40000001: 0x808002,
- 0x50000001: 0x8200,
- 0x60000001: 0x200,
- 0x70000001: 0x800202,
- 0x80000001: 0x808202,
- 0x90000001: 0x808000,
- 0xa0000001: 0x800002,
- 0xb0000001: 0x8202,
- 0xc0000001: 0x202,
- 0xd0000001: 0x800200,
- 0xe0000001: 0x8002,
- 0xf0000001: 0x0,
- 0x8000001: 0x808202,
- 0x18000001: 0x808000,
- 0x28000001: 0x800000,
- 0x38000001: 0x200,
- 0x48000001: 0x8000,
- 0x58000001: 0x800002,
- 0x68000001: 0x2,
- 0x78000001: 0x8202,
- 0x88000001: 0x8002,
- 0x98000001: 0x800202,
- 0xa8000001: 0x202,
- 0xb8000001: 0x808200,
- 0xc8000001: 0x800200,
- 0xd8000001: 0x0,
- 0xe8000001: 0x8200,
- 0xf8000001: 0x808002
- },
- {
- 0x0: 0x40084010,
- 0x1000000: 0x4000,
- 0x2000000: 0x80000,
- 0x3000000: 0x40080010,
- 0x4000000: 0x40000010,
- 0x5000000: 0x40084000,
- 0x6000000: 0x40004000,
- 0x7000000: 0x10,
- 0x8000000: 0x84000,
- 0x9000000: 0x40004010,
- 0xa000000: 0x40000000,
- 0xb000000: 0x84010,
- 0xc000000: 0x80010,
- 0xd000000: 0x0,
- 0xe000000: 0x4010,
- 0xf000000: 0x40080000,
- 0x800000: 0x40004000,
- 0x1800000: 0x84010,
- 0x2800000: 0x10,
- 0x3800000: 0x40004010,
- 0x4800000: 0x40084010,
- 0x5800000: 0x40000000,
- 0x6800000: 0x80000,
- 0x7800000: 0x40080010,
- 0x8800000: 0x80010,
- 0x9800000: 0x0,
- 0xa800000: 0x4000,
- 0xb800000: 0x40080000,
- 0xc800000: 0x40000010,
- 0xd800000: 0x84000,
- 0xe800000: 0x40084000,
- 0xf800000: 0x4010,
- 0x10000000: 0x0,
- 0x11000000: 0x40080010,
- 0x12000000: 0x40004010,
- 0x13000000: 0x40084000,
- 0x14000000: 0x40080000,
- 0x15000000: 0x10,
- 0x16000000: 0x84010,
- 0x17000000: 0x4000,
- 0x18000000: 0x4010,
- 0x19000000: 0x80000,
- 0x1a000000: 0x80010,
- 0x1b000000: 0x40000010,
- 0x1c000000: 0x84000,
- 0x1d000000: 0x40004000,
- 0x1e000000: 0x40000000,
- 0x1f000000: 0x40084010,
- 0x10800000: 0x84010,
- 0x11800000: 0x80000,
- 0x12800000: 0x40080000,
- 0x13800000: 0x4000,
- 0x14800000: 0x40004000,
- 0x15800000: 0x40084010,
- 0x16800000: 0x10,
- 0x17800000: 0x40000000,
- 0x18800000: 0x40084000,
- 0x19800000: 0x40000010,
- 0x1a800000: 0x40004010,
- 0x1b800000: 0x80010,
- 0x1c800000: 0x0,
- 0x1d800000: 0x4010,
- 0x1e800000: 0x40080010,
- 0x1f800000: 0x84000
- },
- {
- 0x0: 0x104,
- 0x100000: 0x0,
- 0x200000: 0x4000100,
- 0x300000: 0x10104,
- 0x400000: 0x10004,
- 0x500000: 0x4000004,
- 0x600000: 0x4010104,
- 0x700000: 0x4010000,
- 0x800000: 0x4000000,
- 0x900000: 0x4010100,
- 0xa00000: 0x10100,
- 0xb00000: 0x4010004,
- 0xc00000: 0x4000104,
- 0xd00000: 0x10000,
- 0xe00000: 0x4,
- 0xf00000: 0x100,
- 0x80000: 0x4010100,
- 0x180000: 0x4010004,
- 0x280000: 0x0,
- 0x380000: 0x4000100,
- 0x480000: 0x4000004,
- 0x580000: 0x10000,
- 0x680000: 0x10004,
- 0x780000: 0x104,
- 0x880000: 0x4,
- 0x980000: 0x100,
- 0xa80000: 0x4010000,
- 0xb80000: 0x10104,
- 0xc80000: 0x10100,
- 0xd80000: 0x4000104,
- 0xe80000: 0x4010104,
- 0xf80000: 0x4000000,
- 0x1000000: 0x4010100,
- 0x1100000: 0x10004,
- 0x1200000: 0x10000,
- 0x1300000: 0x4000100,
- 0x1400000: 0x100,
- 0x1500000: 0x4010104,
- 0x1600000: 0x4000004,
- 0x1700000: 0x0,
- 0x1800000: 0x4000104,
- 0x1900000: 0x4000000,
- 0x1a00000: 0x4,
- 0x1b00000: 0x10100,
- 0x1c00000: 0x4010000,
- 0x1d00000: 0x104,
- 0x1e00000: 0x10104,
- 0x1f00000: 0x4010004,
- 0x1080000: 0x4000000,
- 0x1180000: 0x104,
- 0x1280000: 0x4010100,
- 0x1380000: 0x0,
- 0x1480000: 0x10004,
- 0x1580000: 0x4000100,
- 0x1680000: 0x100,
- 0x1780000: 0x4010004,
- 0x1880000: 0x10000,
- 0x1980000: 0x4010104,
- 0x1a80000: 0x10104,
- 0x1b80000: 0x4000004,
- 0x1c80000: 0x4000104,
- 0x1d80000: 0x4010000,
- 0x1e80000: 0x4,
- 0x1f80000: 0x10100
- },
- {
- 0x0: 0x80401000,
- 0x10000: 0x80001040,
- 0x20000: 0x401040,
- 0x30000: 0x80400000,
- 0x40000: 0x0,
- 0x50000: 0x401000,
- 0x60000: 0x80000040,
- 0x70000: 0x400040,
- 0x80000: 0x80000000,
- 0x90000: 0x400000,
- 0xa0000: 0x40,
- 0xb0000: 0x80001000,
- 0xc0000: 0x80400040,
- 0xd0000: 0x1040,
- 0xe0000: 0x1000,
- 0xf0000: 0x80401040,
- 0x8000: 0x80001040,
- 0x18000: 0x40,
- 0x28000: 0x80400040,
- 0x38000: 0x80001000,
- 0x48000: 0x401000,
- 0x58000: 0x80401040,
- 0x68000: 0x0,
- 0x78000: 0x80400000,
- 0x88000: 0x1000,
- 0x98000: 0x80401000,
- 0xa8000: 0x400000,
- 0xb8000: 0x1040,
- 0xc8000: 0x80000000,
- 0xd8000: 0x400040,
- 0xe8000: 0x401040,
- 0xf8000: 0x80000040,
- 0x100000: 0x400040,
- 0x110000: 0x401000,
- 0x120000: 0x80000040,
- 0x130000: 0x0,
- 0x140000: 0x1040,
- 0x150000: 0x80400040,
- 0x160000: 0x80401000,
- 0x170000: 0x80001040,
- 0x180000: 0x80401040,
- 0x190000: 0x80000000,
- 0x1a0000: 0x80400000,
- 0x1b0000: 0x401040,
- 0x1c0000: 0x80001000,
- 0x1d0000: 0x400000,
- 0x1e0000: 0x40,
- 0x1f0000: 0x1000,
- 0x108000: 0x80400000,
- 0x118000: 0x80401040,
- 0x128000: 0x0,
- 0x138000: 0x401000,
- 0x148000: 0x400040,
- 0x158000: 0x80000000,
- 0x168000: 0x80001040,
- 0x178000: 0x40,
- 0x188000: 0x80000040,
- 0x198000: 0x1000,
- 0x1a8000: 0x80001000,
- 0x1b8000: 0x80400040,
- 0x1c8000: 0x1040,
- 0x1d8000: 0x80401000,
- 0x1e8000: 0x400000,
- 0x1f8000: 0x401040
- },
- {
- 0x0: 0x80,
- 0x1000: 0x1040000,
- 0x2000: 0x40000,
- 0x3000: 0x20000000,
- 0x4000: 0x20040080,
- 0x5000: 0x1000080,
- 0x6000: 0x21000080,
- 0x7000: 0x40080,
- 0x8000: 0x1000000,
- 0x9000: 0x20040000,
- 0xa000: 0x20000080,
- 0xb000: 0x21040080,
- 0xc000: 0x21040000,
- 0xd000: 0x0,
- 0xe000: 0x1040080,
- 0xf000: 0x21000000,
- 0x800: 0x1040080,
- 0x1800: 0x21000080,
- 0x2800: 0x80,
- 0x3800: 0x1040000,
- 0x4800: 0x40000,
- 0x5800: 0x20040080,
- 0x6800: 0x21040000,
- 0x7800: 0x20000000,
- 0x8800: 0x20040000,
- 0x9800: 0x0,
- 0xa800: 0x21040080,
- 0xb800: 0x1000080,
- 0xc800: 0x20000080,
- 0xd800: 0x21000000,
- 0xe800: 0x1000000,
- 0xf800: 0x40080,
- 0x10000: 0x40000,
- 0x11000: 0x80,
- 0x12000: 0x20000000,
- 0x13000: 0x21000080,
- 0x14000: 0x1000080,
- 0x15000: 0x21040000,
- 0x16000: 0x20040080,
- 0x17000: 0x1000000,
- 0x18000: 0x21040080,
- 0x19000: 0x21000000,
- 0x1a000: 0x1040000,
- 0x1b000: 0x20040000,
- 0x1c000: 0x40080,
- 0x1d000: 0x20000080,
- 0x1e000: 0x0,
- 0x1f000: 0x1040080,
- 0x10800: 0x21000080,
- 0x11800: 0x1000000,
- 0x12800: 0x1040000,
- 0x13800: 0x20040080,
- 0x14800: 0x20000000,
- 0x15800: 0x1040080,
- 0x16800: 0x80,
- 0x17800: 0x21040000,
- 0x18800: 0x40080,
- 0x19800: 0x21040080,
- 0x1a800: 0x0,
- 0x1b800: 0x21000000,
- 0x1c800: 0x1000080,
- 0x1d800: 0x40000,
- 0x1e800: 0x20040000,
- 0x1f800: 0x20000080
- },
- {
- 0x0: 0x10000008,
- 0x100: 0x2000,
- 0x200: 0x10200000,
- 0x300: 0x10202008,
- 0x400: 0x10002000,
- 0x500: 0x200000,
- 0x600: 0x200008,
- 0x700: 0x10000000,
- 0x800: 0x0,
- 0x900: 0x10002008,
- 0xa00: 0x202000,
- 0xb00: 0x8,
- 0xc00: 0x10200008,
- 0xd00: 0x202008,
- 0xe00: 0x2008,
- 0xf00: 0x10202000,
- 0x80: 0x10200000,
- 0x180: 0x10202008,
- 0x280: 0x8,
- 0x380: 0x200000,
- 0x480: 0x202008,
- 0x580: 0x10000008,
- 0x680: 0x10002000,
- 0x780: 0x2008,
- 0x880: 0x200008,
- 0x980: 0x2000,
- 0xa80: 0x10002008,
- 0xb80: 0x10200008,
- 0xc80: 0x0,
- 0xd80: 0x10202000,
- 0xe80: 0x202000,
- 0xf80: 0x10000000,
- 0x1000: 0x10002000,
- 0x1100: 0x10200008,
- 0x1200: 0x10202008,
- 0x1300: 0x2008,
- 0x1400: 0x200000,
- 0x1500: 0x10000000,
- 0x1600: 0x10000008,
- 0x1700: 0x202000,
- 0x1800: 0x202008,
- 0x1900: 0x0,
- 0x1a00: 0x8,
- 0x1b00: 0x10200000,
- 0x1c00: 0x2000,
- 0x1d00: 0x10002008,
- 0x1e00: 0x10202000,
- 0x1f00: 0x200008,
- 0x1080: 0x8,
- 0x1180: 0x202000,
- 0x1280: 0x200000,
- 0x1380: 0x10000008,
- 0x1480: 0x10002000,
- 0x1580: 0x2008,
- 0x1680: 0x10202008,
- 0x1780: 0x10200000,
- 0x1880: 0x10202000,
- 0x1980: 0x10200008,
- 0x1a80: 0x2000,
- 0x1b80: 0x202008,
- 0x1c80: 0x200008,
- 0x1d80: 0x0,
- 0x1e80: 0x10000000,
- 0x1f80: 0x10002008
- },
- {
- 0x0: 0x100000,
- 0x10: 0x2000401,
- 0x20: 0x400,
- 0x30: 0x100401,
- 0x40: 0x2100401,
- 0x50: 0x0,
- 0x60: 0x1,
- 0x70: 0x2100001,
- 0x80: 0x2000400,
- 0x90: 0x100001,
- 0xa0: 0x2000001,
- 0xb0: 0x2100400,
- 0xc0: 0x2100000,
- 0xd0: 0x401,
- 0xe0: 0x100400,
- 0xf0: 0x2000000,
- 0x8: 0x2100001,
- 0x18: 0x0,
- 0x28: 0x2000401,
- 0x38: 0x2100400,
- 0x48: 0x100000,
- 0x58: 0x2000001,
- 0x68: 0x2000000,
- 0x78: 0x401,
- 0x88: 0x100401,
- 0x98: 0x2000400,
- 0xa8: 0x2100000,
- 0xb8: 0x100001,
- 0xc8: 0x400,
- 0xd8: 0x2100401,
- 0xe8: 0x1,
- 0xf8: 0x100400,
- 0x100: 0x2000000,
- 0x110: 0x100000,
- 0x120: 0x2000401,
- 0x130: 0x2100001,
- 0x140: 0x100001,
- 0x150: 0x2000400,
- 0x160: 0x2100400,
- 0x170: 0x100401,
- 0x180: 0x401,
- 0x190: 0x2100401,
- 0x1a0: 0x100400,
- 0x1b0: 0x1,
- 0x1c0: 0x0,
- 0x1d0: 0x2100000,
- 0x1e0: 0x2000001,
- 0x1f0: 0x400,
- 0x108: 0x100400,
- 0x118: 0x2000401,
- 0x128: 0x2100001,
- 0x138: 0x1,
- 0x148: 0x2000000,
- 0x158: 0x100000,
- 0x168: 0x401,
- 0x178: 0x2100400,
- 0x188: 0x2000001,
- 0x198: 0x2100000,
- 0x1a8: 0x0,
- 0x1b8: 0x2100401,
- 0x1c8: 0x100401,
- 0x1d8: 0x400,
- 0x1e8: 0x2000400,
- 0x1f8: 0x100001
- },
- {
- 0x0: 0x8000820,
- 0x1: 0x20000,
- 0x2: 0x8000000,
- 0x3: 0x20,
- 0x4: 0x20020,
- 0x5: 0x8020820,
- 0x6: 0x8020800,
- 0x7: 0x800,
- 0x8: 0x8020000,
- 0x9: 0x8000800,
- 0xa: 0x20800,
- 0xb: 0x8020020,
- 0xc: 0x820,
- 0xd: 0x0,
- 0xe: 0x8000020,
- 0xf: 0x20820,
- 0x80000000: 0x800,
- 0x80000001: 0x8020820,
- 0x80000002: 0x8000820,
- 0x80000003: 0x8000000,
- 0x80000004: 0x8020000,
- 0x80000005: 0x20800,
- 0x80000006: 0x20820,
- 0x80000007: 0x20,
- 0x80000008: 0x8000020,
- 0x80000009: 0x820,
- 0x8000000a: 0x20020,
- 0x8000000b: 0x8020800,
- 0x8000000c: 0x0,
- 0x8000000d: 0x8020020,
- 0x8000000e: 0x8000800,
- 0x8000000f: 0x20000,
- 0x10: 0x20820,
- 0x11: 0x8020800,
- 0x12: 0x20,
- 0x13: 0x800,
- 0x14: 0x8000800,
- 0x15: 0x8000020,
- 0x16: 0x8020020,
- 0x17: 0x20000,
- 0x18: 0x0,
- 0x19: 0x20020,
- 0x1a: 0x8020000,
- 0x1b: 0x8000820,
- 0x1c: 0x8020820,
- 0x1d: 0x20800,
- 0x1e: 0x820,
- 0x1f: 0x8000000,
- 0x80000010: 0x20000,
- 0x80000011: 0x800,
- 0x80000012: 0x8020020,
- 0x80000013: 0x20820,
- 0x80000014: 0x20,
- 0x80000015: 0x8020000,
- 0x80000016: 0x8000000,
- 0x80000017: 0x8000820,
- 0x80000018: 0x8020820,
- 0x80000019: 0x8000020,
- 0x8000001a: 0x8000800,
- 0x8000001b: 0x0,
- 0x8000001c: 0x20800,
- 0x8000001d: 0x820,
- 0x8000001e: 0x20020,
- 0x8000001f: 0x8020800
- }
- ];
- // Masks that select the SBOX input
- var SBOX_MASK = [
- 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
- 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
- ];
- /**
- * DES block cipher algorithm.
- */
- var DES = C_algo.DES = BlockCipher.extend({
- _doReset: function () {
- // Shortcuts
- var key = this._key;
- var keyWords = key.words;
- // Select 56 bits according to PC1
- var keyBits = [];
- for (var i = 0; i < 56; i++) {
- var keyBitPos = PC1[i] - 1;
- keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
- }
- // Assemble 16 subkeys
- var subKeys = this._subKeys = [];
- for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
- // Create subkey
- var subKey = subKeys[nSubKey] = [];
- // Shortcut
- var bitShift = BIT_SHIFTS[nSubKey];
- // Select 48 bits according to PC2
- for (var i = 0; i < 24; i++) {
- // Select from the left 28 key bits
- subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
- // Select from the right 28 key bits
- subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
- }
- // Since each subkey is applied to an expanded 32-bit input,
- // the subkey can be broken into 8 values scaled to 32-bits,
- // which allows the key to be used without expansion
- subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
- for (var i = 1; i < 7; i++) {
- subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
- }
- subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
- }
- // Compute inverse subkeys
- var invSubKeys = this._invSubKeys = [];
- for (var i = 0; i < 16; i++) {
- invSubKeys[i] = subKeys[15 - i];
- }
- },
- encryptBlock: function (M, offset) {
- this._doCryptBlock(M, offset, this._subKeys);
- },
- decryptBlock: function (M, offset) {
- this._doCryptBlock(M, offset, this._invSubKeys);
- },
- _doCryptBlock: function (M, offset, subKeys) {
- // Get input
- this._lBlock = M[offset];
- this._rBlock = M[offset + 1];
- // Initial permutation
- exchangeLR.call(this, 4, 0x0f0f0f0f);
- exchangeLR.call(this, 16, 0x0000ffff);
- exchangeRL.call(this, 2, 0x33333333);
- exchangeRL.call(this, 8, 0x00ff00ff);
- exchangeLR.call(this, 1, 0x55555555);
- // Rounds
- for (var round = 0; round < 16; round++) {
- // Shortcuts
- var subKey = subKeys[round];
- var lBlock = this._lBlock;
- var rBlock = this._rBlock;
- // Feistel function
- var f = 0;
- for (var i = 0; i < 8; i++) {
- f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
- }
- this._lBlock = rBlock;
- this._rBlock = lBlock ^ f;
- }
- // Undo swap from last round
- var t = this._lBlock;
- this._lBlock = this._rBlock;
- this._rBlock = t;
- // Final permutation
- exchangeLR.call(this, 1, 0x55555555);
- exchangeRL.call(this, 8, 0x00ff00ff);
- exchangeRL.call(this, 2, 0x33333333);
- exchangeLR.call(this, 16, 0x0000ffff);
- exchangeLR.call(this, 4, 0x0f0f0f0f);
- // Set output
- M[offset] = this._lBlock;
- M[offset + 1] = this._rBlock;
- },
- keySize: 64/32,
- ivSize: 64/32,
- blockSize: 64/32
- });
- // Swap bits across the left and right words
- function exchangeLR(offset, mask) {
- var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
- this._rBlock ^= t;
- this._lBlock ^= t << offset;
- }
- function exchangeRL(offset, mask) {
- var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
- this._lBlock ^= t;
- this._rBlock ^= t << offset;
- }
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
- */
- C.DES = BlockCipher._createHelper(DES);
- /**
- * Triple-DES block cipher algorithm.
- */
- var TripleDES = C_algo.TripleDES = BlockCipher.extend({
- _doReset: function () {
- // Shortcuts
- var key = this._key;
- var keyWords = key.words;
- // Create DES instances
- this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
- this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
- this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
- },
- encryptBlock: function (M, offset) {
- this._des1.encryptBlock(M, offset);
- this._des2.decryptBlock(M, offset);
- this._des3.encryptBlock(M, offset);
- },
- decryptBlock: function (M, offset) {
- this._des3.decryptBlock(M, offset);
- this._des2.encryptBlock(M, offset);
- this._des1.decryptBlock(M, offset);
- },
- keySize: 192/32,
- ivSize: 64/32,
- blockSize: 64/32
- });
- /**
- * Shortcut functions to the cipher's object interface.
- *
- * @example
- *
- * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
- * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
- */
- C.TripleDES = BlockCipher._createHelper(TripleDES);
- }());
- return CryptoJS.TripleDES;
- }));
- },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
- ;(function (root, factory) {
- if (typeof exports === "object") {
- // CommonJS
- module.exports = exports = factory(require("./core"));
- }
- else if (typeof define === "function" && define.amd) {
- // AMD
- define(["./core"], factory);
- }
- else {
- // Global (browser)
- factory(root.CryptoJS);
- }
- }(this, function (CryptoJS) {
- (function (undefined) {
- // Shortcuts
- var C = CryptoJS;
- var C_lib = C.lib;
- var Base = C_lib.Base;
- var X32WordArray = C_lib.WordArray;
- /**
- * x64 namespace.
- */
- var C_x64 = C.x64 = {};
- /**
- * A 64-bit word.
- */
- var X64Word = C_x64.Word = Base.extend({
- /**
- * Initializes a newly created 64-bit word.
- *
- * @param {number} high The high 32 bits.
- * @param {number} low The low 32 bits.
- *
- * @example
- *
- * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
- */
- init: function (high, low) {
- this.high = high;
- this.low = low;
- }
- /**
- * Bitwise NOTs this word.
- *
- * @return {X64Word} A new x64-Word object after negating.
- *
- * @example
- *
- * var negated = x64Word.not();
- */
- // not: function () {
- // var high = ~this.high;
- // var low = ~this.low;
- // return X64Word.create(high, low);
- // },
- /**
- * Bitwise ANDs this word with the passed word.
- *
- * @param {X64Word} word The x64-Word to AND with this word.
- *
- * @return {X64Word} A new x64-Word object after ANDing.
- *
- * @example
- *
- * var anded = x64Word.and(anotherX64Word);
- */
- // and: function (word) {
- // var high = this.high & word.high;
- // var low = this.low & word.low;
- // return X64Word.create(high, low);
- // },
- /**
- * Bitwise ORs this word with the passed word.
- *
- * @param {X64Word} word The x64-Word to OR with this word.
- *
- * @return {X64Word} A new x64-Word object after ORing.
- *
- * @example
- *
- * var ored = x64Word.or(anotherX64Word);
- */
- // or: function (word) {
- // var high = this.high | word.high;
- // var low = this.low | word.low;
- // return X64Word.create(high, low);
- // },
- /**
- * Bitwise XORs this word with the passed word.
- *
- * @param {X64Word} word The x64-Word to XOR with this word.
- *
- * @return {X64Word} A new x64-Word object after XORing.
- *
- * @example
- *
- * var xored = x64Word.xor(anotherX64Word);
- */
- // xor: function (word) {
- // var high = this.high ^ word.high;
- // var low = this.low ^ word.low;
- // return X64Word.create(high, low);
- // },
- /**
- * Shifts this word n bits to the left.
- *
- * @param {number} n The number of bits to shift.
- *
- * @return {X64Word} A new x64-Word object after shifting.
- *
- * @example
- *
- * var shifted = x64Word.shiftL(25);
- */
- // shiftL: function (n) {
- // if (n < 32) {
- // var high = (this.high << n) | (this.low >>> (32 - n));
- // var low = this.low << n;
- // } else {
- // var high = this.low << (n - 32);
- // var low = 0;
- // }
- // return X64Word.create(high, low);
- // },
- /**
- * Shifts this word n bits to the right.
- *
- * @param {number} n The number of bits to shift.
- *
- * @return {X64Word} A new x64-Word object after shifting.
- *
- * @example
- *
- * var shifted = x64Word.shiftR(7);
- */
- // shiftR: function (n) {
- // if (n < 32) {
- // var low = (this.low >>> n) | (this.high << (32 - n));
- // var high = this.high >>> n;
- // } else {
- // var low = this.high >>> (n - 32);
- // var high = 0;
- // }
- // return X64Word.create(high, low);
- // },
- /**
- * Rotates this word n bits to the left.
- *
- * @param {number} n The number of bits to rotate.
- *
- * @return {X64Word} A new x64-Word object after rotating.
- *
- * @example
- *
- * var rotated = x64Word.rotL(25);
- */
- // rotL: function (n) {
- // return this.shiftL(n).or(this.shiftR(64 - n));
- // },
- /**
- * Rotates this word n bits to the right.
- *
- * @param {number} n The number of bits to rotate.
- *
- * @return {X64Word} A new x64-Word object after rotating.
- *
- * @example
- *
- * var rotated = x64Word.rotR(7);
- */
- // rotR: function (n) {
- // return this.shiftR(n).or(this.shiftL(64 - n));
- // },
- /**
- * Adds this word with the passed word.
- *
- * @param {X64Word} word The x64-Word to add with this word.
- *
- * @return {X64Word} A new x64-Word object after adding.
- *
- * @example
- *
- * var added = x64Word.add(anotherX64Word);
- */
- // add: function (word) {
- // var low = (this.low + word.low) | 0;
- // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
- // var high = (this.high + word.high + carry) | 0;
- // return X64Word.create(high, low);
- // }
- });
- /**
- * An array of 64-bit words.
- *
- * @property {Array} words The array of CryptoJS.x64.Word objects.
- * @property {number} sigBytes The number of significant bytes in this word array.
- */
- var X64WordArray = C_x64.WordArray = Base.extend({
- /**
- * Initializes a newly created word array.
- *
- * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
- *
- * @example
- *
- * var wordArray = CryptoJS.x64.WordArray.create();
- *
- * var wordArray = CryptoJS.x64.WordArray.create([
- * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
- * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
- * ]);
- *
- * var wordArray = CryptoJS.x64.WordArray.create([
- * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
- * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
- * ], 10);
- */
- init: function (words, sigBytes) {
- words = this.words = words || [];
- if (sigBytes != undefined) {
- this.sigBytes = sigBytes;
- } else {
- this.sigBytes = words.length * 8;
- }
- },
- /**
- * Converts this 64-bit word array to a 32-bit word array.
- *
- * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
- *
- * @example
- *
- * var x32WordArray = x64WordArray.toX32();
- */
- toX32: function () {
- // Shortcuts
- var x64Words = this.words;
- var x64WordsLength = x64Words.length;
- // Convert
- var x32Words = [];
- for (var i = 0; i < x64WordsLength; i++) {
- var x64Word = x64Words[i];
- x32Words.push(x64Word.high);
- x32Words.push(x64Word.low);
- }
- return X32WordArray.create(x32Words, this.sigBytes);
- },
- /**
- * Creates a copy of this word array.
- *
- * @return {X64WordArray} The clone.
- *
- * @example
- *
- * var clone = x64WordArray.clone();
- */
- clone: function () {
- var clone = Base.clone.call(this);
- // Clone "words" array
- var words = clone.words = this.words.slice(0);
- // Clone each X64Word object
- var wordsLength = words.length;
- for (var i = 0; i < wordsLength; i++) {
- words[i] = words[i].clone();
- }
- return clone;
- }
- });
- }());
- return CryptoJS;
- }));
- },{"./core":53}],85:[function(require,module,exports){
- /*! https://mths.be/utf8js v2.1.2 by @mathias */
- ;(function(root) {
- // Detect free variables `exports`
- var freeExports = typeof exports == 'object' && exports;
- // Detect free variable `module`
- var freeModule = typeof module == 'object' && module &&
- module.exports == freeExports && module;
- // Detect free variable `global`, from Node.js or Browserified code,
- // and use it as `root`
- var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
- root = freeGlobal;
- }
- /*--------------------------------------------------------------------------*/
- var stringFromCharCode = String.fromCharCode;
- // Taken from https://mths.be/punycode
- function ucs2decode(string) {
- var output = [];
- var counter = 0;
- var length = string.length;
- var value;
- var extra;
- while (counter < length) {
- value = string.charCodeAt(counter++);
- if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
- // high surrogate, and there is a next character
- extra = string.charCodeAt(counter++);
- if ((extra & 0xFC00) == 0xDC00) { // low surrogate
- output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
- } else {
- // unmatched surrogate; only append this code unit, in case the next
- // code unit is the high surrogate of a surrogate pair
- output.push(value);
- counter--;
- }
- } else {
- output.push(value);
- }
- }
- return output;
- }
- // Taken from https://mths.be/punycode
- function ucs2encode(array) {
- var length = array.length;
- var index = -1;
- var value;
- var output = '';
- while (++index < length) {
- value = array[index];
- if (value > 0xFFFF) {
- value -= 0x10000;
- output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
- value = 0xDC00 | value & 0x3FF;
- }
- output += stringFromCharCode(value);
- }
- return output;
- }
- function checkScalarValue(codePoint) {
- if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
- throw Error(
- 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
- ' is not a scalar value'
- );
- }
- }
- /*--------------------------------------------------------------------------*/
- function createByte(codePoint, shift) {
- return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
- }
- function encodeCodePoint(codePoint) {
- if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
- return stringFromCharCode(codePoint);
- }
- var symbol = '';
- if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
- symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
- }
- else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
- checkScalarValue(codePoint);
- symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
- symbol += createByte(codePoint, 6);
- }
- else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
- symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
- symbol += createByte(codePoint, 12);
- symbol += createByte(codePoint, 6);
- }
- symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
- return symbol;
- }
- function utf8encode(string) {
- var codePoints = ucs2decode(string);
- var length = codePoints.length;
- var index = -1;
- var codePoint;
- var byteString = '';
- while (++index < length) {
- codePoint = codePoints[index];
- byteString += encodeCodePoint(codePoint);
- }
- return byteString;
- }
- /*--------------------------------------------------------------------------*/
- function readContinuationByte() {
- if (byteIndex >= byteCount) {
- throw Error('Invalid byte index');
- }
- var continuationByte = byteArray[byteIndex] & 0xFF;
- byteIndex++;
- if ((continuationByte & 0xC0) == 0x80) {
- return continuationByte & 0x3F;
- }
- // If we end up here, it’s not a continuation byte
- throw Error('Invalid continuation byte');
- }
- function decodeSymbol() {
- var byte1;
- var byte2;
- var byte3;
- var byte4;
- var codePoint;
- if (byteIndex > byteCount) {
- throw Error('Invalid byte index');
- }
- if (byteIndex == byteCount) {
- return false;
- }
- // Read first byte
- byte1 = byteArray[byteIndex] & 0xFF;
- byteIndex++;
- // 1-byte sequence (no continuation bytes)
- if ((byte1 & 0x80) == 0) {
- return byte1;
- }
- // 2-byte sequence
- if ((byte1 & 0xE0) == 0xC0) {
- byte2 = readContinuationByte();
- codePoint = ((byte1 & 0x1F) << 6) | byte2;
- if (codePoint >= 0x80) {
- return codePoint;
- } else {
- throw Error('Invalid continuation byte');
- }
- }
- // 3-byte sequence (may include unpaired surrogates)
- if ((byte1 & 0xF0) == 0xE0) {
- byte2 = readContinuationByte();
- byte3 = readContinuationByte();
- codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
- if (codePoint >= 0x0800) {
- checkScalarValue(codePoint);
- return codePoint;
- } else {
- throw Error('Invalid continuation byte');
- }
- }
- // 4-byte sequence
- if ((byte1 & 0xF8) == 0xF0) {
- byte2 = readContinuationByte();
- byte3 = readContinuationByte();
- byte4 = readContinuationByte();
- codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
- (byte3 << 0x06) | byte4;
- if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
- return codePoint;
- }
- }
- throw Error('Invalid UTF-8 detected');
- }
- var byteArray;
- var byteCount;
- var byteIndex;
- function utf8decode(byteString) {
- byteArray = ucs2decode(byteString);
- byteCount = byteArray.length;
- byteIndex = 0;
- var codePoints = [];
- var tmp;
- while ((tmp = decodeSymbol()) !== false) {
- codePoints.push(tmp);
- }
- return ucs2encode(codePoints);
- }
- /*--------------------------------------------------------------------------*/
- var utf8 = {
- 'version': '2.1.2',
- 'encode': utf8encode,
- 'decode': utf8decode
- };
- // Some AMD build optimizers, like r.js, check for specific condition patterns
- // like the following:
- if (
- typeof define == 'function' &&
- typeof define.amd == 'object' &&
- define.amd
- ) {
- define(function() {
- return utf8;
- });
- } else if (freeExports && !freeExports.nodeType) {
- if (freeModule) { // in Node.js or RingoJS v0.8.0+
- freeModule.exports = utf8;
- } else { // in Narwhal or RingoJS v0.7.0-
- var object = {};
- var hasOwnProperty = object.hasOwnProperty;
- for (var key in utf8) {
- hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
- }
- }
- } else { // in Rhino or a web browser
- root.utf8 = utf8;
- }
- }(this));
- },{}],86:[function(require,module,exports){
- module.exports = XMLHttpRequest;
- },{}],"bignumber.js":[function(require,module,exports){
- /*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
- ;(function (global) {
- 'use strict';
- /*
- bignumber.js v2.0.7
- A JavaScript library for arbitrary-precision arithmetic.
- https://github.com/MikeMcl/bignumber.js
- Copyright (c) 2015 Michael Mclaughlin <[email protected]>
- MIT Expat Licence
- */
- var BigNumber, crypto, parseNumeric,
- isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
- mathceil = Math.ceil,
- mathfloor = Math.floor,
- notBool = ' not a boolean or binary digit',
- roundingMode = 'rounding mode',
- tooManyDigits = 'number type has more than 15 significant digits',
- ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
- BASE = 1e14,
- LOG_BASE = 14,
- MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
- // MAX_INT32 = 0x7fffffff, // 2^31 - 1
- POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
- SQRT_BASE = 1e7,
- /*
- * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
- * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
- * exception is thrown (if ERRORS is true).
- */
- MAX = 1E9; // 0 to MAX_INT32
- /*
- * Create and return a BigNumber constructor.
- */
- function another(configObj) {
- var div,
- // id tracks the caller function, so its name can be included in error messages.
- id = 0,
- P = BigNumber.prototype,
- ONE = new BigNumber(1),
- /********************************* EDITABLE DEFAULTS **********************************/
- /*
- * The default values below must be integers within the inclusive ranges stated.
- * The values can also be changed at run-time using BigNumber.config.
- */
- // The maximum number of decimal places for operations involving division.
- DECIMAL_PLACES = 20, // 0 to MAX
- /*
- * The rounding mode used when rounding to the above decimal places, and when using
- * toExponential, toFixed, toFormat and toPrecision, and round (default value).
- * UP 0 Away from zero.
- * DOWN 1 Towards zero.
- * CEIL 2 Towards +Infinity.
- * FLOOR 3 Towards -Infinity.
- * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
- * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
- * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
- * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
- * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
- */
- ROUNDING_MODE = 4, // 0 to 8
- // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
- // The exponent value at and beneath which toString returns exponential notation.
- // Number type: -7
- TO_EXP_NEG = -7, // 0 to -MAX
- // The exponent value at and above which toString returns exponential notation.
- // Number type: 21
- TO_EXP_POS = 21, // 0 to MAX
- // RANGE : [MIN_EXP, MAX_EXP]
- // The minimum exponent value, beneath which underflow to zero occurs.
- // Number type: -324 (5e-324)
- MIN_EXP = -1e7, // -1 to -MAX
- // The maximum exponent value, above which overflow to Infinity occurs.
- // Number type: 308 (1.7976931348623157e+308)
- // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
- MAX_EXP = 1e7, // 1 to MAX
- // Whether BigNumber Errors are ever thrown.
- ERRORS = true, // true or false
- // Change to intValidatorNoErrors if ERRORS is false.
- isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
- // Whether to use cryptographically-secure random number generation, if available.
- CRYPTO = false, // true or false
- /*
- * The modulo mode used when calculating the modulus: a mod n.
- * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
- * The remainder (r) is calculated as: r = a - n * q.
- *
- * UP 0 The remainder is positive if the dividend is negative, else is negative.
- * DOWN 1 The remainder has the same sign as the dividend.
- * This modulo mode is commonly known as 'truncated division' and is
- * equivalent to (a % n) in JavaScript.
- * FLOOR 3 The remainder has the same sign as the divisor (Python %).
- * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
- * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
- * The remainder is always positive.
- *
- * The truncated division, floored division, Euclidian division and IEEE 754 remainder
- * modes are commonly used for the modulus operation.
- * Although the other rounding modes can also be used, they may not give useful results.
- */
- MODULO_MODE = 1, // 0 to 9
- // The maximum number of significant digits of the result of the toPower operation.
- // If POW_PRECISION is 0, there will be unlimited significant digits.
- POW_PRECISION = 100, // 0 to MAX
- // The format specification used by the BigNumber.prototype.toFormat method.
- FORMAT = {
- decimalSeparator: '.',
- groupSeparator: ',',
- groupSize: 3,
- secondaryGroupSize: 0,
- fractionGroupSeparator: '\xA0', // non-breaking space
- fractionGroupSize: 0
- };
- /******************************************************************************************/
- // CONSTRUCTOR
- /*
- * The BigNumber constructor and exported function.
- * Create and return a new instance of a BigNumber object.
- *
- * n {number|string|BigNumber} A numeric value.
- * [b] {number} The base of n. Integer, 2 to 64 inclusive.
- */
- function BigNumber( n, b ) {
- var c, e, i, num, len, str,
- x = this;
- // Enable constructor usage without new.
- if ( !( x instanceof BigNumber ) ) {
- // 'BigNumber() constructor call without new: {n}'
- if (ERRORS) raise( 26, 'constructor call without new', n );
- return new BigNumber( n, b );
- }
- // 'new BigNumber() base not an integer: {b}'
- // 'new BigNumber() base out of range: {b}'
- if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
- // Duplicate.
- if ( n instanceof BigNumber ) {
- x.s = n.s;
- x.e = n.e;
- x.c = ( n = n.c ) ? n.slice() : n;
- id = 0;
- return;
- }
- if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
- x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
- // Fast path for integers.
- if ( n === ~~n ) {
- for ( e = 0, i = n; i >= 10; i /= 10, e++ );
- x.e = e;
- x.c = [n];
- id = 0;
- return;
- }
- str = n + '';
- } else {
- if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
- x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
- }
- } else {
- b = b | 0;
- str = n + '';
- // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
- // Allow exponential notation to be used with base 10 argument.
- if ( b == 10 ) {
- x = new BigNumber( n instanceof BigNumber ? n : str );
- return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
- }
- // Avoid potential interpretation of Infinity and NaN as base 44+ values.
- // Any number in exponential form will fail due to the [Ee][+-].
- if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
- !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
- '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
- return parseNumeric( x, str, num, b );
- }
- if (num) {
- x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
- if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
- // 'new BigNumber() number type has more than 15 significant digits: {n}'
- raise( id, tooManyDigits, n );
- }
- // Prevent later check for length on converted number.
- num = false;
- } else {
- x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
- }
- str = convertBase( str, 10, b, x.s );
- }
- // Decimal point?
- if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
- // Exponential form?
- if ( ( i = str.search( /e/i ) ) > 0 ) {
- // Determine exponent.
- if ( e < 0 ) e = i;
- e += +str.slice( i + 1 );
- str = str.substring( 0, i );
- } else if ( e < 0 ) {
- // Integer.
- e = str.length;
- }
- // Determine leading zeros.
- for ( i = 0; str.charCodeAt(i) === 48; i++ );
- // Determine trailing zeros.
- for ( len = str.length; str.charCodeAt(--len) === 48; );
- str = str.slice( i, len + 1 );
- if (str) {
- len = str.length;
- // Disallow numbers with over 15 significant digits if number type.
- // 'new BigNumber() number type has more than 15 significant digits: {n}'
- if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
- e = e - i - 1;
- // Overflow?
- if ( e > MAX_EXP ) {
- // Infinity.
- x.c = x.e = null;
- // Underflow?
- } else if ( e < MIN_EXP ) {
- // Zero.
- x.c = [ x.e = 0 ];
- } else {
- x.e = e;
- x.c = [];
- // Transform base
- // e is the base 10 exponent.
- // i is where to slice str to get the first element of the coefficient array.
- i = ( e + 1 ) % LOG_BASE;
- if ( e < 0 ) i += LOG_BASE;
- if ( i < len ) {
- if (i) x.c.push( +str.slice( 0, i ) );
- for ( len -= LOG_BASE; i < len; ) {
- x.c.push( +str.slice( i, i += LOG_BASE ) );
- }
- str = str.slice(i);
- i = LOG_BASE - str.length;
- } else {
- i -= len;
- }
- for ( ; i--; str += '0' );
- x.c.push( +str );
- }
- } else {
- // Zero.
- x.c = [ x.e = 0 ];
- }
- id = 0;
- }
- // CONSTRUCTOR PROPERTIES
- BigNumber.another = another;
- BigNumber.ROUND_UP = 0;
- BigNumber.ROUND_DOWN = 1;
- BigNumber.ROUND_CEIL = 2;
- BigNumber.ROUND_FLOOR = 3;
- BigNumber.ROUND_HALF_UP = 4;
- BigNumber.ROUND_HALF_DOWN = 5;
- BigNumber.ROUND_HALF_EVEN = 6;
- BigNumber.ROUND_HALF_CEIL = 7;
- BigNumber.ROUND_HALF_FLOOR = 8;
- BigNumber.EUCLID = 9;
- /*
- * Configure infrequently-changing library-wide settings.
- *
- * Accept an object or an argument list, with one or many of the following properties or
- * parameters respectively:
- *
- * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
- * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
- * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
- * [integer -MAX to 0 incl., 0 to MAX incl.]
- * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
- * [integer -MAX to -1 incl., integer 1 to MAX incl.]
- * ERRORS {boolean|number} true, false, 1 or 0
- * CRYPTO {boolean|number} true, false, 1 or 0
- * MODULO_MODE {number} 0 to 9 inclusive
- * POW_PRECISION {number} 0 to MAX inclusive
- * FORMAT {object} See BigNumber.prototype.toFormat
- * decimalSeparator {string}
- * groupSeparator {string}
- * groupSize {number}
- * secondaryGroupSize {number}
- * fractionGroupSeparator {string}
- * fractionGroupSize {number}
- *
- * (The values assigned to the above FORMAT object properties are not checked for validity.)
- *
- * E.g.
- * BigNumber.config(20, 4) is equivalent to
- * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
- *
- * Ignore properties/parameters set to null or undefined.
- * Return an object with the properties current values.
- */
- BigNumber.config = function () {
- var v, p,
- i = 0,
- r = {},
- a = arguments,
- o = a[0],
- has = o && typeof o == 'object'
- ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
- : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
- // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
- // 'config() DECIMAL_PLACES not an integer: {v}'
- // 'config() DECIMAL_PLACES out of range: {v}'
- if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
- DECIMAL_PLACES = v | 0;
- }
- r[p] = DECIMAL_PLACES;
- // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
- // 'config() ROUNDING_MODE not an integer: {v}'
- // 'config() ROUNDING_MODE out of range: {v}'
- if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
- ROUNDING_MODE = v | 0;
- }
- r[p] = ROUNDING_MODE;
- // EXPONENTIAL_AT {number|number[]}
- // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
- // 'config() EXPONENTIAL_AT not an integer: {v}'
- // 'config() EXPONENTIAL_AT out of range: {v}'
- if ( has( p = 'EXPONENTIAL_AT' ) ) {
- if ( isArray(v) ) {
- if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
- TO_EXP_NEG = v[0] | 0;
- TO_EXP_POS = v[1] | 0;
- }
- } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
- TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
- }
- }
- r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
- // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
- // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
- // 'config() RANGE not an integer: {v}'
- // 'config() RANGE cannot be zero: {v}'
- // 'config() RANGE out of range: {v}'
- if ( has( p = 'RANGE' ) ) {
- if ( isArray(v) ) {
- if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
- MIN_EXP = v[0] | 0;
- MAX_EXP = v[1] | 0;
- }
- } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
- if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
- else if (ERRORS) raise( 2, p + ' cannot be zero', v );
- }
- }
- r[p] = [ MIN_EXP, MAX_EXP ];
- // ERRORS {boolean|number} true, false, 1 or 0.
- // 'config() ERRORS not a boolean or binary digit: {v}'
- if ( has( p = 'ERRORS' ) ) {
- if ( v === !!v || v === 1 || v === 0 ) {
- id = 0;
- isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
- } else if (ERRORS) {
- raise( 2, p + notBool, v );
- }
- }
- r[p] = ERRORS;
- // CRYPTO {boolean|number} true, false, 1 or 0.
- // 'config() CRYPTO not a boolean or binary digit: {v}'
- // 'config() crypto unavailable: {crypto}'
- if ( has( p = 'CRYPTO' ) ) {
- if ( v === !!v || v === 1 || v === 0 ) {
- CRYPTO = !!( v && crypto && typeof crypto == 'object' );
- if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
- } else if (ERRORS) {
- raise( 2, p + notBool, v );
- }
- }
- r[p] = CRYPTO;
- // MODULO_MODE {number} Integer, 0 to 9 inclusive.
- // 'config() MODULO_MODE not an integer: {v}'
- // 'config() MODULO_MODE out of range: {v}'
- if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
- MODULO_MODE = v | 0;
- }
- r[p] = MODULO_MODE;
- // POW_PRECISION {number} Integer, 0 to MAX inclusive.
- // 'config() POW_PRECISION not an integer: {v}'
- // 'config() POW_PRECISION out of range: {v}'
- if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
- POW_PRECISION = v | 0;
- }
- r[p] = POW_PRECISION;
- // FORMAT {object}
- // 'config() FORMAT not an object: {v}'
- if ( has( p = 'FORMAT' ) ) {
- if ( typeof v == 'object' ) {
- FORMAT = v;
- } else if (ERRORS) {
- raise( 2, p + ' not an object', v );
- }
- }
- r[p] = FORMAT;
- return r;
- };
- /*
- * Return a new BigNumber whose value is the maximum of the arguments.
- *
- * arguments {number|string|BigNumber}
- */
- BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
- /*
- * Return a new BigNumber whose value is the minimum of the arguments.
- *
- * arguments {number|string|BigNumber}
- */
- BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
- /*
- * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
- * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
- * zeros are produced).
- *
- * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
- *
- * 'random() decimal places not an integer: {dp}'
- * 'random() decimal places out of range: {dp}'
- * 'random() crypto unavailable: {crypto}'
- */
- BigNumber.random = (function () {
- var pow2_53 = 0x20000000000000;
- // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
- // Check if Math.random() produces more than 32 bits of randomness.
- // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
- // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
- var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
- ? function () { return mathfloor( Math.random() * pow2_53 ); }
- : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
- (Math.random() * 0x800000 | 0); };
- return function (dp) {
- var a, b, e, k, v,
- i = 0,
- c = [],
- rand = new BigNumber(ONE);
- dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
- k = mathceil( dp / LOG_BASE );
- if (CRYPTO) {
- // Browsers supporting crypto.getRandomValues.
- if ( crypto && crypto.getRandomValues ) {
- a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
- for ( ; i < k; ) {
- // 53 bits:
- // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
- // 11111 11111111 11111111 11111111 11100000 00000000 00000000
- // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
- // 11111 11111111 11111111
- // 0x20000 is 2^21.
- v = a[i] * 0x20000 + (a[i + 1] >>> 11);
- // Rejection sampling:
- // 0 <= v < 9007199254740992
- // Probability that v >= 9e15, is
- // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
- if ( v >= 9e15 ) {
- b = crypto.getRandomValues( new Uint32Array(2) );
- a[i] = b[0];
- a[i + 1] = b[1];
- } else {
- // 0 <= v <= 8999999999999999
- // 0 <= (v % 1e14) <= 99999999999999
- c.push( v % 1e14 );
- i += 2;
- }
- }
- i = k / 2;
- // Node.js supporting crypto.randomBytes.
- } else if ( crypto && crypto.randomBytes ) {
- // buffer
- a = crypto.randomBytes( k *= 7 );
- for ( ; i < k; ) {
- // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
- // 0x100000000 is 2^32, 0x1000000 is 2^24
- // 11111 11111111 11111111 11111111 11111111 11111111 11111111
- // 0 <= v < 9007199254740992
- v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
- ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
- ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
- if ( v >= 9e15 ) {
- crypto.randomBytes(7).copy( a, i );
- } else {
- // 0 <= (v % 1e14) <= 99999999999999
- c.push( v % 1e14 );
- i += 7;
- }
- }
- i = k / 7;
- } else if (ERRORS) {
- raise( 14, 'crypto unavailable', crypto );
- }
- }
- // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
- if (!i) {
- for ( ; i < k; ) {
- v = random53bitInt();
- if ( v < 9e15 ) c[i++] = v % 1e14;
- }
- }
- k = c[--i];
- dp %= LOG_BASE;
- // Convert trailing digits to zeros according to dp.
- if ( k && dp ) {
- v = POWS_TEN[LOG_BASE - dp];
- c[i] = mathfloor( k / v ) * v;
- }
- // Remove trailing elements which are zero.
- for ( ; c[i] === 0; c.pop(), i-- );
- // Zero?
- if ( i < 0 ) {
- c = [ e = 0 ];
- } else {
- // Remove leading elements which are zero and adjust exponent accordingly.
- for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
- // Count the digits of the first element of c to determine leading zeros, and...
- for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
- // adjust the exponent accordingly.
- if ( i < LOG_BASE ) e -= LOG_BASE - i;
- }
- rand.e = e;
- rand.c = c;
- return rand;
- };
- })();
- // PRIVATE FUNCTIONS
- // Convert a numeric string of baseIn to a numeric string of baseOut.
- function convertBase( str, baseOut, baseIn, sign ) {
- var d, e, k, r, x, xc, y,
- i = str.indexOf( '.' ),
- dp = DECIMAL_PLACES,
- rm = ROUNDING_MODE;
- if ( baseIn < 37 ) str = str.toLowerCase();
- // Non-integer.
- if ( i >= 0 ) {
- k = POW_PRECISION;
- // Unlimited precision.
- POW_PRECISION = 0;
- str = str.replace( '.', '' );
- y = new BigNumber(baseIn);
- x = y.pow( str.length - i );
- POW_PRECISION = k;
- // Convert str as if an integer, then restore the fraction part by dividing the
- // result by its base raised to a power.
- y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
- y.e = y.c.length;
- }
- // Convert the number as integer.
- xc = toBaseOut( str, baseIn, baseOut );
- e = k = xc.length;
- // Remove trailing zeros.
- for ( ; xc[--k] == 0; xc.pop() );
- if ( !xc[0] ) return '0';
- if ( i < 0 ) {
- --e;
- } else {
- x.c = xc;
- x.e = e;
- // sign is needed for correct rounding.
- x.s = sign;
- x = div( x, y, dp, rm, baseOut );
- xc = x.c;
- r = x.r;
- e = x.e;
- }
- d = e + dp + 1;
- // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
- i = xc[d];
- k = baseOut / 2;
- r = r || d < 0 || xc[d + 1] != null;
- r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
- : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
- rm == ( x.s < 0 ? 8 : 7 ) );
- if ( d < 1 || !xc[0] ) {
- // 1^-dp or 0.
- str = r ? toFixedPoint( '1', -dp ) : '0';
- } else {
- xc.length = d;
- if (r) {
- // Rounding up may mean the previous digit has to be rounded up and so on.
- for ( --baseOut; ++xc[--d] > baseOut; ) {
- xc[d] = 0;
- if ( !d ) {
- ++e;
- xc.unshift(1);
- }
- }
- }
- // Determine trailing zeros.
- for ( k = xc.length; !xc[--k]; );
- // E.g. [4, 11, 15] becomes 4bf.
- for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
- str = toFixedPoint( str, e );
- }
- // The caller will add the sign.
- return str;
- }
- // Perform division in the specified base. Called by div and convertBase.
- div = (function () {
- // Assume non-zero x and k.
- function multiply( x, k, base ) {
- var m, temp, xlo, xhi,
- carry = 0,
- i = x.length,
- klo = k % SQRT_BASE,
- khi = k / SQRT_BASE | 0;
- for ( x = x.slice(); i--; ) {
- xlo = x[i] % SQRT_BASE;
- xhi = x[i] / SQRT_BASE | 0;
- m = khi * xlo + xhi * klo;
- temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
- carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
- x[i] = temp % base;
- }
- if (carry) x.unshift(carry);
- return x;
- }
- function compare( a, b, aL, bL ) {
- var i, cmp;
- if ( aL != bL ) {
- cmp = aL > bL ? 1 : -1;
- } else {
- for ( i = cmp = 0; i < aL; i++ ) {
- if ( a[i] != b[i] ) {
- cmp = a[i] > b[i] ? 1 : -1;
- break;
- }
- }
- }
- return cmp;
- }
- function subtract( a, b, aL, base ) {
- var i = 0;
- // Subtract b from a.
- for ( ; aL--; ) {
- a[aL] -= i;
- i = a[aL] < b[aL] ? 1 : 0;
- a[aL] = i * base + a[aL] - b[aL];
- }
- // Remove leading zeros.
- for ( ; !a[0] && a.length > 1; a.shift() );
- }
- // x: dividend, y: divisor.
- return function ( x, y, dp, rm, base ) {
- var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
- yL, yz,
- s = x.s == y.s ? 1 : -1,
- xc = x.c,
- yc = y.c;
- // Either NaN, Infinity or 0?
- if ( !xc || !xc[0] || !yc || !yc[0] ) {
- return new BigNumber(
- // Return NaN if either NaN, or both Infinity or 0.
- !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
- // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
- xc && xc[0] == 0 || !yc ? s * 0 : s / 0
- );
- }
- q = new BigNumber(s);
- qc = q.c = [];
- e = x.e - y.e;
- s = dp + e + 1;
- if ( !base ) {
- base = BASE;
- e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
- s = s / LOG_BASE | 0;
- }
- // Result exponent may be one less then the current value of e.
- // The coefficients of the BigNumbers from convertBase may have trailing zeros.
- for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
- if ( yc[i] > ( xc[i] || 0 ) ) e--;
- if ( s < 0 ) {
- qc.push(1);
- more = true;
- } else {
- xL = xc.length;
- yL = yc.length;
- i = 0;
- s += 2;
- // Normalise xc and yc so highest order digit of yc is >= base / 2.
- n = mathfloor( base / ( yc[0] + 1 ) );
- // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
- // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
- if ( n > 1 ) {
- yc = multiply( yc, n, base );
- xc = multiply( xc, n, base );
- yL = yc.length;
- xL = xc.length;
- }
- xi = yL;
- rem = xc.slice( 0, yL );
- remL = rem.length;
- // Add zeros to make remainder as long as divisor.
- for ( ; remL < yL; rem[remL++] = 0 );
- yz = yc.slice();
- yz.unshift(0);
- yc0 = yc[0];
- if ( yc[1] >= base / 2 ) yc0++;
- // Not necessary, but to prevent trial digit n > base, when using base 3.
- // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
- do {
- n = 0;
- // Compare divisor and remainder.
- cmp = compare( yc, rem, yL, remL );
- // If divisor < remainder.
- if ( cmp < 0 ) {
- // Calculate trial digit, n.
- rem0 = rem[0];
- if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
- // n is how many times the divisor goes into the current remainder.
- n = mathfloor( rem0 / yc0 );
- // Algorithm:
- // 1. product = divisor * trial digit (n)
- // 2. if product > remainder: product -= divisor, n--
- // 3. remainder -= product
- // 4. if product was < remainder at 2:
- // 5. compare new remainder and divisor
- // 6. If remainder > divisor: remainder -= divisor, n++
- if ( n > 1 ) {
- // n may be > base only when base is 3.
- if (n >= base) n = base - 1;
- // product = divisor * trial digit.
- prod = multiply( yc, n, base );
- prodL = prod.length;
- remL = rem.length;
- // Compare product and remainder.
- // If product > remainder.
- // Trial digit n too high.
- // n is 1 too high about 5% of the time, and is not known to have
- // ever been more than 1 too high.
- while ( compare( prod, rem, prodL, remL ) == 1 ) {
- n--;
- // Subtract divisor from product.
- subtract( prod, yL < prodL ? yz : yc, prodL, base );
- prodL = prod.length;
- cmp = 1;
- }
- } else {
- // n is 0 or 1, cmp is -1.
- // If n is 0, there is no need to compare yc and rem again below,
- // so change cmp to 1 to avoid it.
- // If n is 1, leave cmp as -1, so yc and rem are compared again.
- if ( n == 0 ) {
- // divisor < remainder, so n must be at least 1.
- cmp = n = 1;
- }
- // product = divisor
- prod = yc.slice();
- prodL = prod.length;
- }
- if ( prodL < remL ) prod.unshift(0);
- // Subtract product from remainder.
- subtract( rem, prod, remL, base );
- remL = rem.length;
- // If product was < remainder.
- if ( cmp == -1 ) {
- // Compare divisor and new remainder.
- // If divisor < new remainder, subtract divisor from remainder.
- // Trial digit n too low.
- // n is 1 too low about 5% of the time, and very rarely 2 too low.
- while ( compare( yc, rem, yL, remL ) < 1 ) {
- n++;
- // Subtract divisor from remainder.
- subtract( rem, yL < remL ? yz : yc, remL, base );
- remL = rem.length;
- }
- }
- } else if ( cmp === 0 ) {
- n++;
- rem = [0];
- } // else cmp === 1 and n will be 0
- // Add the next digit, n, to the result array.
- qc[i++] = n;
- // Update the remainder.
- if ( rem[0] ) {
- rem[remL++] = xc[xi] || 0;
- } else {
- rem = [ xc[xi] ];
- remL = 1;
- }
- } while ( ( xi++ < xL || rem[0] != null ) && s-- );
- more = rem[0] != null;
- // Leading zero?
- if ( !qc[0] ) qc.shift();
- }
- if ( base == BASE ) {
- // To calculate q.e, first get the number of digits of qc[0].
- for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
- round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
- // Caller is convertBase.
- } else {
- q.e = e;
- q.r = +more;
- }
- return q;
- };
- })();
- /*
- * Return a string representing the value of BigNumber n in fixed-point or exponential
- * notation rounded to the specified decimal places or significant digits.
- *
- * n is a BigNumber.
- * i is the index of the last digit required (i.e. the digit that may be rounded up).
- * rm is the rounding mode.
- * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
- */
- function format( n, i, rm, caller ) {
- var c0, e, ne, len, str;
- rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
- ? rm | 0 : ROUNDING_MODE;
- if ( !n.c ) return n.toString();
- c0 = n.c[0];
- ne = n.e;
- if ( i == null ) {
- str = coeffToString( n.c );
- str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
- ? toExponential( str, ne )
- : toFixedPoint( str, ne );
- } else {
- n = round( new BigNumber(n), i, rm );
- // n.e may have changed if the value was rounded up.
- e = n.e;
- str = coeffToString( n.c );
- len = str.length;
- // toPrecision returns exponential notation if the number of significant digits
- // specified is less than the number of digits necessary to represent the integer
- // part of the value in fixed-point notation.
- // Exponential notation.
- if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
- // Append zeros?
- for ( ; len < i; str += '0', len++ );
- str = toExponential( str, e );
- // Fixed-point notation.
- } else {
- i -= ne;
- str = toFixedPoint( str, e );
- // Append zeros?
- if ( e + 1 > len ) {
- if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
- } else {
- i += e - len;
- if ( i > 0 ) {
- if ( e + 1 == len ) str += '.';
- for ( ; i--; str += '0' );
- }
- }
- }
- }
- return n.s < 0 && c0 ? '-' + str : str;
- }
- // Handle BigNumber.max and BigNumber.min.
- function maxOrMin( args, method ) {
- var m, n,
- i = 0;
- if ( isArray( args[0] ) ) args = args[0];
- m = new BigNumber( args[0] );
- for ( ; ++i < args.length; ) {
- n = new BigNumber( args[i] );
- // If any number is NaN, return NaN.
- if ( !n.s ) {
- m = n;
- break;
- } else if ( method.call( m, n ) ) {
- m = n;
- }
- }
- return m;
- }
- /*
- * Return true if n is an integer in range, otherwise throw.
- * Use for argument validation when ERRORS is true.
- */
- function intValidatorWithErrors( n, min, max, caller, name ) {
- if ( n < min || n > max || n != truncate(n) ) {
- raise( caller, ( name || 'decimal places' ) +
- ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
- }
- return true;
- }
- /*
- * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
- * Called by minus, plus and times.
- */
- function normalise( n, c, e ) {
- var i = 1,
- j = c.length;
- // Remove trailing zeros.
- for ( ; !c[--j]; c.pop() );
- // Calculate the base 10 exponent. First get the number of digits of c[0].
- for ( j = c[0]; j >= 10; j /= 10, i++ );
- // Overflow?
- if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
- // Infinity.
- n.c = n.e = null;
- // Underflow?
- } else if ( e < MIN_EXP ) {
- // Zero.
- n.c = [ n.e = 0 ];
- } else {
- n.e = e;
- n.c = c;
- }
- return n;
- }
- // Handle values that fail the validity test in BigNumber.
- parseNumeric = (function () {
- var basePrefix = /^(-?)0([xbo])/i,
- dotAfter = /^([^.]+)\.$/,
- dotBefore = /^\.([^.]+)$/,
- isInfinityOrNaN = /^-?(Infinity|NaN)$/,
- whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
- return function ( x, str, num, b ) {
- var base,
- s = num ? str : str.replace( whitespaceOrPlus, '' );
- // No exception on ±Infinity or NaN.
- if ( isInfinityOrNaN.test(s) ) {
- x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
- } else {
- if ( !num ) {
- // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
- s = s.replace( basePrefix, function ( m, p1, p2 ) {
- base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
- return !b || b == base ? p1 : m;
- });
- if (b) {
- base = b;
- // E.g. '1.' to '1', '.1' to '0.1'
- s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
- }
- if ( str != s ) return new BigNumber( s, base );
- }
- // 'new BigNumber() not a number: {n}'
- // 'new BigNumber() not a base {b} number: {n}'
- if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
- x.s = null;
- }
- x.c = x.e = null;
- id = 0;
- }
- })();
- // Throw a BigNumber Error.
- function raise( caller, msg, val ) {
- var error = new Error( [
- 'new BigNumber', // 0
- 'cmp', // 1
- 'config', // 2
- 'div', // 3
- 'divToInt', // 4
- 'eq', // 5
- 'gt', // 6
- 'gte', // 7
- 'lt', // 8
- 'lte', // 9
- 'minus', // 10
- 'mod', // 11
- 'plus', // 12
- 'precision', // 13
- 'random', // 14
- 'round', // 15
- 'shift', // 16
- 'times', // 17
- 'toDigits', // 18
- 'toExponential', // 19
- 'toFixed', // 20
- 'toFormat', // 21
- 'toFraction', // 22
- 'pow', // 23
- 'toPrecision', // 24
- 'toString', // 25
- 'BigNumber' // 26
- ][caller] + '() ' + msg + ': ' + val );
- error.name = 'BigNumber Error';
- id = 0;
- throw error;
- }
- /*
- * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
- * If r is truthy, it is known that there are more digits after the rounding digit.
- */
- function round( x, sd, rm, r ) {
- var d, i, j, k, n, ni, rd,
- xc = x.c,
- pows10 = POWS_TEN;
- // if x is not Infinity or NaN...
- if (xc) {
- // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
- // n is a base 1e14 number, the value of the element of array x.c containing rd.
- // ni is the index of n within x.c.
- // d is the number of digits of n.
- // i is the index of rd within n including leading zeros.
- // j is the actual index of rd within n (if < 0, rd is a leading zero).
- out: {
- // Get the number of digits of the first element of xc.
- for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
- i = sd - d;
- // If the rounding digit is in the first element of xc...
- if ( i < 0 ) {
- i += LOG_BASE;
- j = sd;
- n = xc[ ni = 0 ];
- // Get the rounding digit at index j of n.
- rd = n / pows10[ d - j - 1 ] % 10 | 0;
- } else {
- ni = mathceil( ( i + 1 ) / LOG_BASE );
- if ( ni >= xc.length ) {
- if (r) {
- // Needed by sqrt.
- for ( ; xc.length <= ni; xc.push(0) );
- n = rd = 0;
- d = 1;
- i %= LOG_BASE;
- j = i - LOG_BASE + 1;
- } else {
- break out;
- }
- } else {
- n = k = xc[ni];
- // Get the number of digits of n.
- for ( d = 1; k >= 10; k /= 10, d++ );
- // Get the index of rd within n.
- i %= LOG_BASE;
- // Get the index of rd within n, adjusted for leading zeros.
- // The number of leading zeros of n is given by LOG_BASE - d.
- j = i - LOG_BASE + d;
- // Get the rounding digit at index j of n.
- rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
- }
- }
- r = r || sd < 0 ||
- // Are there any non-zero digits after the rounding digit?
- // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
- // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
- xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
- r = rm < 4
- ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
- : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
- // Check whether the digit to the left of the rounding digit is odd.
- ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
- rm == ( x.s < 0 ? 8 : 7 ) );
- if ( sd < 1 || !xc[0] ) {
- xc.length = 0;
- if (r) {
- // Convert sd to decimal places.
- sd -= x.e + 1;
- // 1, 0.1, 0.01, 0.001, 0.0001 etc.
- xc[0] = pows10[ sd % LOG_BASE ];
- x.e = -sd || 0;
- } else {
- // Zero.
- xc[0] = x.e = 0;
- }
- return x;
- }
- // Remove excess digits.
- if ( i == 0 ) {
- xc.length = ni;
- k = 1;
- ni--;
- } else {
- xc.length = ni + 1;
- k = pows10[ LOG_BASE - i ];
- // E.g. 56700 becomes 56000 if 7 is the rounding digit.
- // j > 0 means i > number of leading zeros of n.
- xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
- }
- // Round up?
- if (r) {
- for ( ; ; ) {
- // If the digit to be rounded up is in the first element of xc...
- if ( ni == 0 ) {
- // i will be the length of xc[0] before k is added.
- for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
- j = xc[0] += k;
- for ( k = 1; j >= 10; j /= 10, k++ );
- // if i != k the length has increased.
- if ( i != k ) {
- x.e++;
- if ( xc[0] == BASE ) xc[0] = 1;
- }
- break;
- } else {
- xc[ni] += k;
- if ( xc[ni] != BASE ) break;
- xc[ni--] = 0;
- k = 1;
- }
- }
- }
- // Remove trailing zeros.
- for ( i = xc.length; xc[--i] === 0; xc.pop() );
- }
- // Overflow? Infinity.
- if ( x.e > MAX_EXP ) {
- x.c = x.e = null;
- // Underflow? Zero.
- } else if ( x.e < MIN_EXP ) {
- x.c = [ x.e = 0 ];
- }
- }
- return x;
- }
- // PROTOTYPE/INSTANCE METHODS
- /*
- * Return a new BigNumber whose value is the absolute value of this BigNumber.
- */
- P.absoluteValue = P.abs = function () {
- var x = new BigNumber(this);
- if ( x.s < 0 ) x.s = 1;
- return x;
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
- * number in the direction of Infinity.
- */
- P.ceil = function () {
- return round( new BigNumber(this), this.e + 1, 2 );
- };
- /*
- * Return
- * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
- * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
- * 0 if they have the same value,
- * or null if the value of either is NaN.
- */
- P.comparedTo = P.cmp = function ( y, b ) {
- id = 1;
- return compare( this, new BigNumber( y, b ) );
- };
- /*
- * Return the number of decimal places of the value of this BigNumber, or null if the value
- * of this BigNumber is ±Infinity or NaN.
- */
- P.decimalPlaces = P.dp = function () {
- var n, v,
- c = this.c;
- if ( !c ) return null;
- n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
- // Subtract the number of trailing zeros of the last number.
- if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
- if ( n < 0 ) n = 0;
- return n;
- };
- /*
- * n / 0 = I
- * n / N = N
- * n / I = 0
- * 0 / n = 0
- * 0 / 0 = N
- * 0 / N = N
- * 0 / I = 0
- * N / n = N
- * N / 0 = N
- * N / N = N
- * N / I = N
- * I / n = I
- * I / 0 = I
- * I / N = N
- * I / I = N
- *
- * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
- * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
- */
- P.dividedBy = P.div = function ( y, b ) {
- id = 3;
- return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
- };
- /*
- * Return a new BigNumber whose value is the integer part of dividing the value of this
- * BigNumber by the value of BigNumber(y, b).
- */
- P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
- id = 4;
- return div( this, new BigNumber( y, b ), 0, 1 );
- };
- /*
- * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
- * otherwise returns false.
- */
- P.equals = P.eq = function ( y, b ) {
- id = 5;
- return compare( this, new BigNumber( y, b ) ) === 0;
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
- * number in the direction of -Infinity.
- */
- P.floor = function () {
- return round( new BigNumber(this), this.e + 1, 3 );
- };
- /*
- * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
- * otherwise returns false.
- */
- P.greaterThan = P.gt = function ( y, b ) {
- id = 6;
- return compare( this, new BigNumber( y, b ) ) > 0;
- };
- /*
- * Return true if the value of this BigNumber is greater than or equal to the value of
- * BigNumber(y, b), otherwise returns false.
- */
- P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
- id = 7;
- return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
- };
- /*
- * Return true if the value of this BigNumber is a finite number, otherwise returns false.
- */
- P.isFinite = function () {
- return !!this.c;
- };
- /*
- * Return true if the value of this BigNumber is an integer, otherwise return false.
- */
- P.isInteger = P.isInt = function () {
- return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
- };
- /*
- * Return true if the value of this BigNumber is NaN, otherwise returns false.
- */
- P.isNaN = function () {
- return !this.s;
- };
- /*
- * Return true if the value of this BigNumber is negative, otherwise returns false.
- */
- P.isNegative = P.isNeg = function () {
- return this.s < 0;
- };
- /*
- * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
- */
- P.isZero = function () {
- return !!this.c && this.c[0] == 0;
- };
- /*
- * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
- * otherwise returns false.
- */
- P.lessThan = P.lt = function ( y, b ) {
- id = 8;
- return compare( this, new BigNumber( y, b ) ) < 0;
- };
- /*
- * Return true if the value of this BigNumber is less than or equal to the value of
- * BigNumber(y, b), otherwise returns false.
- */
- P.lessThanOrEqualTo = P.lte = function ( y, b ) {
- id = 9;
- return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
- };
- /*
- * n - 0 = n
- * n - N = N
- * n - I = -I
- * 0 - n = -n
- * 0 - 0 = 0
- * 0 - N = N
- * 0 - I = -I
- * N - n = N
- * N - 0 = N
- * N - N = N
- * N - I = N
- * I - n = I
- * I - 0 = I
- * I - N = N
- * I - I = N
- *
- * Return a new BigNumber whose value is the value of this BigNumber minus the value of
- * BigNumber(y, b).
- */
- P.minus = P.sub = function ( y, b ) {
- var i, j, t, xLTy,
- x = this,
- a = x.s;
- id = 10;
- y = new BigNumber( y, b );
- b = y.s;
- // Either NaN?
- if ( !a || !b ) return new BigNumber(NaN);
- // Signs differ?
- if ( a != b ) {
- y.s = -b;
- return x.plus(y);
- }
- var xe = x.e / LOG_BASE,
- ye = y.e / LOG_BASE,
- xc = x.c,
- yc = y.c;
- if ( !xe || !ye ) {
- // Either Infinity?
- if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
- // Either zero?
- if ( !xc[0] || !yc[0] ) {
- // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
- return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
- // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
- ROUNDING_MODE == 3 ? -0 : 0 );
- }
- }
- xe = bitFloor(xe);
- ye = bitFloor(ye);
- xc = xc.slice();
- // Determine which is the bigger number.
- if ( a = xe - ye ) {
- if ( xLTy = a < 0 ) {
- a = -a;
- t = xc;
- } else {
- ye = xe;
- t = yc;
- }
- t.reverse();
- // Prepend zeros to equalise exponents.
- for ( b = a; b--; t.push(0) );
- t.reverse();
- } else {
- // Exponents equal. Check digit by digit.
- j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
- for ( a = b = 0; b < j; b++ ) {
- if ( xc[b] != yc[b] ) {
- xLTy = xc[b] < yc[b];
- break;
- }
- }
- }
- // x < y? Point xc to the array of the bigger number.
- if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
- b = ( j = yc.length ) - ( i = xc.length );
- // Append zeros to xc if shorter.
- // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
- if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
- b = BASE - 1;
- // Subtract yc from xc.
- for ( ; j > a; ) {
- if ( xc[--j] < yc[j] ) {
- for ( i = j; i && !xc[--i]; xc[i] = b );
- --xc[i];
- xc[j] += BASE;
- }
- xc[j] -= yc[j];
- }
- // Remove leading zeros and adjust exponent accordingly.
- for ( ; xc[0] == 0; xc.shift(), --ye );
- // Zero?
- if ( !xc[0] ) {
- // Following IEEE 754 (2008) 6.3,
- // n - n = +0 but n - n = -0 when rounding towards -Infinity.
- y.s = ROUNDING_MODE == 3 ? -1 : 1;
- y.c = [ y.e = 0 ];
- return y;
- }
- // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
- // for finite x and y.
- return normalise( y, xc, ye );
- };
- /*
- * n % 0 = N
- * n % N = N
- * n % I = n
- * 0 % n = 0
- * -0 % n = -0
- * 0 % 0 = N
- * 0 % N = N
- * 0 % I = 0
- * N % n = N
- * N % 0 = N
- * N % N = N
- * N % I = N
- * I % n = N
- * I % 0 = N
- * I % N = N
- * I % I = N
- *
- * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
- * BigNumber(y, b). The result depends on the value of MODULO_MODE.
- */
- P.modulo = P.mod = function ( y, b ) {
- var q, s,
- x = this;
- id = 11;
- y = new BigNumber( y, b );
- // Return NaN if x is Infinity or NaN, or y is NaN or zero.
- if ( !x.c || !y.s || y.c && !y.c[0] ) {
- return new BigNumber(NaN);
- // Return x if y is Infinity or x is zero.
- } else if ( !y.c || x.c && !x.c[0] ) {
- return new BigNumber(x);
- }
- if ( MODULO_MODE == 9 ) {
- // Euclidian division: q = sign(y) * floor(x / abs(y))
- // r = x - qy where 0 <= r < abs(y)
- s = y.s;
- y.s = 1;
- q = div( x, y, 0, 3 );
- y.s = s;
- q.s *= s;
- } else {
- q = div( x, y, 0, MODULO_MODE );
- }
- return x.minus( q.times(y) );
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber negated,
- * i.e. multiplied by -1.
- */
- P.negated = P.neg = function () {
- var x = new BigNumber(this);
- x.s = -x.s || null;
- return x;
- };
- /*
- * n + 0 = n
- * n + N = N
- * n + I = I
- * 0 + n = n
- * 0 + 0 = 0
- * 0 + N = N
- * 0 + I = I
- * N + n = N
- * N + 0 = N
- * N + N = N
- * N + I = N
- * I + n = I
- * I + 0 = I
- * I + N = N
- * I + I = I
- *
- * Return a new BigNumber whose value is the value of this BigNumber plus the value of
- * BigNumber(y, b).
- */
- P.plus = P.add = function ( y, b ) {
- var t,
- x = this,
- a = x.s;
- id = 12;
- y = new BigNumber( y, b );
- b = y.s;
- // Either NaN?
- if ( !a || !b ) return new BigNumber(NaN);
- // Signs differ?
- if ( a != b ) {
- y.s = -b;
- return x.minus(y);
- }
- var xe = x.e / LOG_BASE,
- ye = y.e / LOG_BASE,
- xc = x.c,
- yc = y.c;
- if ( !xe || !ye ) {
- // Return ±Infinity if either ±Infinity.
- if ( !xc || !yc ) return new BigNumber( a / 0 );
- // Either zero?
- // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
- if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
- }
- xe = bitFloor(xe);
- ye = bitFloor(ye);
- xc = xc.slice();
- // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
- if ( a = xe - ye ) {
- if ( a > 0 ) {
- ye = xe;
- t = yc;
- } else {
- a = -a;
- t = xc;
- }
- t.reverse();
- for ( ; a--; t.push(0) );
- t.reverse();
- }
- a = xc.length;
- b = yc.length;
- // Point xc to the longer array, and b to the shorter length.
- if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
- // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
- for ( a = 0; b; ) {
- a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
- xc[b] %= BASE;
- }
- if (a) {
- xc.unshift(a);
- ++ye;
- }
- // No need to check for zero, as +x + +y != 0 && -x + -y != 0
- // ye = MAX_EXP + 1 possible
- return normalise( y, xc, ye );
- };
- /*
- * Return the number of significant digits of the value of this BigNumber.
- *
- * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
- */
- P.precision = P.sd = function (z) {
- var n, v,
- x = this,
- c = x.c;
- // 'precision() argument not a boolean or binary digit: {z}'
- if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
- if (ERRORS) raise( 13, 'argument' + notBool, z );
- if ( z != !!z ) z = null;
- }
- if ( !c ) return null;
- v = c.length - 1;
- n = v * LOG_BASE + 1;
- if ( v = c[v] ) {
- // Subtract the number of trailing zeros of the last element.
- for ( ; v % 10 == 0; v /= 10, n-- );
- // Add the number of digits of the first element.
- for ( v = c[0]; v >= 10; v /= 10, n++ );
- }
- if ( z && x.e + 1 > n ) n = x.e + 1;
- return n;
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
- * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
- * omitted.
- *
- * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'round() decimal places out of range: {dp}'
- * 'round() decimal places not an integer: {dp}'
- * 'round() rounding mode not an integer: {rm}'
- * 'round() rounding mode out of range: {rm}'
- */
- P.round = function ( dp, rm ) {
- var n = new BigNumber(this);
- if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
- round( n, ~~dp + this.e + 1, rm == null ||
- !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
- }
- return n;
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
- * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
- *
- * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
- *
- * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
- * otherwise.
- *
- * 'shift() argument not an integer: {k}'
- * 'shift() argument out of range: {k}'
- */
- P.shift = function (k) {
- var n = this;
- return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
- // k < 1e+21, or truncate(k) will produce exponential notation.
- ? n.times( '1e' + truncate(k) )
- : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
- ? n.s * ( k < 0 ? 0 : 1 / 0 )
- : n );
- };
- /*
- * sqrt(-n) = N
- * sqrt( N) = N
- * sqrt(-I) = N
- * sqrt( I) = I
- * sqrt( 0) = 0
- * sqrt(-0) = -0
- *
- * Return a new BigNumber whose value is the square root of the value of this BigNumber,
- * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
- */
- P.squareRoot = P.sqrt = function () {
- var m, n, r, rep, t,
- x = this,
- c = x.c,
- s = x.s,
- e = x.e,
- dp = DECIMAL_PLACES + 4,
- half = new BigNumber('0.5');
- // Negative/NaN/Infinity/zero?
- if ( s !== 1 || !c || !c[0] ) {
- return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
- }
- // Initial estimate.
- s = Math.sqrt( +x );
- // Math.sqrt underflow/overflow?
- // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
- if ( s == 0 || s == 1 / 0 ) {
- n = coeffToString(c);
- if ( ( n.length + e ) % 2 == 0 ) n += '0';
- s = Math.sqrt(n);
- e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
- if ( s == 1 / 0 ) {
- n = '1e' + e;
- } else {
- n = s.toExponential();
- n = n.slice( 0, n.indexOf('e') + 1 ) + e;
- }
- r = new BigNumber(n);
- } else {
- r = new BigNumber( s + '' );
- }
- // Check for zero.
- // r could be zero if MIN_EXP is changed after the this value was created.
- // This would cause a division by zero (x/t) and hence Infinity below, which would cause
- // coeffToString to throw.
- if ( r.c[0] ) {
- e = r.e;
- s = e + dp;
- if ( s < 3 ) s = 0;
- // Newton-Raphson iteration.
- for ( ; ; ) {
- t = r;
- r = half.times( t.plus( div( x, t, dp, 1 ) ) );
- if ( coeffToString( t.c ).slice( 0, s ) === ( n =
- coeffToString( r.c ) ).slice( 0, s ) ) {
- // The exponent of r may here be one less than the final result exponent,
- // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
- // are indexed correctly.
- if ( r.e < e ) --s;
- n = n.slice( s - 3, s + 1 );
- // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
- // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
- // iteration.
- if ( n == '9999' || !rep && n == '4999' ) {
- // On the first iteration only, check to see if rounding up gives the
- // exact result as the nines may infinitely repeat.
- if ( !rep ) {
- round( t, t.e + DECIMAL_PLACES + 2, 0 );
- if ( t.times(t).eq(x) ) {
- r = t;
- break;
- }
- }
- dp += 4;
- s += 4;
- rep = 1;
- } else {
- // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
- // result. If not, then there are further digits and m will be truthy.
- if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
- // Truncate to the first rounding digit.
- round( r, r.e + DECIMAL_PLACES + 2, 1 );
- m = !r.times(r).eq(x);
- }
- break;
- }
- }
- }
- }
- return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
- };
- /*
- * n * 0 = 0
- * n * N = N
- * n * I = I
- * 0 * n = 0
- * 0 * 0 = 0
- * 0 * N = N
- * 0 * I = N
- * N * n = N
- * N * 0 = N
- * N * N = N
- * N * I = N
- * I * n = I
- * I * 0 = N
- * I * N = N
- * I * I = I
- *
- * Return a new BigNumber whose value is the value of this BigNumber times the value of
- * BigNumber(y, b).
- */
- P.times = P.mul = function ( y, b ) {
- var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
- base, sqrtBase,
- x = this,
- xc = x.c,
- yc = ( id = 17, y = new BigNumber( y, b ) ).c;
- // Either NaN, ±Infinity or ±0?
- if ( !xc || !yc || !xc[0] || !yc[0] ) {
- // Return NaN if either is NaN, or one is 0 and the other is Infinity.
- if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
- y.c = y.e = y.s = null;
- } else {
- y.s *= x.s;
- // Return ±Infinity if either is ±Infinity.
- if ( !xc || !yc ) {
- y.c = y.e = null;
- // Return ±0 if either is ±0.
- } else {
- y.c = [0];
- y.e = 0;
- }
- }
- return y;
- }
- e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
- y.s *= x.s;
- xcL = xc.length;
- ycL = yc.length;
- // Ensure xc points to longer array and xcL to its length.
- if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
- // Initialise the result array with zeros.
- for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
- base = BASE;
- sqrtBase = SQRT_BASE;
- for ( i = ycL; --i >= 0; ) {
- c = 0;
- ylo = yc[i] % sqrtBase;
- yhi = yc[i] / sqrtBase | 0;
- for ( k = xcL, j = i + k; j > i; ) {
- xlo = xc[--k] % sqrtBase;
- xhi = xc[k] / sqrtBase | 0;
- m = yhi * xlo + xhi * ylo;
- xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
- c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
- zc[j--] = xlo % base;
- }
- zc[j] = c;
- }
- if (c) {
- ++e;
- } else {
- zc.shift();
- }
- return normalise( y, zc, e );
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
- * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
- *
- * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'toDigits() precision out of range: {sd}'
- * 'toDigits() precision not an integer: {sd}'
- * 'toDigits() rounding mode not an integer: {rm}'
- * 'toDigits() rounding mode out of range: {rm}'
- */
- P.toDigits = function ( sd, rm ) {
- var n = new BigNumber(this);
- sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
- rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
- return sd ? round( n, sd, rm ) : n;
- };
- /*
- * Return a string representing the value of this BigNumber in exponential notation and
- * rounded using ROUNDING_MODE to dp fixed decimal places.
- *
- * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'toExponential() decimal places not an integer: {dp}'
- * 'toExponential() decimal places out of range: {dp}'
- * 'toExponential() rounding mode not an integer: {rm}'
- * 'toExponential() rounding mode out of range: {rm}'
- */
- P.toExponential = function ( dp, rm ) {
- return format( this,
- dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
- };
- /*
- * Return a string representing the value of this BigNumber in fixed-point notation rounding
- * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
- *
- * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
- * but e.g. (-0.00001).toFixed(0) is '-0'.
- *
- * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'toFixed() decimal places not an integer: {dp}'
- * 'toFixed() decimal places out of range: {dp}'
- * 'toFixed() rounding mode not an integer: {rm}'
- * 'toFixed() rounding mode out of range: {rm}'
- */
- P.toFixed = function ( dp, rm ) {
- return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
- ? ~~dp + this.e + 1 : null, rm, 20 );
- };
- /*
- * Return a string representing the value of this BigNumber in fixed-point notation rounded
- * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
- * of the FORMAT object (see BigNumber.config).
- *
- * FORMAT = {
- * decimalSeparator : '.',
- * groupSeparator : ',',
- * groupSize : 3,
- * secondaryGroupSize : 0,
- * fractionGroupSeparator : '\xA0', // non-breaking space
- * fractionGroupSize : 0
- * };
- *
- * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'toFormat() decimal places not an integer: {dp}'
- * 'toFormat() decimal places out of range: {dp}'
- * 'toFormat() rounding mode not an integer: {rm}'
- * 'toFormat() rounding mode out of range: {rm}'
- */
- P.toFormat = function ( dp, rm ) {
- var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
- ? ~~dp + this.e + 1 : null, rm, 21 );
- if ( this.c ) {
- var i,
- arr = str.split('.'),
- g1 = +FORMAT.groupSize,
- g2 = +FORMAT.secondaryGroupSize,
- groupSeparator = FORMAT.groupSeparator,
- intPart = arr[0],
- fractionPart = arr[1],
- isNeg = this.s < 0,
- intDigits = isNeg ? intPart.slice(1) : intPart,
- len = intDigits.length;
- if (g2) i = g1, g1 = g2, g2 = i, len -= i;
- if ( g1 > 0 && len > 0 ) {
- i = len % g1 || g1;
- intPart = intDigits.substr( 0, i );
- for ( ; i < len; i += g1 ) {
- intPart += groupSeparator + intDigits.substr( i, g1 );
- }
- if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
- if (isNeg) intPart = '-' + intPart;
- }
- str = fractionPart
- ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
- ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
- '$&' + FORMAT.fractionGroupSeparator )
- : fractionPart )
- : intPart;
- }
- return str;
- };
- /*
- * Return a string array representing the value of this BigNumber as a simple fraction with
- * an integer numerator and an integer denominator. The denominator will be a positive
- * non-zero value less than or equal to the specified maximum denominator. If a maximum
- * denominator is not specified, the denominator will be the lowest value necessary to
- * represent the number exactly.
- *
- * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
- *
- * 'toFraction() max denominator not an integer: {md}'
- * 'toFraction() max denominator out of range: {md}'
- */
- P.toFraction = function (md) {
- var arr, d0, d2, e, exp, n, n0, q, s,
- k = ERRORS,
- x = this,
- xc = x.c,
- d = new BigNumber(ONE),
- n1 = d0 = new BigNumber(ONE),
- d1 = n0 = new BigNumber(ONE);
- if ( md != null ) {
- ERRORS = false;
- n = new BigNumber(md);
- ERRORS = k;
- if ( !( k = n.isInt() ) || n.lt(ONE) ) {
- if (ERRORS) {
- raise( 22,
- 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
- }
- // ERRORS is false:
- // If md is a finite non-integer >= 1, round it to an integer and use it.
- md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
- }
- }
- if ( !xc ) return x.toString();
- s = coeffToString(xc);
- // Determine initial denominator.
- // d is a power of 10 and the minimum max denominator that specifies the value exactly.
- e = d.e = s.length - x.e - 1;
- d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
- md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
- exp = MAX_EXP;
- MAX_EXP = 1 / 0;
- n = new BigNumber(s);
- // n0 = d1 = 0
- n0.c[0] = 0;
- for ( ; ; ) {
- q = div( n, d, 0, 1 );
- d2 = d0.plus( q.times(d1) );
- if ( d2.cmp(md) == 1 ) break;
- d0 = d1;
- d1 = d2;
- n1 = n0.plus( q.times( d2 = n1 ) );
- n0 = d2;
- d = n.minus( q.times( d2 = d ) );
- n = d2;
- }
- d2 = div( md.minus(d0), d1, 0, 1 );
- n0 = n0.plus( d2.times(n1) );
- d0 = d0.plus( d2.times(d1) );
- n0.s = n1.s = x.s;
- e *= 2;
- // Determine which fraction is closer to x, n0/d0 or n1/d1
- arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
- div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
- ? [ n1.toString(), d1.toString() ]
- : [ n0.toString(), d0.toString() ];
- MAX_EXP = exp;
- return arr;
- };
- /*
- * Return the value of this BigNumber converted to a number primitive.
- */
- P.toNumber = function () {
- var x = this;
- // Ensure zero has correct sign.
- return +x || ( x.s ? x.s * 0 : NaN );
- };
- /*
- * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
- * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
- * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
- *
- * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
- * (Performs 54 loop iterations for n of 9007199254740992.)
- *
- * 'pow() exponent not an integer: {n}'
- * 'pow() exponent out of range: {n}'
- */
- P.toPower = P.pow = function (n) {
- var k, y,
- i = mathfloor( n < 0 ? -n : +n ),
- x = this;
- // Pass ±Infinity to Math.pow if exponent is out of range.
- if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
- ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
- parseFloat(n) != n && !( n = NaN ) ) ) {
- return new BigNumber( Math.pow( +x, n ) );
- }
- // Truncating each coefficient array to a length of k after each multiplication equates
- // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
- // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
- k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
- y = new BigNumber(ONE);
- for ( ; ; ) {
- if ( i % 2 ) {
- y = y.times(x);
- if ( !y.c ) break;
- if ( k && y.c.length > k ) y.c.length = k;
- }
- i = mathfloor( i / 2 );
- if ( !i ) break;
- x = x.times(x);
- if ( k && x.c && x.c.length > k ) x.c.length = k;
- }
- if ( n < 0 ) y = ONE.div(y);
- return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
- };
- /*
- * Return a string representing the value of this BigNumber rounded to sd significant digits
- * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
- * necessary to represent the integer part of the value in fixed-point notation, then use
- * exponential notation.
- *
- * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
- * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
- *
- * 'toPrecision() precision not an integer: {sd}'
- * 'toPrecision() precision out of range: {sd}'
- * 'toPrecision() rounding mode not an integer: {rm}'
- * 'toPrecision() rounding mode out of range: {rm}'
- */
- P.toPrecision = function ( sd, rm ) {
- return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
- ? sd | 0 : null, rm, 24 );
- };
- /*
- * Return a string representing the value of this BigNumber in base b, or base 10 if b is
- * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
- * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
- * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
- * TO_EXP_NEG, return exponential notation.
- *
- * [b] {number} Integer, 2 to 64 inclusive.
- *
- * 'toString() base not an integer: {b}'
- * 'toString() base out of range: {b}'
- */
- P.toString = function (b) {
- var str,
- n = this,
- s = n.s,
- e = n.e;
- // Infinity or NaN?
- if ( e === null ) {
- if (s) {
- str = 'Infinity';
- if ( s < 0 ) str = '-' + str;
- } else {
- str = 'NaN';
- }
- } else {
- str = coeffToString( n.c );
- if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
- str = e <= TO_EXP_NEG || e >= TO_EXP_POS
- ? toExponential( str, e )
- : toFixedPoint( str, e );
- } else {
- str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
- }
- if ( s < 0 && n.c[0] ) str = '-' + str;
- }
- return str;
- };
- /*
- * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
- * number.
- */
- P.truncated = P.trunc = function () {
- return round( new BigNumber(this), this.e + 1, 1 );
- };
- /*
- * Return as toString, but do not accept a base argument.
- */
- P.valueOf = P.toJSON = function () {
- return this.toString();
- };
- // Aliases for BigDecimal methods.
- //P.add = P.plus; // P.add included above
- //P.subtract = P.minus; // P.sub included above
- //P.multiply = P.times; // P.mul included above
- //P.divide = P.div;
- //P.remainder = P.mod;
- //P.compareTo = P.cmp;
- //P.negate = P.neg;
- if ( configObj != null ) BigNumber.config(configObj);
- return BigNumber;
- }
- // PRIVATE HELPER FUNCTIONS
- function bitFloor(n) {
- var i = n | 0;
- return n > 0 || n === i ? i : i - 1;
- }
- // Return a coefficient array as a string of base 10 digits.
- function coeffToString(a) {
- var s, z,
- i = 1,
- j = a.length,
- r = a[0] + '';
- for ( ; i < j; ) {
- s = a[i++] + '';
- z = LOG_BASE - s.length;
- for ( ; z--; s = '0' + s );
- r += s;
- }
- // Determine trailing zeros.
- for ( j = r.length; r.charCodeAt(--j) === 48; );
- return r.slice( 0, j + 1 || 1 );
- }
- // Compare the value of BigNumbers x and y.
- function compare( x, y ) {
- var a, b,
- xc = x.c,
- yc = y.c,
- i = x.s,
- j = y.s,
- k = x.e,
- l = y.e;
- // Either NaN?
- if ( !i || !j ) return null;
- a = xc && !xc[0];
- b = yc && !yc[0];
- // Either zero?
- if ( a || b ) return a ? b ? 0 : -j : i;
- // Signs differ?
- if ( i != j ) return i;
- a = i < 0;
- b = k == l;
- // Either Infinity?
- if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
- // Compare exponents.
- if ( !b ) return k > l ^ a ? 1 : -1;
- j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
- // Compare digit by digit.
- for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
- // Compare lengths.
- return k == l ? 0 : k > l ^ a ? 1 : -1;
- }
- /*
- * Return true if n is a valid number in range, otherwise false.
- * Use for argument validation when ERRORS is false.
- * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
- */
- function intValidatorNoErrors( n, min, max ) {
- return ( n = truncate(n) ) >= min && n <= max;
- }
- function isArray(obj) {
- return Object.prototype.toString.call(obj) == '[object Array]';
- }
- /*
- * Convert string of baseIn to an array of numbers of baseOut.
- * Eg. convertBase('255', 10, 16) returns [15, 15].
- * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
- */
- function toBaseOut( str, baseIn, baseOut ) {
- var j,
- arr = [0],
- arrL,
- i = 0,
- len = str.length;
- for ( ; i < len; ) {
- for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
- arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
- for ( ; j < arr.length; j++ ) {
- if ( arr[j] > baseOut - 1 ) {
- if ( arr[j + 1] == null ) arr[j + 1] = 0;
- arr[j + 1] += arr[j] / baseOut | 0;
- arr[j] %= baseOut;
- }
- }
- }
- return arr.reverse();
- }
- function toExponential( str, e ) {
- return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
- ( e < 0 ? 'e' : 'e+' ) + e;
- }
- function toFixedPoint( str, e ) {
- var len, z;
- // Negative exponent?
- if ( e < 0 ) {
- // Prepend zeros.
- for ( z = '0.'; ++e; z += '0' );
- str = z + str;
- // Positive exponent
- } else {
- len = str.length;
- // Append zeros.
- if ( ++e > len ) {
- for ( z = '0', e -= len; --e; z += '0' );
- str += z;
- } else if ( e < len ) {
- str = str.slice( 0, e ) + '.' + str.slice(e);
- }
- }
- return str;
- }
- function truncate(n) {
- n = parseFloat(n);
- return n < 0 ? mathceil(n) : mathfloor(n);
- }
- // EXPORT
- BigNumber = another();
- // AMD.
- if ( typeof define == 'function' && define.amd ) {
- define( function () { return BigNumber; } );
- // Node and other environments that support module.exports.
- } else if ( typeof module != 'undefined' && module.exports ) {
- module.exports = BigNumber;
- if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
- // Browser.
- } else {
- global.BigNumber = BigNumber;
- }
- })(this);
- },{"crypto":50}],"web3":[function(require,module,exports){
- var Web3 = require('./lib/web3');
- // dont override global variable
- if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
- window.Web3 = Web3;
- }
- module.exports = Web3;
- },{"./lib/web3":22}]},{},["web3"])
- //# sourceMappingURL=web3.js.map
- var IpfsApi =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId])
- /******/ return installedModules[moduleId].exports;
- /******/
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // identity function for calling harmory imports with the correct context
- /******/ __webpack_require__.i = function(value) { return value; };
- /******/
- /******/ // define getter function for harmory exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/_karma_webpack_//";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 588);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , core = __webpack_require__(32)
- , hide = __webpack_require__(19)
- , redefine = __webpack_require__(22)
- , ctx = __webpack_require__(35)
- , PROTOTYPE = 'prototype';
- var $export = function(type, name, source){
- var IS_FORCED = type & $export.F
- , IS_GLOBAL = type & $export.G
- , IS_STATIC = type & $export.S
- , IS_PROTO = type & $export.P
- , IS_BIND = type & $export.B
- , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
- , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
- , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {})
- , key, own, out, exp;
- if(IS_GLOBAL)source = name;
- for(key in source){
- // contains in native
- own = !IS_FORCED && target && target[key] !== undefined;
- // export native or passed
- out = (own ? target : source)[key];
- // bind timers to global for call from export context
- exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
- // extend global
- if(target)redefine(target, key, out, type & $export.U);
- // export
- if(exports[key] != out)hide(exports, key, exp);
- if(IS_PROTO && expProto[key] != out)expProto[key] = out;
- }
- };
- global.core = core;
- // type bitmap
- $export.F = 1; // forced
- $export.G = 2; // global
- $export.S = 4; // static
- $export.P = 8; // proto
- $export.B = 16; // bind
- $export.W = 32; // wrap
- $export.U = 64; // safe
- $export.R = 128; // real proto method for `library`
- module.exports = $export;
- /***/ },
- /* 1 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license MIT
- */
- /* eslint-disable no-proto */
- 'use strict'
- var base64 = __webpack_require__(282)
- var ieee754 = __webpack_require__(511)
- var isArray = __webpack_require__(133)
- exports.Buffer = Buffer
- exports.SlowBuffer = SlowBuffer
- exports.INSPECT_MAX_BYTES = 50
- /**
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
- * === true Use Uint8Array implementation (fastest)
- * === false Use Object implementation (most compatible, even IE6)
- *
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
- * Opera 11.6+, iOS 4.2+.
- *
- * Due to various browser bugs, sometimes the Object implementation will be used even
- * when the browser supports typed arrays.
- *
- * Note:
- *
- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
- *
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
- *
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
- * incorrect length in some situations.
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
- * get the Object implementation, which is slower but behaves correctly.
- */
- Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
- ? global.TYPED_ARRAY_SUPPORT
- : typedArraySupport()
- /*
- * Export kMaxLength after typed array support is determined.
- */
- exports.kMaxLength = kMaxLength()
- function typedArraySupport () {
- try {
- var arr = new Uint8Array(1)
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
- return arr.foo() === 42 && // typed array instances can be augmented
- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
- arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
- } catch (e) {
- return false
- }
- }
- function kMaxLength () {
- return Buffer.TYPED_ARRAY_SUPPORT
- ? 0x7fffffff
- : 0x3fffffff
- }
- function createBuffer (that, length) {
- if (kMaxLength() < length) {
- throw new RangeError('Invalid typed array length')
- }
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- // Return an augmented `Uint8Array` instance, for best performance
- that = new Uint8Array(length)
- that.__proto__ = Buffer.prototype
- } else {
- // Fallback: Return an object instance of the Buffer class
- if (that === null) {
- that = new Buffer(length)
- }
- that.length = length
- }
- return that
- }
- /**
- * The Buffer constructor returns instances of `Uint8Array` that have their
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
- * returns a single octet.
- *
- * The `Uint8Array` prototype remains unmodified.
- */
- function Buffer (arg, encodingOrOffset, length) {
- if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
- return new Buffer(arg, encodingOrOffset, length)
- }
- // Common case.
- if (typeof arg === 'number') {
- if (typeof encodingOrOffset === 'string') {
- throw new Error(
- 'If encoding is specified then the first argument must be a string'
- )
- }
- return allocUnsafe(this, arg)
- }
- return from(this, arg, encodingOrOffset, length)
- }
- Buffer.poolSize = 8192 // not used by this implementation
- // TODO: Legacy, not needed anymore. Remove in next major version.
- Buffer._augment = function (arr) {
- arr.__proto__ = Buffer.prototype
- return arr
- }
- function from (that, value, encodingOrOffset, length) {
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number')
- }
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
- return fromArrayBuffer(that, value, encodingOrOffset, length)
- }
- if (typeof value === 'string') {
- return fromString(that, value, encodingOrOffset)
- }
- return fromObject(that, value)
- }
- /**
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
- * if value is a number.
- * Buffer.from(str[, encoding])
- * Buffer.from(array)
- * Buffer.from(buffer)
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
- **/
- Buffer.from = function (value, encodingOrOffset, length) {
- return from(null, value, encodingOrOffset, length)
- }
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- Buffer.prototype.__proto__ = Uint8Array.prototype
- Buffer.__proto__ = Uint8Array
- if (typeof Symbol !== 'undefined' && Symbol.species &&
- Buffer[Symbol.species] === Buffer) {
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
- Object.defineProperty(Buffer, Symbol.species, {
- value: null,
- configurable: true
- })
- }
- }
- function assertSize (size) {
- if (typeof size !== 'number') {
- throw new TypeError('"size" argument must be a number')
- }
- }
- function alloc (that, size, fill, encoding) {
- assertSize(size)
- if (size <= 0) {
- return createBuffer(that, size)
- }
- if (fill !== undefined) {
- // Only pay attention to encoding if it's a string. This
- // prevents accidentally sending in a number that would
- // be interpretted as a start offset.
- return typeof encoding === 'string'
- ? createBuffer(that, size).fill(fill, encoding)
- : createBuffer(that, size).fill(fill)
- }
- return createBuffer(that, size)
- }
- /**
- * Creates a new filled Buffer instance.
- * alloc(size[, fill[, encoding]])
- **/
- Buffer.alloc = function (size, fill, encoding) {
- return alloc(null, size, fill, encoding)
- }
- function allocUnsafe (that, size) {
- assertSize(size)
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
- if (!Buffer.TYPED_ARRAY_SUPPORT) {
- for (var i = 0; i < size; ++i) {
- that[i] = 0
- }
- }
- return that
- }
- /**
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
- * */
- Buffer.allocUnsafe = function (size) {
- return allocUnsafe(null, size)
- }
- /**
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
- */
- Buffer.allocUnsafeSlow = function (size) {
- return allocUnsafe(null, size)
- }
- function fromString (that, string, encoding) {
- if (typeof encoding !== 'string' || encoding === '') {
- encoding = 'utf8'
- }
- if (!Buffer.isEncoding(encoding)) {
- throw new TypeError('"encoding" must be a valid string encoding')
- }
- var length = byteLength(string, encoding) | 0
- that = createBuffer(that, length)
- that.write(string, encoding)
- return that
- }
- function fromArrayLike (that, array) {
- var length = checked(array.length) | 0
- that = createBuffer(that, length)
- for (var i = 0; i < length; i += 1) {
- that[i] = array[i] & 255
- }
- return that
- }
- function fromArrayBuffer (that, array, byteOffset, length) {
- array.byteLength // this throws if `array` is not a valid ArrayBuffer
- if (byteOffset < 0 || array.byteLength < byteOffset) {
- throw new RangeError('\'offset\' is out of bounds')
- }
- if (array.byteLength < byteOffset + (length || 0)) {
- throw new RangeError('\'length\' is out of bounds')
- }
- if (length === undefined) {
- array = new Uint8Array(array, byteOffset)
- } else {
- array = new Uint8Array(array, byteOffset, length)
- }
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- // Return an augmented `Uint8Array` instance, for best performance
- that = array
- that.__proto__ = Buffer.prototype
- } else {
- // Fallback: Return an object instance of the Buffer class
- that = fromArrayLike(that, array)
- }
- return that
- }
- function fromObject (that, obj) {
- if (Buffer.isBuffer(obj)) {
- var len = checked(obj.length) | 0
- that = createBuffer(that, len)
- if (that.length === 0) {
- return that
- }
- obj.copy(that, 0, 0, len)
- return that
- }
- if (obj) {
- if ((typeof ArrayBuffer !== 'undefined' &&
- obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
- return createBuffer(that, 0)
- }
- return fromArrayLike(that, obj)
- }
- if (obj.type === 'Buffer' && isArray(obj.data)) {
- return fromArrayLike(that, obj.data)
- }
- }
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
- }
- function checked (length) {
- // Note: cannot use `length < kMaxLength` here because that fails when
- // length is NaN (which is otherwise coerced to zero.)
- if (length >= kMaxLength()) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + kMaxLength().toString(16) + ' bytes')
- }
- return length | 0
- }
- function SlowBuffer (length) {
- if (+length != length) { // eslint-disable-line eqeqeq
- length = 0
- }
- return Buffer.alloc(+length)
- }
- Buffer.isBuffer = function isBuffer (b) {
- return !!(b != null && b._isBuffer)
- }
- Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
- if (a === b) return 0
- var x = a.length
- var y = b.length
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i]
- y = b[i]
- break
- }
- }
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
- Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'binary':
- case 'base64':
- case 'raw':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
- }
- Buffer.concat = function concat (list, length) {
- if (!isArray(list)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- if (list.length === 0) {
- return Buffer.alloc(0)
- }
- var i
- if (length === undefined) {
- length = 0
- for (i = 0; i < list.length; ++i) {
- length += list[i].length
- }
- }
- var buffer = Buffer.allocUnsafe(length)
- var pos = 0
- for (i = 0; i < list.length; ++i) {
- var buf = list[i]
- if (!Buffer.isBuffer(buf)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- buf.copy(buffer, pos)
- pos += buf.length
- }
- return buffer
- }
- function byteLength (string, encoding) {
- if (Buffer.isBuffer(string)) {
- return string.length
- }
- if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
- (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
- return string.byteLength
- }
- if (typeof string !== 'string') {
- string = '' + string
- }
- var len = string.length
- if (len === 0) return 0
- // Use a for loop to avoid recursion
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'ascii':
- case 'binary':
- case 'raw':
- case 'raws':
- return len
- case 'utf8':
- case 'utf-8':
- case undefined:
- return utf8ToBytes(string).length
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return len * 2
- case 'hex':
- return len >>> 1
- case 'base64':
- return base64ToBytes(string).length
- default:
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.byteLength = byteLength
- function slowToString (encoding, start, end) {
- var loweredCase = false
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
- // property of a typed array.
- // This behaves neither like String nor Uint8Array in that we set start/end
- // to their upper/lower bounds if the value passed is out of range.
- // undefined is handled specially as per ECMA-262 6th Edition,
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
- if (start === undefined || start < 0) {
- start = 0
- }
- // Return early if start > this.length. Done here to prevent potential uint32
- // coercion fail below.
- if (start > this.length) {
- return ''
- }
- if (end === undefined || end > this.length) {
- end = this.length
- }
- if (end <= 0) {
- return ''
- }
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
- end >>>= 0
- start >>>= 0
- if (end <= start) {
- return ''
- }
- if (!encoding) encoding = 'utf8'
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
- case 'ascii':
- return asciiSlice(this, start, end)
- case 'binary':
- return binarySlice(this, start, end)
- case 'base64':
- return base64Slice(this, start, end)
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
- }
- // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
- // Buffer instances.
- Buffer.prototype._isBuffer = true
- function swap (b, n, m) {
- var i = b[n]
- b[n] = b[m]
- b[m] = i
- }
- Buffer.prototype.swap16 = function swap16 () {
- var len = this.length
- if (len % 2 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 16-bits')
- }
- for (var i = 0; i < len; i += 2) {
- swap(this, i, i + 1)
- }
- return this
- }
- Buffer.prototype.swap32 = function swap32 () {
- var len = this.length
- if (len % 4 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 32-bits')
- }
- for (var i = 0; i < len; i += 4) {
- swap(this, i, i + 3)
- swap(this, i + 1, i + 2)
- }
- return this
- }
- Buffer.prototype.toString = function toString () {
- var length = this.length | 0
- if (length === 0) return ''
- if (arguments.length === 0) return utf8Slice(this, 0, length)
- return slowToString.apply(this, arguments)
- }
- Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
- }
- Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return '<Buffer ' + str + '>'
- }
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
- if (!Buffer.isBuffer(target)) {
- throw new TypeError('Argument must be a Buffer')
- }
- if (start === undefined) {
- start = 0
- }
- if (end === undefined) {
- end = target ? target.length : 0
- }
- if (thisStart === undefined) {
- thisStart = 0
- }
- if (thisEnd === undefined) {
- thisEnd = this.length
- }
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
- throw new RangeError('out of range index')
- }
- if (thisStart >= thisEnd && start >= end) {
- return 0
- }
- if (thisStart >= thisEnd) {
- return -1
- }
- if (start >= end) {
- return 1
- }
- start >>>= 0
- end >>>= 0
- thisStart >>>= 0
- thisEnd >>>= 0
- if (this === target) return 0
- var x = thisEnd - thisStart
- var y = end - start
- var len = Math.min(x, y)
- var thisCopy = this.slice(thisStart, thisEnd)
- var targetCopy = target.slice(start, end)
- for (var i = 0; i < len; ++i) {
- if (thisCopy[i] !== targetCopy[i]) {
- x = thisCopy[i]
- y = targetCopy[i]
- break
- }
- }
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
- function arrayIndexOf (arr, val, byteOffset, encoding) {
- var indexSize = 1
- var arrLength = arr.length
- var valLength = val.length
- if (encoding !== undefined) {
- encoding = String(encoding).toLowerCase()
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
- encoding === 'utf16le' || encoding === 'utf-16le') {
- if (arr.length < 2 || val.length < 2) {
- return -1
- }
- indexSize = 2
- arrLength /= 2
- valLength /= 2
- byteOffset /= 2
- }
- }
- function read (buf, i) {
- if (indexSize === 1) {
- return buf[i]
- } else {
- return buf.readUInt16BE(i * indexSize)
- }
- }
- var foundIndex = -1
- for (var i = byteOffset; i < arrLength; ++i) {
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
- } else {
- if (foundIndex !== -1) i -= i - foundIndex
- foundIndex = -1
- }
- }
- return -1
- }
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
- if (typeof byteOffset === 'string') {
- encoding = byteOffset
- byteOffset = 0
- } else if (byteOffset > 0x7fffffff) {
- byteOffset = 0x7fffffff
- } else if (byteOffset < -0x80000000) {
- byteOffset = -0x80000000
- }
- byteOffset >>= 0
- if (this.length === 0) return -1
- if (byteOffset >= this.length) return -1
- // Negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
- if (typeof val === 'string') {
- val = Buffer.from(val, encoding)
- }
- if (Buffer.isBuffer(val)) {
- // special case: looking for empty string/buffer always fails
- if (val.length === 0) {
- return -1
- }
- return arrayIndexOf(this, val, byteOffset, encoding)
- }
- if (typeof val === 'number') {
- if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
- return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
- }
- return arrayIndexOf(this, [ val ], byteOffset, encoding)
- }
- throw new TypeError('val must be string, number or Buffer')
- }
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
- return this.indexOf(val, byteOffset, encoding) !== -1
- }
- function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
- // must be an even number of digits
- var strLen = string.length
- if (strLen % 2 !== 0) throw new Error('Invalid hex string')
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; ++i) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (isNaN(parsed)) return i
- buf[offset + i] = parsed
- }
- return i
- }
- function utf8Write (buf, string, offset, length) {
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
- }
- function asciiWrite (buf, string, offset, length) {
- return blitBuffer(asciiToBytes(string), buf, offset, length)
- }
- function binaryWrite (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
- }
- function base64Write (buf, string, offset, length) {
- return blitBuffer(base64ToBytes(string), buf, offset, length)
- }
- function ucs2Write (buf, string, offset, length) {
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
- }
- Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Buffer#write(string)
- if (offset === undefined) {
- encoding = 'utf8'
- length = this.length
- offset = 0
- // Buffer#write(string, encoding)
- } else if (length === undefined && typeof offset === 'string') {
- encoding = offset
- length = this.length
- offset = 0
- // Buffer#write(string, offset[, length][, encoding])
- } else if (isFinite(offset)) {
- offset = offset | 0
- if (isFinite(length)) {
- length = length | 0
- if (encoding === undefined) encoding = 'utf8'
- } else {
- encoding = length
- length = undefined
- }
- // legacy write(string, encoding, offset, length) - remove in v0.13
- } else {
- throw new Error(
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
- )
- }
- var remaining = this.length - offset
- if (length === undefined || length > remaining) length = remaining
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
- throw new RangeError('Attempt to write outside buffer bounds')
- }
- if (!encoding) encoding = 'utf8'
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'hex':
- return hexWrite(this, string, offset, length)
- case 'utf8':
- case 'utf-8':
- return utf8Write(this, string, offset, length)
- case 'ascii':
- return asciiWrite(this, string, offset, length)
- case 'binary':
- return binaryWrite(this, string, offset, length)
- case 'base64':
- // Warning: maxLength not taken into account in base64Write
- return base64Write(this, string, offset, length)
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return ucs2Write(this, string, offset, length)
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
- }
- function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
- }
- function utf8Slice (buf, start, end) {
- end = Math.min(buf.length, end)
- var res = []
- var i = start
- while (i < end) {
- var firstByte = buf[i]
- var codePoint = null
- var bytesPerSequence = (firstByte > 0xEF) ? 4
- : (firstByte > 0xDF) ? 3
- : (firstByte > 0xBF) ? 2
- : 1
- if (i + bytesPerSequence <= end) {
- var secondByte, thirdByte, fourthByte, tempCodePoint
- switch (bytesPerSequence) {
- case 1:
- if (firstByte < 0x80) {
- codePoint = firstByte
- }
- break
- case 2:
- secondByte = buf[i + 1]
- if ((secondByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
- if (tempCodePoint > 0x7F) {
- codePoint = tempCodePoint
- }
- }
- break
- case 3:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
- codePoint = tempCodePoint
- }
- }
- break
- case 4:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- fourthByte = buf[i + 3]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
- codePoint = tempCodePoint
- }
- }
- }
- }
- if (codePoint === null) {
- // we did not generate a valid codePoint so insert a
- // replacement char (U+FFFD) and advance only 1 byte
- codePoint = 0xFFFD
- bytesPerSequence = 1
- } else if (codePoint > 0xFFFF) {
- // encode to utf16 (surrogate pair dance)
- codePoint -= 0x10000
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
- codePoint = 0xDC00 | codePoint & 0x3FF
- }
- res.push(codePoint)
- i += bytesPerSequence
- }
- return decodeCodePointsArray(res)
- }
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
- // the lowest limit is Chrome, with 0x10000 args.
- // We go 1 magnitude less, for safety
- var MAX_ARGUMENTS_LENGTH = 0x1000
- function decodeCodePointsArray (codePoints) {
- var len = codePoints.length
- if (len <= MAX_ARGUMENTS_LENGTH) {
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
- }
- // Decode in chunks to avoid "call stack size exceeded".
- var res = ''
- var i = 0
- while (i < len) {
- res += String.fromCharCode.apply(
- String,
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
- )
- }
- return res
- }
- function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
- }
- function binarySlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
- }
- function hexSlice (buf, start, end) {
- var len = buf.length
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
- var out = ''
- for (var i = start; i < end; ++i) {
- out += toHex(buf[i])
- }
- return out
- }
- function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
- }
- return res
- }
- Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
- if (end < start) end = start
- var newBuf
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- newBuf = this.subarray(start, end)
- newBuf.__proto__ = Buffer.prototype
- } else {
- var sliceLen = end - start
- newBuf = new Buffer(sliceLen, undefined)
- for (var i = 0; i < sliceLen; ++i) {
- newBuf[i] = this[i + start]
- }
- }
- return newBuf
- }
- /*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
- function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
- }
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- return val
- }
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
- return val
- }
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
- }
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
- }
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
- }
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
- }
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
- }
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
- }
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
- }
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
- }
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
- }
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
- }
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
- }
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
- }
- function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- }
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- byteLength = byteLength | 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- this[offset] = (value & 0xff)
- return offset + 1
- }
- function objectWriteUInt16 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
- (littleEndian ? i : 1 - i) * 8
- }
- }
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
- }
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
- }
- function objectWriteUInt32 (buf, value, offset, littleEndian) {
- if (value < 0) value = 0xffffffff + value + 1
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
- }
- }
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
- }
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
- }
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) {
- var limit = Math.pow(2, 8 * byteLength - 1)
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
- var i = 0
- var mul = 1
- var sub = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) {
- var limit = Math.pow(2, 8 * byteLength - 1)
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
- var i = byteLength - 1
- var mul = 1
- var sub = 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
- if (value < 0) value = 0xff + value + 1
- this[offset] = (value & 0xff)
- return offset + 1
- }
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- } else {
- objectWriteUInt16(this, value, offset, true)
- }
- return offset + 2
- }
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- } else {
- objectWriteUInt16(this, value, offset, false)
- }
- return offset + 2
- }
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- } else {
- objectWriteUInt32(this, value, offset, true)
- }
- return offset + 4
- }
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset | 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- if (Buffer.TYPED_ARRAY_SUPPORT) {
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- } else {
- objectWriteUInt32(this, value, offset, false)
- }
- return offset + 4
- }
- function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- if (offset < 0) throw new RangeError('Index out of range')
- }
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
- }
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
- }
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
- }
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
- }
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (targetStart >= target.length) targetStart = target.length
- if (!targetStart) targetStart = 0
- if (end > 0 && end < start) end = start
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
- // Fatal error conditions
- if (targetStart < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - targetStart < end - start) {
- end = target.length - targetStart + start
- }
- var len = end - start
- var i
- if (this === target && start < targetStart && targetStart < end) {
- // descending copy from end
- for (i = len - 1; i >= 0; --i) {
- target[i + targetStart] = this[i + start]
- }
- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
- // ascending copy from start
- for (i = 0; i < len; ++i) {
- target[i + targetStart] = this[i + start]
- }
- } else {
- Uint8Array.prototype.set.call(
- target,
- this.subarray(start, start + len),
- targetStart
- )
- }
- return len
- }
- // Usage:
- // buffer.fill(number[, offset[, end]])
- // buffer.fill(buffer[, offset[, end]])
- // buffer.fill(string[, offset[, end]][, encoding])
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
- // Handle string cases:
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = this.length
- } else if (typeof end === 'string') {
- encoding = end
- end = this.length
- }
- if (val.length === 1) {
- var code = val.charCodeAt(0)
- if (code < 256) {
- val = code
- }
- }
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- } else if (typeof val === 'number') {
- val = val & 255
- }
- // Invalid ranges are not set to a default, so can range check early.
- if (start < 0 || this.length < start || this.length < end) {
- throw new RangeError('Out of range index')
- }
- if (end <= start) {
- return this
- }
- start = start >>> 0
- end = end === undefined ? this.length : end >>> 0
- if (!val) val = 0
- var i
- if (typeof val === 'number') {
- for (i = start; i < end; ++i) {
- this[i] = val
- }
- } else {
- var bytes = Buffer.isBuffer(val)
- ? val
- : utf8ToBytes(new Buffer(val, encoding).toString())
- var len = bytes.length
- for (i = 0; i < end - start; ++i) {
- this[i + start] = bytes[i % len]
- }
- }
- return this
- }
- // HELPER FUNCTIONS
- // ================
- var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
- function base64clean (str) {
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = stringtrim(str).replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
- }
- function stringtrim (str) {
- if (str.trim) return str.trim()
- return str.replace(/^\s+|\s+$/g, '')
- }
- function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
- }
- function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
- for (var i = 0; i < length; ++i) {
- codePoint = string.charCodeAt(i)
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (!leadSurrogate) {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- }
- // valid lead
- leadSurrogate = codePoint
- continue
- }
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- }
- // valid surrogate pair
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- }
- leadSurrogate = null
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x110000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
- return bytes
- }
- function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
- }
- function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- if ((units -= 2) < 0) break
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
- return byteArray
- }
- function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
- }
- function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; ++i) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
- }
- function isnan (val) {
- return val !== val // eslint-disable-line no-self-compare
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(13)))
- /***/ },
- /* 2 */
- /***/ function(module, exports) {
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- /***/ },
- /* 3 */
- /***/ function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(7);
- module.exports = function(it){
- if(!isObject(it))throw TypeError(it + ' is not an object!');
- return it;
- };
- /***/ },
- /* 4 */
- /***/ function(module, exports) {
- // shim for using process in browser
- var process = module.exports = {};
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
- var cachedSetTimeout;
- var cachedClearTimeout;
- (function () {
- try {
- cachedSetTimeout = setTimeout;
- } catch (e) {
- cachedSetTimeout = function () {
- throw new Error('setTimeout is not defined');
- }
- }
- try {
- cachedClearTimeout = clearTimeout;
- } catch (e) {
- cachedClearTimeout = function () {
- throw new Error('clearTimeout is not defined');
- }
- }
- } ())
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = cachedSetTimeout(cleanUpNextTick);
- draining = true;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- cachedClearTimeout(timeout);
- }
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- cachedSetTimeout(drainQueue, 0);
- }
- };
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
- function noop() {}
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
- /***/ },
- /* 5 */
- /***/ function(module, exports) {
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
- var global = module.exports = typeof window != 'undefined' && window.Math == Math
- ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
- if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
- /***/ },
- /* 6 */
- /***/ function(module, exports) {
- module.exports = function(exec){
- try {
- return !!exec();
- } catch(e){
- return true;
- }
- };
- /***/ },
- /* 7 */
- /***/ function(module, exports) {
- module.exports = function(it){
- return typeof it === 'object' ? it !== null : typeof it === 'function';
- };
- /***/ },
- /* 8 */
- /***/ function(module, exports, __webpack_require__) {
- var store = __webpack_require__(92)('wks')
- , uid = __webpack_require__(53)
- , Symbol = __webpack_require__(5).Symbol
- , USE_SYMBOL = typeof Symbol == 'function';
- var $exports = module.exports = function(name){
- return store[name] || (store[name] =
- USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
- };
- $exports.store = store;
- /***/ },
- /* 9 */
- /***/ function(module, exports, __webpack_require__) {
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Stream;
- var EE = __webpack_require__(30).EventEmitter;
- var inherits = __webpack_require__(2);
- inherits(Stream, EE);
- Stream.Readable = __webpack_require__(550);
- Stream.Writable = __webpack_require__(552);
- Stream.Duplex = __webpack_require__(214);
- Stream.Transform = __webpack_require__(551);
- Stream.PassThrough = __webpack_require__(549);
- // Backwards-compat with node 0.4.x
- Stream.Stream = Stream;
- // old-style streams. Note that the pipe method (the only relevant
- // part of this class) is overridden in the Readable class.
- function Stream() {
- EE.call(this);
- }
- Stream.prototype.pipe = function(dest, options) {
- var source = this;
- function ondata(chunk) {
- if (dest.writable) {
- if (false === dest.write(chunk) && source.pause) {
- source.pause();
- }
- }
- }
- source.on('data', ondata);
- function ondrain() {
- if (source.readable && source.resume) {
- source.resume();
- }
- }
- dest.on('drain', ondrain);
- // If the 'end' option is not supplied, dest.end() will be called when
- // source gets the 'end' or 'close' events. Only dest.end() once.
- if (!dest._isStdio && (!options || options.end !== false)) {
- source.on('end', onend);
- source.on('close', onclose);
- }
- var didOnEnd = false;
- function onend() {
- if (didOnEnd) return;
- didOnEnd = true;
- dest.end();
- }
- function onclose() {
- if (didOnEnd) return;
- didOnEnd = true;
- if (typeof dest.destroy === 'function') dest.destroy();
- }
- // don't leave dangling pipes when there are errors.
- function onerror(er) {
- cleanup();
- if (EE.listenerCount(this, 'error') === 0) {
- throw er; // Unhandled stream error in pipe.
- }
- }
- source.on('error', onerror);
- dest.on('error', onerror);
- // remove all the event listeners that were added.
- function cleanup() {
- source.removeListener('data', ondata);
- dest.removeListener('drain', ondrain);
- source.removeListener('end', onend);
- source.removeListener('close', onclose);
- source.removeListener('error', onerror);
- dest.removeListener('error', onerror);
- source.removeListener('end', cleanup);
- source.removeListener('close', cleanup);
- dest.removeListener('close', cleanup);
- }
- source.on('end', cleanup);
- source.on('close', cleanup);
- dest.on('close', cleanup);
- dest.emit('pipe', source);
- // Allow for unix-like usage: A.pipe(B).pipe(C)
- return dest;
- };
- /***/ },
- /* 10 */
- /***/ function(module, exports, __webpack_require__) {
- // Thank's IE8 for his funny defineProperty
- module.exports = !__webpack_require__(6)(function(){
- return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
- });
- /***/ },
- /* 11 */
- /***/ function(module, exports, __webpack_require__) {
- var anObject = __webpack_require__(3)
- , IE8_DOM_DEFINE = __webpack_require__(176)
- , toPrimitive = __webpack_require__(34)
- , dP = Object.defineProperty;
- exports.f = __webpack_require__(10) ? Object.defineProperty : function defineProperty(O, P, Attributes){
- anObject(O);
- P = toPrimitive(P, true);
- anObject(Attributes);
- if(IE8_DOM_DEFINE)try {
- return dP(O, P, Attributes);
- } catch(e){ /* empty */ }
- if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
- if('value' in Attributes)O[P] = Attributes.value;
- return O;
- };
- /***/ },
- /* 12 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
- 'use strict';
- // Utils
- function assert (val, msg) {
- if (!val) throw new Error(msg || 'Assertion failed');
- }
- // Could use `inherits` module, but don't want to move from single file
- // architecture yet.
- function inherits (ctor, superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
- }
- // BN
- function BN (number, base, endian) {
- if (BN.isBN(number)) {
- return number;
- }
- this.negative = 0;
- this.words = null;
- this.length = 0;
- // Reduction context
- this.red = null;
- if (number !== null) {
- if (base === 'le' || base === 'be') {
- endian = base;
- base = 10;
- }
- this._init(number || 0, base || 10, endian || 'be');
- }
- }
- if (typeof module === 'object') {
- module.exports = BN;
- } else {
- exports.BN = BN;
- }
- BN.BN = BN;
- BN.wordSize = 26;
- var Buffer;
- try {
- Buffer = __webpack_require__(1).Buffer;
- } catch (e) {
- }
- BN.isBN = function isBN (num) {
- return num !== null && typeof num === 'object' &&
- num.constructor.name === 'BN' && Array.isArray(num.words);
- };
- BN.max = function max (left, right) {
- if (left.cmp(right) > 0) return left;
- return right;
- };
- BN.min = function min (left, right) {
- if (left.cmp(right) < 0) return left;
- return right;
- };
- BN.prototype._init = function init (number, base, endian) {
- if (typeof number === 'number') {
- return this._initNumber(number, base, endian);
- }
- if (typeof number === 'object') {
- return this._initArray(number, base, endian);
- }
- if (base === 'hex') {
- base = 16;
- }
- assert(base === (base | 0) && base >= 2 && base <= 36);
- number = number.toString().replace(/\s+/g, '');
- var start = 0;
- if (number[0] === '-') {
- start++;
- }
- if (base === 16) {
- this._parseHex(number, start);
- } else {
- this._parseBase(number, base, start);
- }
- if (number[0] === '-') {
- this.negative = 1;
- }
- this.strip();
- if (endian !== 'le') return;
- this._initArray(this.toArray(), base, endian);
- };
- BN.prototype._initNumber = function _initNumber (number, base, endian) {
- if (number < 0) {
- this.negative = 1;
- number = -number;
- }
- if (number < 0x4000000) {
- this.words = [ number & 0x3ffffff ];
- this.length = 1;
- } else if (number < 0x10000000000000) {
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff
- ];
- this.length = 2;
- } else {
- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff,
- 1
- ];
- this.length = 3;
- }
- if (endian !== 'le') return;
- // Reverse the bytes
- this._initArray(this.toArray(), base, endian);
- };
- BN.prototype._initArray = function _initArray (number, base, endian) {
- // Perhaps a Uint8Array
- assert(typeof number.length === 'number');
- if (number.length <= 0) {
- this.words = [ 0 ];
- this.length = 1;
- return this;
- }
- this.length = Math.ceil(number.length / 3);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- var j, w;
- var off = 0;
- if (endian === 'be') {
- for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
- w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- } else if (endian === 'le') {
- for (i = 0, j = 0; i < number.length; i += 3) {
- w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- }
- return this.strip();
- };
- function parseHex (str, start, end) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
- r <<= 4;
- // 'a' - 'f'
- if (c >= 49 && c <= 54) {
- r |= c - 49 + 0xa;
- // 'A' - 'F'
- } else if (c >= 17 && c <= 22) {
- r |= c - 17 + 0xa;
- // '0' - '9'
- } else {
- r |= c & 0xf;
- }
- }
- return r;
- }
- BN.prototype._parseHex = function _parseHex (number, start) {
- // Create possibly bigger array to ensure that it fits the number
- this.length = Math.ceil((number.length - start) / 6);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- var j, w;
- // Scan 24-bit chunks and add them to the number
- var off = 0;
- for (i = number.length - 6, j = 0; i >= start; i -= 6) {
- w = parseHex(number, i, i + 6);
- this.words[j] |= (w << off) & 0x3ffffff;
- // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- if (i + 6 !== start) {
- w = parseHex(number, start, i + 6);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
- }
- this.strip();
- };
- function parseBase (str, start, end, mul) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
- r *= mul;
- // 'a'
- if (c >= 49) {
- r += c - 49 + 0xa;
- // 'A'
- } else if (c >= 17) {
- r += c - 17 + 0xa;
- // '0' - '9'
- } else {
- r += c;
- }
- }
- return r;
- }
- BN.prototype._parseBase = function _parseBase (number, base, start) {
- // Initialize as zero
- this.words = [ 0 ];
- this.length = 1;
- // Find length of limb in base
- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
- limbLen++;
- }
- limbLen--;
- limbPow = (limbPow / base) | 0;
- var total = number.length - start;
- var mod = total % limbLen;
- var end = Math.min(total, total - mod) + start;
- var word = 0;
- for (var i = start; i < end; i += limbLen) {
- word = parseBase(number, i, i + limbLen, base);
- this.imuln(limbPow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- if (mod !== 0) {
- var pow = 1;
- word = parseBase(number, i, number.length, base);
- for (i = 0; i < mod; i++) {
- pow *= base;
- }
- this.imuln(pow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- };
- BN.prototype.copy = function copy (dest) {
- dest.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- dest.words[i] = this.words[i];
- }
- dest.length = this.length;
- dest.negative = this.negative;
- dest.red = this.red;
- };
- BN.prototype.clone = function clone () {
- var r = new BN(null);
- this.copy(r);
- return r;
- };
- BN.prototype._expand = function _expand (size) {
- while (this.length < size) {
- this.words[this.length++] = 0;
- }
- return this;
- };
- // Remove leading `0` from `this`
- BN.prototype.strip = function strip () {
- while (this.length > 1 && this.words[this.length - 1] === 0) {
- this.length--;
- }
- return this._normSign();
- };
- BN.prototype._normSign = function _normSign () {
- // -0 = 0
- if (this.length === 1 && this.words[0] === 0) {
- this.negative = 0;
- }
- return this;
- };
- BN.prototype.inspect = function inspect () {
- return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
- };
- /*
- var zeros = [];
- var groupSizes = [];
- var groupBases = [];
- var s = '';
- var i = -1;
- while (++i < BN.wordSize) {
- zeros[i] = s;
- s += '0';
- }
- groupSizes[0] = 0;
- groupSizes[1] = 0;
- groupBases[0] = 0;
- groupBases[1] = 0;
- var base = 2 - 1;
- while (++base < 36 + 1) {
- var groupSize = 0;
- var groupBase = 1;
- while (groupBase < (1 << BN.wordSize) / base) {
- groupBase *= base;
- groupSize += 1;
- }
- groupSizes[base] = groupSize;
- groupBases[base] = groupBase;
- }
- */
- var zeros = [
- '',
- '0',
- '00',
- '000',
- '0000',
- '00000',
- '000000',
- '0000000',
- '00000000',
- '000000000',
- '0000000000',
- '00000000000',
- '000000000000',
- '0000000000000',
- '00000000000000',
- '000000000000000',
- '0000000000000000',
- '00000000000000000',
- '000000000000000000',
- '0000000000000000000',
- '00000000000000000000',
- '000000000000000000000',
- '0000000000000000000000',
- '00000000000000000000000',
- '000000000000000000000000',
- '0000000000000000000000000'
- ];
- var groupSizes = [
- 0, 0,
- 25, 16, 12, 11, 10, 9, 8,
- 8, 7, 7, 7, 7, 6, 6,
- 6, 6, 6, 6, 6, 5, 5,
- 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5
- ];
- var groupBases = [
- 0, 0,
- 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
- 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
- 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
- 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
- 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
- ];
- BN.prototype.toString = function toString (base, padding) {
- base = base || 10;
- padding = padding | 0 || 1;
- var out;
- if (base === 16 || base === 'hex') {
- out = '';
- var off = 0;
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = this.words[i];
- var word = (((w << off) | carry) & 0xffffff).toString(16);
- carry = (w >>> (24 - off)) & 0xffffff;
- if (carry !== 0 || i !== this.length - 1) {
- out = zeros[6 - word.length] + word + out;
- } else {
- out = word + out;
- }
- off += 2;
- if (off >= 26) {
- off -= 26;
- i--;
- }
- }
- if (carry !== 0) {
- out = carry.toString(16) + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- if (base === (base | 0) && base >= 2 && base <= 36) {
- // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
- var groupSize = groupSizes[base];
- // var groupBase = Math.pow(base, groupSize);
- var groupBase = groupBases[base];
- out = '';
- var c = this.clone();
- c.negative = 0;
- while (!c.isZero()) {
- var r = c.modn(groupBase).toString(base);
- c = c.idivn(groupBase);
- if (!c.isZero()) {
- out = zeros[groupSize - r.length] + r + out;
- } else {
- out = r + out;
- }
- }
- if (this.isZero()) {
- out = '0' + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- assert(false, 'Base should be between 2 and 36');
- };
- BN.prototype.toNumber = function toNumber () {
- var ret = this.words[0];
- if (this.length === 2) {
- ret += this.words[1] * 0x4000000;
- } else if (this.length === 3 && this.words[2] === 0x01) {
- // NOTE: at this stage it is known that the top bit is set
- ret += 0x10000000000000 + (this.words[1] * 0x4000000);
- } else if (this.length > 2) {
- assert(false, 'Number can only safely store up to 53 bits');
- }
- return (this.negative !== 0) ? -ret : ret;
- };
- BN.prototype.toJSON = function toJSON () {
- return this.toString(16);
- };
- BN.prototype.toBuffer = function toBuffer (endian, length) {
- assert(typeof Buffer !== 'undefined');
- return this.toArrayLike(Buffer, endian, length);
- };
- BN.prototype.toArray = function toArray (endian, length) {
- return this.toArrayLike(Array, endian, length);
- };
- BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
- var byteLength = this.byteLength();
- var reqLength = length || Math.max(1, byteLength);
- assert(byteLength <= reqLength, 'byte array longer than desired length');
- assert(reqLength > 0, 'Requested array length <= 0');
- this.strip();
- var littleEndian = endian === 'le';
- var res = new ArrayType(reqLength);
- var b, i;
- var q = this.clone();
- if (!littleEndian) {
- // Assume big-endian
- for (i = 0; i < reqLength - byteLength; i++) {
- res[i] = 0;
- }
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[reqLength - i - 1] = b;
- }
- } else {
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[i] = b;
- }
- for (; i < reqLength; i++) {
- res[i] = 0;
- }
- }
- return res;
- };
- if (Math.clz32) {
- BN.prototype._countBits = function _countBits (w) {
- return 32 - Math.clz32(w);
- };
- } else {
- BN.prototype._countBits = function _countBits (w) {
- var t = w;
- var r = 0;
- if (t >= 0x1000) {
- r += 13;
- t >>>= 13;
- }
- if (t >= 0x40) {
- r += 7;
- t >>>= 7;
- }
- if (t >= 0x8) {
- r += 4;
- t >>>= 4;
- }
- if (t >= 0x02) {
- r += 2;
- t >>>= 2;
- }
- return r + t;
- };
- }
- BN.prototype._zeroBits = function _zeroBits (w) {
- // Short-cut
- if (w === 0) return 26;
- var t = w;
- var r = 0;
- if ((t & 0x1fff) === 0) {
- r += 13;
- t >>>= 13;
- }
- if ((t & 0x7f) === 0) {
- r += 7;
- t >>>= 7;
- }
- if ((t & 0xf) === 0) {
- r += 4;
- t >>>= 4;
- }
- if ((t & 0x3) === 0) {
- r += 2;
- t >>>= 2;
- }
- if ((t & 0x1) === 0) {
- r++;
- }
- return r;
- };
- // Return number of used bits in a BN
- BN.prototype.bitLength = function bitLength () {
- var w = this.words[this.length - 1];
- var hi = this._countBits(w);
- return (this.length - 1) * 26 + hi;
- };
- function toBitArray (num) {
- var w = new Array(num.bitLength());
- for (var bit = 0; bit < w.length; bit++) {
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
- }
- return w;
- }
- // Number of trailing zero bits
- BN.prototype.zeroBits = function zeroBits () {
- if (this.isZero()) return 0;
- var r = 0;
- for (var i = 0; i < this.length; i++) {
- var b = this._zeroBits(this.words[i]);
- r += b;
- if (b !== 26) break;
- }
- return r;
- };
- BN.prototype.byteLength = function byteLength () {
- return Math.ceil(this.bitLength() / 8);
- };
- BN.prototype.toTwos = function toTwos (width) {
- if (this.negative !== 0) {
- return this.abs().inotn(width).iaddn(1);
- }
- return this.clone();
- };
- BN.prototype.fromTwos = function fromTwos (width) {
- if (this.testn(width - 1)) {
- return this.notn(width).iaddn(1).ineg();
- }
- return this.clone();
- };
- BN.prototype.isNeg = function isNeg () {
- return this.negative !== 0;
- };
- // Return negative clone of `this`
- BN.prototype.neg = function neg () {
- return this.clone().ineg();
- };
- BN.prototype.ineg = function ineg () {
- if (!this.isZero()) {
- this.negative ^= 1;
- }
- return this;
- };
- // Or `num` with `this` in-place
- BN.prototype.iuor = function iuor (num) {
- while (this.length < num.length) {
- this.words[this.length++] = 0;
- }
- for (var i = 0; i < num.length; i++) {
- this.words[i] = this.words[i] | num.words[i];
- }
- return this.strip();
- };
- BN.prototype.ior = function ior (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuor(num);
- };
- // Or `num` with `this`
- BN.prototype.or = function or (num) {
- if (this.length > num.length) return this.clone().ior(num);
- return num.clone().ior(this);
- };
- BN.prototype.uor = function uor (num) {
- if (this.length > num.length) return this.clone().iuor(num);
- return num.clone().iuor(this);
- };
- // And `num` with `this` in-place
- BN.prototype.iuand = function iuand (num) {
- // b = min-length(num, this)
- var b;
- if (this.length > num.length) {
- b = num;
- } else {
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = this.words[i] & num.words[i];
- }
- this.length = b.length;
- return this.strip();
- };
- BN.prototype.iand = function iand (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuand(num);
- };
- // And `num` with `this`
- BN.prototype.and = function and (num) {
- if (this.length > num.length) return this.clone().iand(num);
- return num.clone().iand(this);
- };
- BN.prototype.uand = function uand (num) {
- if (this.length > num.length) return this.clone().iuand(num);
- return num.clone().iuand(this);
- };
- // Xor `num` with `this` in-place
- BN.prototype.iuxor = function iuxor (num) {
- // a.length > b.length
- var a;
- var b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = a.words[i] ^ b.words[i];
- }
- if (this !== a) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = a.length;
- return this.strip();
- };
- BN.prototype.ixor = function ixor (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuxor(num);
- };
- // Xor `num` with `this`
- BN.prototype.xor = function xor (num) {
- if (this.length > num.length) return this.clone().ixor(num);
- return num.clone().ixor(this);
- };
- BN.prototype.uxor = function uxor (num) {
- if (this.length > num.length) return this.clone().iuxor(num);
- return num.clone().iuxor(this);
- };
- // Not ``this`` with ``width`` bitwidth
- BN.prototype.inotn = function inotn (width) {
- assert(typeof width === 'number' && width >= 0);
- var bytesNeeded = Math.ceil(width / 26) | 0;
- var bitsLeft = width % 26;
- // Extend the buffer with leading zeroes
- this._expand(bytesNeeded);
- if (bitsLeft > 0) {
- bytesNeeded--;
- }
- // Handle complete words
- for (var i = 0; i < bytesNeeded; i++) {
- this.words[i] = ~this.words[i] & 0x3ffffff;
- }
- // Handle the residue
- if (bitsLeft > 0) {
- this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
- }
- // And remove leading zeroes
- return this.strip();
- };
- BN.prototype.notn = function notn (width) {
- return this.clone().inotn(width);
- };
- // Set `bit` of `this`
- BN.prototype.setn = function setn (bit, val) {
- assert(typeof bit === 'number' && bit >= 0);
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- this._expand(off + 1);
- if (val) {
- this.words[off] = this.words[off] | (1 << wbit);
- } else {
- this.words[off] = this.words[off] & ~(1 << wbit);
- }
- return this.strip();
- };
- // Add `num` to `this` in-place
- BN.prototype.iadd = function iadd (num) {
- var r;
- // negative + positive
- if (this.negative !== 0 && num.negative === 0) {
- this.negative = 0;
- r = this.isub(num);
- this.negative ^= 1;
- return this._normSign();
- // positive + negative
- } else if (this.negative === 0 && num.negative !== 0) {
- num.negative = 0;
- r = this.isub(num);
- num.negative = 1;
- return r._normSign();
- }
- // a.length > b.length
- var a, b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- this.length = a.length;
- if (carry !== 0) {
- this.words[this.length] = carry;
- this.length++;
- // Copy the rest of the words
- } else if (a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- return this;
- };
- // Add `num` to `this`
- BN.prototype.add = function add (num) {
- var res;
- if (num.negative !== 0 && this.negative === 0) {
- num.negative = 0;
- res = this.sub(num);
- num.negative ^= 1;
- return res;
- } else if (num.negative === 0 && this.negative !== 0) {
- this.negative = 0;
- res = num.sub(this);
- this.negative = 1;
- return res;
- }
- if (this.length > num.length) return this.clone().iadd(num);
- return num.clone().iadd(this);
- };
- // Subtract `num` from `this` in-place
- BN.prototype.isub = function isub (num) {
- // this - (-num) = this + num
- if (num.negative !== 0) {
- num.negative = 0;
- var r = this.iadd(num);
- num.negative = 1;
- return r._normSign();
- // -this - num = -(this + num)
- } else if (this.negative !== 0) {
- this.negative = 0;
- this.iadd(num);
- this.negative = 1;
- return this._normSign();
- }
- // At this point both numbers are positive
- var cmp = this.cmp(num);
- // Optimization - zeroify
- if (cmp === 0) {
- this.negative = 0;
- this.length = 1;
- this.words[0] = 0;
- return this;
- }
- // a > b
- var a, b;
- if (cmp > 0) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- // Copy rest of the words
- if (carry === 0 && i < a.length && a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = Math.max(this.length, i);
- if (a !== this) {
- this.negative = 1;
- }
- return this.strip();
- };
- // Subtract `num` from `this`
- BN.prototype.sub = function sub (num) {
- return this.clone().isub(num);
- };
- function smallMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- var len = (self.length + num.length) | 0;
- out.length = len;
- len = (len - 1) | 0;
- // Peel one iteration (compiler can't do it, because of code complexity)
- var a = self.words[0] | 0;
- var b = num.words[0] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- var carry = (r / 0x4000000) | 0;
- out.words[0] = lo;
- for (var k = 1; k < len; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = carry >>> 26;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = (k - j) | 0;
- a = self.words[i] | 0;
- b = num.words[j] | 0;
- r = a * b + rword;
- ncarry += (r / 0x4000000) | 0;
- rword = r & 0x3ffffff;
- }
- out.words[k] = rword | 0;
- carry = ncarry | 0;
- }
- if (carry !== 0) {
- out.words[k] = carry | 0;
- } else {
- out.length--;
- }
- return out.strip();
- }
- // TODO(indutny): it may be reasonable to omit it for users who don't need
- // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
- // multiplication (like elliptic secp256k1).
- var comb10MulTo = function comb10MulTo (self, num, out) {
- var a = self.words;
- var b = num.words;
- var o = out.words;
- var c = 0;
- var lo;
- var mid;
- var hi;
- var a0 = a[0] | 0;
- var al0 = a0 & 0x1fff;
- var ah0 = a0 >>> 13;
- var a1 = a[1] | 0;
- var al1 = a1 & 0x1fff;
- var ah1 = a1 >>> 13;
- var a2 = a[2] | 0;
- var al2 = a2 & 0x1fff;
- var ah2 = a2 >>> 13;
- var a3 = a[3] | 0;
- var al3 = a3 & 0x1fff;
- var ah3 = a3 >>> 13;
- var a4 = a[4] | 0;
- var al4 = a4 & 0x1fff;
- var ah4 = a4 >>> 13;
- var a5 = a[5] | 0;
- var al5 = a5 & 0x1fff;
- var ah5 = a5 >>> 13;
- var a6 = a[6] | 0;
- var al6 = a6 & 0x1fff;
- var ah6 = a6 >>> 13;
- var a7 = a[7] | 0;
- var al7 = a7 & 0x1fff;
- var ah7 = a7 >>> 13;
- var a8 = a[8] | 0;
- var al8 = a8 & 0x1fff;
- var ah8 = a8 >>> 13;
- var a9 = a[9] | 0;
- var al9 = a9 & 0x1fff;
- var ah9 = a9 >>> 13;
- var b0 = b[0] | 0;
- var bl0 = b0 & 0x1fff;
- var bh0 = b0 >>> 13;
- var b1 = b[1] | 0;
- var bl1 = b1 & 0x1fff;
- var bh1 = b1 >>> 13;
- var b2 = b[2] | 0;
- var bl2 = b2 & 0x1fff;
- var bh2 = b2 >>> 13;
- var b3 = b[3] | 0;
- var bl3 = b3 & 0x1fff;
- var bh3 = b3 >>> 13;
- var b4 = b[4] | 0;
- var bl4 = b4 & 0x1fff;
- var bh4 = b4 >>> 13;
- var b5 = b[5] | 0;
- var bl5 = b5 & 0x1fff;
- var bh5 = b5 >>> 13;
- var b6 = b[6] | 0;
- var bl6 = b6 & 0x1fff;
- var bh6 = b6 >>> 13;
- var b7 = b[7] | 0;
- var bl7 = b7 & 0x1fff;
- var bh7 = b7 >>> 13;
- var b8 = b[8] | 0;
- var bl8 = b8 & 0x1fff;
- var bh8 = b8 >>> 13;
- var b9 = b[9] | 0;
- var bl9 = b9 & 0x1fff;
- var bh9 = b9 >>> 13;
- out.negative = self.negative ^ num.negative;
- out.length = 19;
- /* k = 0 */
- lo = Math.imul(al0, bl0);
- mid = Math.imul(al0, bh0);
- mid = (mid + Math.imul(ah0, bl0)) | 0;
- hi = Math.imul(ah0, bh0);
- var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
- w0 &= 0x3ffffff;
- /* k = 1 */
- lo = Math.imul(al1, bl0);
- mid = Math.imul(al1, bh0);
- mid = (mid + Math.imul(ah1, bl0)) | 0;
- hi = Math.imul(ah1, bh0);
- lo = (lo + Math.imul(al0, bl1)) | 0;
- mid = (mid + Math.imul(al0, bh1)) | 0;
- mid = (mid + Math.imul(ah0, bl1)) | 0;
- hi = (hi + Math.imul(ah0, bh1)) | 0;
- var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
- w1 &= 0x3ffffff;
- /* k = 2 */
- lo = Math.imul(al2, bl0);
- mid = Math.imul(al2, bh0);
- mid = (mid + Math.imul(ah2, bl0)) | 0;
- hi = Math.imul(ah2, bh0);
- lo = (lo + Math.imul(al1, bl1)) | 0;
- mid = (mid + Math.imul(al1, bh1)) | 0;
- mid = (mid + Math.imul(ah1, bl1)) | 0;
- hi = (hi + Math.imul(ah1, bh1)) | 0;
- lo = (lo + Math.imul(al0, bl2)) | 0;
- mid = (mid + Math.imul(al0, bh2)) | 0;
- mid = (mid + Math.imul(ah0, bl2)) | 0;
- hi = (hi + Math.imul(ah0, bh2)) | 0;
- var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
- w2 &= 0x3ffffff;
- /* k = 3 */
- lo = Math.imul(al3, bl0);
- mid = Math.imul(al3, bh0);
- mid = (mid + Math.imul(ah3, bl0)) | 0;
- hi = Math.imul(ah3, bh0);
- lo = (lo + Math.imul(al2, bl1)) | 0;
- mid = (mid + Math.imul(al2, bh1)) | 0;
- mid = (mid + Math.imul(ah2, bl1)) | 0;
- hi = (hi + Math.imul(ah2, bh1)) | 0;
- lo = (lo + Math.imul(al1, bl2)) | 0;
- mid = (mid + Math.imul(al1, bh2)) | 0;
- mid = (mid + Math.imul(ah1, bl2)) | 0;
- hi = (hi + Math.imul(ah1, bh2)) | 0;
- lo = (lo + Math.imul(al0, bl3)) | 0;
- mid = (mid + Math.imul(al0, bh3)) | 0;
- mid = (mid + Math.imul(ah0, bl3)) | 0;
- hi = (hi + Math.imul(ah0, bh3)) | 0;
- var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
- w3 &= 0x3ffffff;
- /* k = 4 */
- lo = Math.imul(al4, bl0);
- mid = Math.imul(al4, bh0);
- mid = (mid + Math.imul(ah4, bl0)) | 0;
- hi = Math.imul(ah4, bh0);
- lo = (lo + Math.imul(al3, bl1)) | 0;
- mid = (mid + Math.imul(al3, bh1)) | 0;
- mid = (mid + Math.imul(ah3, bl1)) | 0;
- hi = (hi + Math.imul(ah3, bh1)) | 0;
- lo = (lo + Math.imul(al2, bl2)) | 0;
- mid = (mid + Math.imul(al2, bh2)) | 0;
- mid = (mid + Math.imul(ah2, bl2)) | 0;
- hi = (hi + Math.imul(ah2, bh2)) | 0;
- lo = (lo + Math.imul(al1, bl3)) | 0;
- mid = (mid + Math.imul(al1, bh3)) | 0;
- mid = (mid + Math.imul(ah1, bl3)) | 0;
- hi = (hi + Math.imul(ah1, bh3)) | 0;
- lo = (lo + Math.imul(al0, bl4)) | 0;
- mid = (mid + Math.imul(al0, bh4)) | 0;
- mid = (mid + Math.imul(ah0, bl4)) | 0;
- hi = (hi + Math.imul(ah0, bh4)) | 0;
- var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
- w4 &= 0x3ffffff;
- /* k = 5 */
- lo = Math.imul(al5, bl0);
- mid = Math.imul(al5, bh0);
- mid = (mid + Math.imul(ah5, bl0)) | 0;
- hi = Math.imul(ah5, bh0);
- lo = (lo + Math.imul(al4, bl1)) | 0;
- mid = (mid + Math.imul(al4, bh1)) | 0;
- mid = (mid + Math.imul(ah4, bl1)) | 0;
- hi = (hi + Math.imul(ah4, bh1)) | 0;
- lo = (lo + Math.imul(al3, bl2)) | 0;
- mid = (mid + Math.imul(al3, bh2)) | 0;
- mid = (mid + Math.imul(ah3, bl2)) | 0;
- hi = (hi + Math.imul(ah3, bh2)) | 0;
- lo = (lo + Math.imul(al2, bl3)) | 0;
- mid = (mid + Math.imul(al2, bh3)) | 0;
- mid = (mid + Math.imul(ah2, bl3)) | 0;
- hi = (hi + Math.imul(ah2, bh3)) | 0;
- lo = (lo + Math.imul(al1, bl4)) | 0;
- mid = (mid + Math.imul(al1, bh4)) | 0;
- mid = (mid + Math.imul(ah1, bl4)) | 0;
- hi = (hi + Math.imul(ah1, bh4)) | 0;
- lo = (lo + Math.imul(al0, bl5)) | 0;
- mid = (mid + Math.imul(al0, bh5)) | 0;
- mid = (mid + Math.imul(ah0, bl5)) | 0;
- hi = (hi + Math.imul(ah0, bh5)) | 0;
- var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
- w5 &= 0x3ffffff;
- /* k = 6 */
- lo = Math.imul(al6, bl0);
- mid = Math.imul(al6, bh0);
- mid = (mid + Math.imul(ah6, bl0)) | 0;
- hi = Math.imul(ah6, bh0);
- lo = (lo + Math.imul(al5, bl1)) | 0;
- mid = (mid + Math.imul(al5, bh1)) | 0;
- mid = (mid + Math.imul(ah5, bl1)) | 0;
- hi = (hi + Math.imul(ah5, bh1)) | 0;
- lo = (lo + Math.imul(al4, bl2)) | 0;
- mid = (mid + Math.imul(al4, bh2)) | 0;
- mid = (mid + Math.imul(ah4, bl2)) | 0;
- hi = (hi + Math.imul(ah4, bh2)) | 0;
- lo = (lo + Math.imul(al3, bl3)) | 0;
- mid = (mid + Math.imul(al3, bh3)) | 0;
- mid = (mid + Math.imul(ah3, bl3)) | 0;
- hi = (hi + Math.imul(ah3, bh3)) | 0;
- lo = (lo + Math.imul(al2, bl4)) | 0;
- mid = (mid + Math.imul(al2, bh4)) | 0;
- mid = (mid + Math.imul(ah2, bl4)) | 0;
- hi = (hi + Math.imul(ah2, bh4)) | 0;
- lo = (lo + Math.imul(al1, bl5)) | 0;
- mid = (mid + Math.imul(al1, bh5)) | 0;
- mid = (mid + Math.imul(ah1, bl5)) | 0;
- hi = (hi + Math.imul(ah1, bh5)) | 0;
- lo = (lo + Math.imul(al0, bl6)) | 0;
- mid = (mid + Math.imul(al0, bh6)) | 0;
- mid = (mid + Math.imul(ah0, bl6)) | 0;
- hi = (hi + Math.imul(ah0, bh6)) | 0;
- var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
- w6 &= 0x3ffffff;
- /* k = 7 */
- lo = Math.imul(al7, bl0);
- mid = Math.imul(al7, bh0);
- mid = (mid + Math.imul(ah7, bl0)) | 0;
- hi = Math.imul(ah7, bh0);
- lo = (lo + Math.imul(al6, bl1)) | 0;
- mid = (mid + Math.imul(al6, bh1)) | 0;
- mid = (mid + Math.imul(ah6, bl1)) | 0;
- hi = (hi + Math.imul(ah6, bh1)) | 0;
- lo = (lo + Math.imul(al5, bl2)) | 0;
- mid = (mid + Math.imul(al5, bh2)) | 0;
- mid = (mid + Math.imul(ah5, bl2)) | 0;
- hi = (hi + Math.imul(ah5, bh2)) | 0;
- lo = (lo + Math.imul(al4, bl3)) | 0;
- mid = (mid + Math.imul(al4, bh3)) | 0;
- mid = (mid + Math.imul(ah4, bl3)) | 0;
- hi = (hi + Math.imul(ah4, bh3)) | 0;
- lo = (lo + Math.imul(al3, bl4)) | 0;
- mid = (mid + Math.imul(al3, bh4)) | 0;
- mid = (mid + Math.imul(ah3, bl4)) | 0;
- hi = (hi + Math.imul(ah3, bh4)) | 0;
- lo = (lo + Math.imul(al2, bl5)) | 0;
- mid = (mid + Math.imul(al2, bh5)) | 0;
- mid = (mid + Math.imul(ah2, bl5)) | 0;
- hi = (hi + Math.imul(ah2, bh5)) | 0;
- lo = (lo + Math.imul(al1, bl6)) | 0;
- mid = (mid + Math.imul(al1, bh6)) | 0;
- mid = (mid + Math.imul(ah1, bl6)) | 0;
- hi = (hi + Math.imul(ah1, bh6)) | 0;
- lo = (lo + Math.imul(al0, bl7)) | 0;
- mid = (mid + Math.imul(al0, bh7)) | 0;
- mid = (mid + Math.imul(ah0, bl7)) | 0;
- hi = (hi + Math.imul(ah0, bh7)) | 0;
- var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
- w7 &= 0x3ffffff;
- /* k = 8 */
- lo = Math.imul(al8, bl0);
- mid = Math.imul(al8, bh0);
- mid = (mid + Math.imul(ah8, bl0)) | 0;
- hi = Math.imul(ah8, bh0);
- lo = (lo + Math.imul(al7, bl1)) | 0;
- mid = (mid + Math.imul(al7, bh1)) | 0;
- mid = (mid + Math.imul(ah7, bl1)) | 0;
- hi = (hi + Math.imul(ah7, bh1)) | 0;
- lo = (lo + Math.imul(al6, bl2)) | 0;
- mid = (mid + Math.imul(al6, bh2)) | 0;
- mid = (mid + Math.imul(ah6, bl2)) | 0;
- hi = (hi + Math.imul(ah6, bh2)) | 0;
- lo = (lo + Math.imul(al5, bl3)) | 0;
- mid = (mid + Math.imul(al5, bh3)) | 0;
- mid = (mid + Math.imul(ah5, bl3)) | 0;
- hi = (hi + Math.imul(ah5, bh3)) | 0;
- lo = (lo + Math.imul(al4, bl4)) | 0;
- mid = (mid + Math.imul(al4, bh4)) | 0;
- mid = (mid + Math.imul(ah4, bl4)) | 0;
- hi = (hi + Math.imul(ah4, bh4)) | 0;
- lo = (lo + Math.imul(al3, bl5)) | 0;
- mid = (mid + Math.imul(al3, bh5)) | 0;
- mid = (mid + Math.imul(ah3, bl5)) | 0;
- hi = (hi + Math.imul(ah3, bh5)) | 0;
- lo = (lo + Math.imul(al2, bl6)) | 0;
- mid = (mid + Math.imul(al2, bh6)) | 0;
- mid = (mid + Math.imul(ah2, bl6)) | 0;
- hi = (hi + Math.imul(ah2, bh6)) | 0;
- lo = (lo + Math.imul(al1, bl7)) | 0;
- mid = (mid + Math.imul(al1, bh7)) | 0;
- mid = (mid + Math.imul(ah1, bl7)) | 0;
- hi = (hi + Math.imul(ah1, bh7)) | 0;
- lo = (lo + Math.imul(al0, bl8)) | 0;
- mid = (mid + Math.imul(al0, bh8)) | 0;
- mid = (mid + Math.imul(ah0, bl8)) | 0;
- hi = (hi + Math.imul(ah0, bh8)) | 0;
- var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
- w8 &= 0x3ffffff;
- /* k = 9 */
- lo = Math.imul(al9, bl0);
- mid = Math.imul(al9, bh0);
- mid = (mid + Math.imul(ah9, bl0)) | 0;
- hi = Math.imul(ah9, bh0);
- lo = (lo + Math.imul(al8, bl1)) | 0;
- mid = (mid + Math.imul(al8, bh1)) | 0;
- mid = (mid + Math.imul(ah8, bl1)) | 0;
- hi = (hi + Math.imul(ah8, bh1)) | 0;
- lo = (lo + Math.imul(al7, bl2)) | 0;
- mid = (mid + Math.imul(al7, bh2)) | 0;
- mid = (mid + Math.imul(ah7, bl2)) | 0;
- hi = (hi + Math.imul(ah7, bh2)) | 0;
- lo = (lo + Math.imul(al6, bl3)) | 0;
- mid = (mid + Math.imul(al6, bh3)) | 0;
- mid = (mid + Math.imul(ah6, bl3)) | 0;
- hi = (hi + Math.imul(ah6, bh3)) | 0;
- lo = (lo + Math.imul(al5, bl4)) | 0;
- mid = (mid + Math.imul(al5, bh4)) | 0;
- mid = (mid + Math.imul(ah5, bl4)) | 0;
- hi = (hi + Math.imul(ah5, bh4)) | 0;
- lo = (lo + Math.imul(al4, bl5)) | 0;
- mid = (mid + Math.imul(al4, bh5)) | 0;
- mid = (mid + Math.imul(ah4, bl5)) | 0;
- hi = (hi + Math.imul(ah4, bh5)) | 0;
- lo = (lo + Math.imul(al3, bl6)) | 0;
- mid = (mid + Math.imul(al3, bh6)) | 0;
- mid = (mid + Math.imul(ah3, bl6)) | 0;
- hi = (hi + Math.imul(ah3, bh6)) | 0;
- lo = (lo + Math.imul(al2, bl7)) | 0;
- mid = (mid + Math.imul(al2, bh7)) | 0;
- mid = (mid + Math.imul(ah2, bl7)) | 0;
- hi = (hi + Math.imul(ah2, bh7)) | 0;
- lo = (lo + Math.imul(al1, bl8)) | 0;
- mid = (mid + Math.imul(al1, bh8)) | 0;
- mid = (mid + Math.imul(ah1, bl8)) | 0;
- hi = (hi + Math.imul(ah1, bh8)) | 0;
- lo = (lo + Math.imul(al0, bl9)) | 0;
- mid = (mid + Math.imul(al0, bh9)) | 0;
- mid = (mid + Math.imul(ah0, bl9)) | 0;
- hi = (hi + Math.imul(ah0, bh9)) | 0;
- var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
- w9 &= 0x3ffffff;
- /* k = 10 */
- lo = Math.imul(al9, bl1);
- mid = Math.imul(al9, bh1);
- mid = (mid + Math.imul(ah9, bl1)) | 0;
- hi = Math.imul(ah9, bh1);
- lo = (lo + Math.imul(al8, bl2)) | 0;
- mid = (mid + Math.imul(al8, bh2)) | 0;
- mid = (mid + Math.imul(ah8, bl2)) | 0;
- hi = (hi + Math.imul(ah8, bh2)) | 0;
- lo = (lo + Math.imul(al7, bl3)) | 0;
- mid = (mid + Math.imul(al7, bh3)) | 0;
- mid = (mid + Math.imul(ah7, bl3)) | 0;
- hi = (hi + Math.imul(ah7, bh3)) | 0;
- lo = (lo + Math.imul(al6, bl4)) | 0;
- mid = (mid + Math.imul(al6, bh4)) | 0;
- mid = (mid + Math.imul(ah6, bl4)) | 0;
- hi = (hi + Math.imul(ah6, bh4)) | 0;
- lo = (lo + Math.imul(al5, bl5)) | 0;
- mid = (mid + Math.imul(al5, bh5)) | 0;
- mid = (mid + Math.imul(ah5, bl5)) | 0;
- hi = (hi + Math.imul(ah5, bh5)) | 0;
- lo = (lo + Math.imul(al4, bl6)) | 0;
- mid = (mid + Math.imul(al4, bh6)) | 0;
- mid = (mid + Math.imul(ah4, bl6)) | 0;
- hi = (hi + Math.imul(ah4, bh6)) | 0;
- lo = (lo + Math.imul(al3, bl7)) | 0;
- mid = (mid + Math.imul(al3, bh7)) | 0;
- mid = (mid + Math.imul(ah3, bl7)) | 0;
- hi = (hi + Math.imul(ah3, bh7)) | 0;
- lo = (lo + Math.imul(al2, bl8)) | 0;
- mid = (mid + Math.imul(al2, bh8)) | 0;
- mid = (mid + Math.imul(ah2, bl8)) | 0;
- hi = (hi + Math.imul(ah2, bh8)) | 0;
- lo = (lo + Math.imul(al1, bl9)) | 0;
- mid = (mid + Math.imul(al1, bh9)) | 0;
- mid = (mid + Math.imul(ah1, bl9)) | 0;
- hi = (hi + Math.imul(ah1, bh9)) | 0;
- var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
- w10 &= 0x3ffffff;
- /* k = 11 */
- lo = Math.imul(al9, bl2);
- mid = Math.imul(al9, bh2);
- mid = (mid + Math.imul(ah9, bl2)) | 0;
- hi = Math.imul(ah9, bh2);
- lo = (lo + Math.imul(al8, bl3)) | 0;
- mid = (mid + Math.imul(al8, bh3)) | 0;
- mid = (mid + Math.imul(ah8, bl3)) | 0;
- hi = (hi + Math.imul(ah8, bh3)) | 0;
- lo = (lo + Math.imul(al7, bl4)) | 0;
- mid = (mid + Math.imul(al7, bh4)) | 0;
- mid = (mid + Math.imul(ah7, bl4)) | 0;
- hi = (hi + Math.imul(ah7, bh4)) | 0;
- lo = (lo + Math.imul(al6, bl5)) | 0;
- mid = (mid + Math.imul(al6, bh5)) | 0;
- mid = (mid + Math.imul(ah6, bl5)) | 0;
- hi = (hi + Math.imul(ah6, bh5)) | 0;
- lo = (lo + Math.imul(al5, bl6)) | 0;
- mid = (mid + Math.imul(al5, bh6)) | 0;
- mid = (mid + Math.imul(ah5, bl6)) | 0;
- hi = (hi + Math.imul(ah5, bh6)) | 0;
- lo = (lo + Math.imul(al4, bl7)) | 0;
- mid = (mid + Math.imul(al4, bh7)) | 0;
- mid = (mid + Math.imul(ah4, bl7)) | 0;
- hi = (hi + Math.imul(ah4, bh7)) | 0;
- lo = (lo + Math.imul(al3, bl8)) | 0;
- mid = (mid + Math.imul(al3, bh8)) | 0;
- mid = (mid + Math.imul(ah3, bl8)) | 0;
- hi = (hi + Math.imul(ah3, bh8)) | 0;
- lo = (lo + Math.imul(al2, bl9)) | 0;
- mid = (mid + Math.imul(al2, bh9)) | 0;
- mid = (mid + Math.imul(ah2, bl9)) | 0;
- hi = (hi + Math.imul(ah2, bh9)) | 0;
- var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
- w11 &= 0x3ffffff;
- /* k = 12 */
- lo = Math.imul(al9, bl3);
- mid = Math.imul(al9, bh3);
- mid = (mid + Math.imul(ah9, bl3)) | 0;
- hi = Math.imul(ah9, bh3);
- lo = (lo + Math.imul(al8, bl4)) | 0;
- mid = (mid + Math.imul(al8, bh4)) | 0;
- mid = (mid + Math.imul(ah8, bl4)) | 0;
- hi = (hi + Math.imul(ah8, bh4)) | 0;
- lo = (lo + Math.imul(al7, bl5)) | 0;
- mid = (mid + Math.imul(al7, bh5)) | 0;
- mid = (mid + Math.imul(ah7, bl5)) | 0;
- hi = (hi + Math.imul(ah7, bh5)) | 0;
- lo = (lo + Math.imul(al6, bl6)) | 0;
- mid = (mid + Math.imul(al6, bh6)) | 0;
- mid = (mid + Math.imul(ah6, bl6)) | 0;
- hi = (hi + Math.imul(ah6, bh6)) | 0;
- lo = (lo + Math.imul(al5, bl7)) | 0;
- mid = (mid + Math.imul(al5, bh7)) | 0;
- mid = (mid + Math.imul(ah5, bl7)) | 0;
- hi = (hi + Math.imul(ah5, bh7)) | 0;
- lo = (lo + Math.imul(al4, bl8)) | 0;
- mid = (mid + Math.imul(al4, bh8)) | 0;
- mid = (mid + Math.imul(ah4, bl8)) | 0;
- hi = (hi + Math.imul(ah4, bh8)) | 0;
- lo = (lo + Math.imul(al3, bl9)) | 0;
- mid = (mid + Math.imul(al3, bh9)) | 0;
- mid = (mid + Math.imul(ah3, bl9)) | 0;
- hi = (hi + Math.imul(ah3, bh9)) | 0;
- var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
- w12 &= 0x3ffffff;
- /* k = 13 */
- lo = Math.imul(al9, bl4);
- mid = Math.imul(al9, bh4);
- mid = (mid + Math.imul(ah9, bl4)) | 0;
- hi = Math.imul(ah9, bh4);
- lo = (lo + Math.imul(al8, bl5)) | 0;
- mid = (mid + Math.imul(al8, bh5)) | 0;
- mid = (mid + Math.imul(ah8, bl5)) | 0;
- hi = (hi + Math.imul(ah8, bh5)) | 0;
- lo = (lo + Math.imul(al7, bl6)) | 0;
- mid = (mid + Math.imul(al7, bh6)) | 0;
- mid = (mid + Math.imul(ah7, bl6)) | 0;
- hi = (hi + Math.imul(ah7, bh6)) | 0;
- lo = (lo + Math.imul(al6, bl7)) | 0;
- mid = (mid + Math.imul(al6, bh7)) | 0;
- mid = (mid + Math.imul(ah6, bl7)) | 0;
- hi = (hi + Math.imul(ah6, bh7)) | 0;
- lo = (lo + Math.imul(al5, bl8)) | 0;
- mid = (mid + Math.imul(al5, bh8)) | 0;
- mid = (mid + Math.imul(ah5, bl8)) | 0;
- hi = (hi + Math.imul(ah5, bh8)) | 0;
- lo = (lo + Math.imul(al4, bl9)) | 0;
- mid = (mid + Math.imul(al4, bh9)) | 0;
- mid = (mid + Math.imul(ah4, bl9)) | 0;
- hi = (hi + Math.imul(ah4, bh9)) | 0;
- var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
- w13 &= 0x3ffffff;
- /* k = 14 */
- lo = Math.imul(al9, bl5);
- mid = Math.imul(al9, bh5);
- mid = (mid + Math.imul(ah9, bl5)) | 0;
- hi = Math.imul(ah9, bh5);
- lo = (lo + Math.imul(al8, bl6)) | 0;
- mid = (mid + Math.imul(al8, bh6)) | 0;
- mid = (mid + Math.imul(ah8, bl6)) | 0;
- hi = (hi + Math.imul(ah8, bh6)) | 0;
- lo = (lo + Math.imul(al7, bl7)) | 0;
- mid = (mid + Math.imul(al7, bh7)) | 0;
- mid = (mid + Math.imul(ah7, bl7)) | 0;
- hi = (hi + Math.imul(ah7, bh7)) | 0;
- lo = (lo + Math.imul(al6, bl8)) | 0;
- mid = (mid + Math.imul(al6, bh8)) | 0;
- mid = (mid + Math.imul(ah6, bl8)) | 0;
- hi = (hi + Math.imul(ah6, bh8)) | 0;
- lo = (lo + Math.imul(al5, bl9)) | 0;
- mid = (mid + Math.imul(al5, bh9)) | 0;
- mid = (mid + Math.imul(ah5, bl9)) | 0;
- hi = (hi + Math.imul(ah5, bh9)) | 0;
- var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
- w14 &= 0x3ffffff;
- /* k = 15 */
- lo = Math.imul(al9, bl6);
- mid = Math.imul(al9, bh6);
- mid = (mid + Math.imul(ah9, bl6)) | 0;
- hi = Math.imul(ah9, bh6);
- lo = (lo + Math.imul(al8, bl7)) | 0;
- mid = (mid + Math.imul(al8, bh7)) | 0;
- mid = (mid + Math.imul(ah8, bl7)) | 0;
- hi = (hi + Math.imul(ah8, bh7)) | 0;
- lo = (lo + Math.imul(al7, bl8)) | 0;
- mid = (mid + Math.imul(al7, bh8)) | 0;
- mid = (mid + Math.imul(ah7, bl8)) | 0;
- hi = (hi + Math.imul(ah7, bh8)) | 0;
- lo = (lo + Math.imul(al6, bl9)) | 0;
- mid = (mid + Math.imul(al6, bh9)) | 0;
- mid = (mid + Math.imul(ah6, bl9)) | 0;
- hi = (hi + Math.imul(ah6, bh9)) | 0;
- var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
- w15 &= 0x3ffffff;
- /* k = 16 */
- lo = Math.imul(al9, bl7);
- mid = Math.imul(al9, bh7);
- mid = (mid + Math.imul(ah9, bl7)) | 0;
- hi = Math.imul(ah9, bh7);
- lo = (lo + Math.imul(al8, bl8)) | 0;
- mid = (mid + Math.imul(al8, bh8)) | 0;
- mid = (mid + Math.imul(ah8, bl8)) | 0;
- hi = (hi + Math.imul(ah8, bh8)) | 0;
- lo = (lo + Math.imul(al7, bl9)) | 0;
- mid = (mid + Math.imul(al7, bh9)) | 0;
- mid = (mid + Math.imul(ah7, bl9)) | 0;
- hi = (hi + Math.imul(ah7, bh9)) | 0;
- var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
- w16 &= 0x3ffffff;
- /* k = 17 */
- lo = Math.imul(al9, bl8);
- mid = Math.imul(al9, bh8);
- mid = (mid + Math.imul(ah9, bl8)) | 0;
- hi = Math.imul(ah9, bh8);
- lo = (lo + Math.imul(al8, bl9)) | 0;
- mid = (mid + Math.imul(al8, bh9)) | 0;
- mid = (mid + Math.imul(ah8, bl9)) | 0;
- hi = (hi + Math.imul(ah8, bh9)) | 0;
- var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
- w17 &= 0x3ffffff;
- /* k = 18 */
- lo = Math.imul(al9, bl9);
- mid = Math.imul(al9, bh9);
- mid = (mid + Math.imul(ah9, bl9)) | 0;
- hi = Math.imul(ah9, bh9);
- var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
- w18 &= 0x3ffffff;
- o[0] = w0;
- o[1] = w1;
- o[2] = w2;
- o[3] = w3;
- o[4] = w4;
- o[5] = w5;
- o[6] = w6;
- o[7] = w7;
- o[8] = w8;
- o[9] = w9;
- o[10] = w10;
- o[11] = w11;
- o[12] = w12;
- o[13] = w13;
- o[14] = w14;
- o[15] = w15;
- o[16] = w16;
- o[17] = w17;
- o[18] = w18;
- if (c !== 0) {
- o[19] = c;
- out.length++;
- }
- return out;
- };
- // Polyfill comb
- if (!Math.imul) {
- comb10MulTo = smallMulTo;
- }
- function bigMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- out.length = self.length + num.length;
- var carry = 0;
- var hncarry = 0;
- for (var k = 0; k < out.length - 1; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = hncarry;
- hncarry = 0;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = k - j;
- var a = self.words[i] | 0;
- var b = num.words[j] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
- lo = (lo + rword) | 0;
- rword = lo & 0x3ffffff;
- ncarry = (ncarry + (lo >>> 26)) | 0;
- hncarry += ncarry >>> 26;
- ncarry &= 0x3ffffff;
- }
- out.words[k] = rword;
- carry = ncarry;
- ncarry = hncarry;
- }
- if (carry !== 0) {
- out.words[k] = carry;
- } else {
- out.length--;
- }
- return out.strip();
- }
- function jumboMulTo (self, num, out) {
- var fftm = new FFTM();
- return fftm.mulp(self, num, out);
- }
- BN.prototype.mulTo = function mulTo (num, out) {
- var res;
- var len = this.length + num.length;
- if (this.length === 10 && num.length === 10) {
- res = comb10MulTo(this, num, out);
- } else if (len < 63) {
- res = smallMulTo(this, num, out);
- } else if (len < 1024) {
- res = bigMulTo(this, num, out);
- } else {
- res = jumboMulTo(this, num, out);
- }
- return res;
- };
- // Cooley-Tukey algorithm for FFT
- // slightly revisited to rely on looping instead of recursion
- function FFTM (x, y) {
- this.x = x;
- this.y = y;
- }
- FFTM.prototype.makeRBT = function makeRBT (N) {
- var t = new Array(N);
- var l = BN.prototype._countBits(N) - 1;
- for (var i = 0; i < N; i++) {
- t[i] = this.revBin(i, l, N);
- }
- return t;
- };
- // Returns binary-reversed representation of `x`
- FFTM.prototype.revBin = function revBin (x, l, N) {
- if (x === 0 || x === N - 1) return x;
- var rb = 0;
- for (var i = 0; i < l; i++) {
- rb |= (x & 1) << (l - i - 1);
- x >>= 1;
- }
- return rb;
- };
- // Performs "tweedling" phase, therefore 'emulating'
- // behaviour of the recursive algorithm
- FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
- for (var i = 0; i < N; i++) {
- rtws[i] = rws[rbt[i]];
- itws[i] = iws[rbt[i]];
- }
- };
- FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
- this.permute(rbt, rws, iws, rtws, itws, N);
- for (var s = 1; s < N; s <<= 1) {
- var l = s << 1;
- var rtwdf = Math.cos(2 * Math.PI / l);
- var itwdf = Math.sin(2 * Math.PI / l);
- for (var p = 0; p < N; p += l) {
- var rtwdf_ = rtwdf;
- var itwdf_ = itwdf;
- for (var j = 0; j < s; j++) {
- var re = rtws[p + j];
- var ie = itws[p + j];
- var ro = rtws[p + j + s];
- var io = itws[p + j + s];
- var rx = rtwdf_ * ro - itwdf_ * io;
- io = rtwdf_ * io + itwdf_ * ro;
- ro = rx;
- rtws[p + j] = re + ro;
- itws[p + j] = ie + io;
- rtws[p + j + s] = re - ro;
- itws[p + j + s] = ie - io;
- /* jshint maxdepth : false */
- if (j !== l) {
- rx = rtwdf * rtwdf_ - itwdf * itwdf_;
- itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
- rtwdf_ = rx;
- }
- }
- }
- }
- };
- FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
- var N = Math.max(m, n) | 1;
- var odd = N & 1;
- var i = 0;
- for (N = N / 2 | 0; N; N = N >>> 1) {
- i++;
- }
- return 1 << i + 1 + odd;
- };
- FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
- if (N <= 1) return;
- for (var i = 0; i < N / 2; i++) {
- var t = rws[i];
- rws[i] = rws[N - i - 1];
- rws[N - i - 1] = t;
- t = iws[i];
- iws[i] = -iws[N - i - 1];
- iws[N - i - 1] = -t;
- }
- };
- FFTM.prototype.normalize13b = function normalize13b (ws, N) {
- var carry = 0;
- for (var i = 0; i < N / 2; i++) {
- var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
- Math.round(ws[2 * i] / N) +
- carry;
- ws[i] = w & 0x3ffffff;
- if (w < 0x4000000) {
- carry = 0;
- } else {
- carry = w / 0x4000000 | 0;
- }
- }
- return ws;
- };
- FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
- var carry = 0;
- for (var i = 0; i < len; i++) {
- carry = carry + (ws[i] | 0);
- rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
- rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
- }
- // Pad with zeroes
- for (i = 2 * len; i < N; ++i) {
- rws[i] = 0;
- }
- assert(carry === 0);
- assert((carry & ~0x1fff) === 0);
- };
- FFTM.prototype.stub = function stub (N) {
- var ph = new Array(N);
- for (var i = 0; i < N; i++) {
- ph[i] = 0;
- }
- return ph;
- };
- FFTM.prototype.mulp = function mulp (x, y, out) {
- var N = 2 * this.guessLen13b(x.length, y.length);
- var rbt = this.makeRBT(N);
- var _ = this.stub(N);
- var rws = new Array(N);
- var rwst = new Array(N);
- var iwst = new Array(N);
- var nrws = new Array(N);
- var nrwst = new Array(N);
- var niwst = new Array(N);
- var rmws = out.words;
- rmws.length = N;
- this.convert13b(x.words, x.length, rws, N);
- this.convert13b(y.words, y.length, nrws, N);
- this.transform(rws, _, rwst, iwst, N, rbt);
- this.transform(nrws, _, nrwst, niwst, N, rbt);
- for (var i = 0; i < N; i++) {
- var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
- iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
- rwst[i] = rx;
- }
- this.conjugate(rwst, iwst, N);
- this.transform(rwst, iwst, rmws, _, N, rbt);
- this.conjugate(rmws, _, N);
- this.normalize13b(rmws, N);
- out.negative = x.negative ^ y.negative;
- out.length = x.length + y.length;
- return out.strip();
- };
- // Multiply `this` by `num`
- BN.prototype.mul = function mul (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return this.mulTo(num, out);
- };
- // Multiply employing FFT
- BN.prototype.mulf = function mulf (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return jumboMulTo(this, num, out);
- };
- // In-place Multiplication
- BN.prototype.imul = function imul (num) {
- return this.clone().mulTo(num, this);
- };
- BN.prototype.imuln = function imuln (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- // Carry
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = (this.words[i] | 0) * num;
- var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
- carry >>= 26;
- carry += (w / 0x4000000) | 0;
- // NOTE: lo is 27bit maximum
- carry += lo >>> 26;
- this.words[i] = lo & 0x3ffffff;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.muln = function muln (num) {
- return this.clone().imuln(num);
- };
- // `this` * `this`
- BN.prototype.sqr = function sqr () {
- return this.mul(this);
- };
- // `this` * `this` in-place
- BN.prototype.isqr = function isqr () {
- return this.imul(this.clone());
- };
- // Math.pow(`this`, `num`)
- BN.prototype.pow = function pow (num) {
- var w = toBitArray(num);
- if (w.length === 0) return new BN(1);
- // Skip leading zeroes
- var res = this;
- for (var i = 0; i < w.length; i++, res = res.sqr()) {
- if (w[i] !== 0) break;
- }
- if (++i < w.length) {
- for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
- if (w[i] === 0) continue;
- res = res.mul(q);
- }
- }
- return res;
- };
- // Shift-left in-place
- BN.prototype.iushln = function iushln (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
- var i;
- if (r !== 0) {
- var carry = 0;
- for (i = 0; i < this.length; i++) {
- var newCarry = this.words[i] & carryMask;
- var c = ((this.words[i] | 0) - newCarry) << r;
- this.words[i] = c | carry;
- carry = newCarry >>> (26 - r);
- }
- if (carry) {
- this.words[i] = carry;
- this.length++;
- }
- }
- if (s !== 0) {
- for (i = this.length - 1; i >= 0; i--) {
- this.words[i + s] = this.words[i];
- }
- for (i = 0; i < s; i++) {
- this.words[i] = 0;
- }
- this.length += s;
- }
- return this.strip();
- };
- BN.prototype.ishln = function ishln (bits) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushln(bits);
- };
- // Shift-right in-place
- // NOTE: `hint` is a lowest bit before trailing zeroes
- // NOTE: if `extended` is present - it will be filled with destroyed bits
- BN.prototype.iushrn = function iushrn (bits, hint, extended) {
- assert(typeof bits === 'number' && bits >= 0);
- var h;
- if (hint) {
- h = (hint - (hint % 26)) / 26;
- } else {
- h = 0;
- }
- var r = bits % 26;
- var s = Math.min((bits - r) / 26, this.length);
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- var maskedWords = extended;
- h -= s;
- h = Math.max(0, h);
- // Extended mode, copy masked part
- if (maskedWords) {
- for (var i = 0; i < s; i++) {
- maskedWords.words[i] = this.words[i];
- }
- maskedWords.length = s;
- }
- if (s === 0) {
- // No-op, we should not move anything at all
- } else if (this.length > s) {
- this.length -= s;
- for (i = 0; i < this.length; i++) {
- this.words[i] = this.words[i + s];
- }
- } else {
- this.words[0] = 0;
- this.length = 1;
- }
- var carry = 0;
- for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
- var word = this.words[i] | 0;
- this.words[i] = (carry << (26 - r)) | (word >>> r);
- carry = word & mask;
- }
- // Push carried bits as a mask
- if (maskedWords && carry !== 0) {
- maskedWords.words[maskedWords.length++] = carry;
- }
- if (this.length === 0) {
- this.words[0] = 0;
- this.length = 1;
- }
- return this.strip();
- };
- BN.prototype.ishrn = function ishrn (bits, hint, extended) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushrn(bits, hint, extended);
- };
- // Shift-left
- BN.prototype.shln = function shln (bits) {
- return this.clone().ishln(bits);
- };
- BN.prototype.ushln = function ushln (bits) {
- return this.clone().iushln(bits);
- };
- // Shift-right
- BN.prototype.shrn = function shrn (bits) {
- return this.clone().ishrn(bits);
- };
- BN.prototype.ushrn = function ushrn (bits) {
- return this.clone().iushrn(bits);
- };
- // Test if n bit is set
- BN.prototype.testn = function testn (bit) {
- assert(typeof bit === 'number' && bit >= 0);
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) return false;
- // Check bit and return
- var w = this.words[s];
- return !!(w & q);
- };
- // Return only lowers bits of number (in-place)
- BN.prototype.imaskn = function imaskn (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- assert(this.negative === 0, 'imaskn works only with positive numbers');
- if (r !== 0) {
- s++;
- }
- this.length = Math.min(s, this.length);
- if (r !== 0) {
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- this.words[this.length - 1] &= mask;
- }
- return this.strip();
- };
- // Return only lowers bits of number
- BN.prototype.maskn = function maskn (bits) {
- return this.clone().imaskn(bits);
- };
- // Add plain number `num` to `this`
- BN.prototype.iaddn = function iaddn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.isubn(-num);
- // Possible sign change
- if (this.negative !== 0) {
- if (this.length === 1 && (this.words[0] | 0) < num) {
- this.words[0] = num - (this.words[0] | 0);
- this.negative = 0;
- return this;
- }
- this.negative = 0;
- this.isubn(num);
- this.negative = 1;
- return this;
- }
- // Add without checks
- return this._iaddn(num);
- };
- BN.prototype._iaddn = function _iaddn (num) {
- this.words[0] += num;
- // Carry
- for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
- this.words[i] -= 0x4000000;
- if (i === this.length - 1) {
- this.words[i + 1] = 1;
- } else {
- this.words[i + 1]++;
- }
- }
- this.length = Math.max(this.length, i + 1);
- return this;
- };
- // Subtract plain number `num` from `this`
- BN.prototype.isubn = function isubn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.iaddn(-num);
- if (this.negative !== 0) {
- this.negative = 0;
- this.iaddn(num);
- this.negative = 1;
- return this;
- }
- this.words[0] -= num;
- if (this.length === 1 && this.words[0] < 0) {
- this.words[0] = -this.words[0];
- this.negative = 1;
- } else {
- // Carry
- for (var i = 0; i < this.length && this.words[i] < 0; i++) {
- this.words[i] += 0x4000000;
- this.words[i + 1] -= 1;
- }
- }
- return this.strip();
- };
- BN.prototype.addn = function addn (num) {
- return this.clone().iaddn(num);
- };
- BN.prototype.subn = function subn (num) {
- return this.clone().isubn(num);
- };
- BN.prototype.iabs = function iabs () {
- this.negative = 0;
- return this;
- };
- BN.prototype.abs = function abs () {
- return this.clone().iabs();
- };
- BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
- var len = num.length + shift;
- var i;
- this._expand(len);
- var w;
- var carry = 0;
- for (i = 0; i < num.length; i++) {
- w = (this.words[i + shift] | 0) + carry;
- var right = (num.words[i] | 0) * mul;
- w -= right & 0x3ffffff;
- carry = (w >> 26) - ((right / 0x4000000) | 0);
- this.words[i + shift] = w & 0x3ffffff;
- }
- for (; i < this.length - shift; i++) {
- w = (this.words[i + shift] | 0) + carry;
- carry = w >> 26;
- this.words[i + shift] = w & 0x3ffffff;
- }
- if (carry === 0) return this.strip();
- // Subtraction overflow
- assert(carry === -1);
- carry = 0;
- for (i = 0; i < this.length; i++) {
- w = -(this.words[i] | 0) + carry;
- carry = w >> 26;
- this.words[i] = w & 0x3ffffff;
- }
- this.negative = 1;
- return this.strip();
- };
- BN.prototype._wordDiv = function _wordDiv (num, mode) {
- var shift = this.length - num.length;
- var a = this.clone();
- var b = num;
- // Normalize
- var bhi = b.words[b.length - 1] | 0;
- var bhiBits = this._countBits(bhi);
- shift = 26 - bhiBits;
- if (shift !== 0) {
- b = b.ushln(shift);
- a.iushln(shift);
- bhi = b.words[b.length - 1] | 0;
- }
- // Initialize quotient
- var m = a.length - b.length;
- var q;
- if (mode !== 'mod') {
- q = new BN(null);
- q.length = m + 1;
- q.words = new Array(q.length);
- for (var i = 0; i < q.length; i++) {
- q.words[i] = 0;
- }
- }
- var diff = a.clone()._ishlnsubmul(b, 1, m);
- if (diff.negative === 0) {
- a = diff;
- if (q) {
- q.words[m] = 1;
- }
- }
- for (var j = m - 1; j >= 0; j--) {
- var qj = (a.words[b.length + j] | 0) * 0x4000000 +
- (a.words[b.length + j - 1] | 0);
- // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
- // (0x7ffffff)
- qj = Math.min((qj / bhi) | 0, 0x3ffffff);
- a._ishlnsubmul(b, qj, j);
- while (a.negative !== 0) {
- qj--;
- a.negative = 0;
- a._ishlnsubmul(b, 1, j);
- if (!a.isZero()) {
- a.negative ^= 1;
- }
- }
- if (q) {
- q.words[j] = qj;
- }
- }
- if (q) {
- q.strip();
- }
- a.strip();
- // Denormalize
- if (mode !== 'div' && shift !== 0) {
- a.iushrn(shift);
- }
- return {
- div: q || null,
- mod: a
- };
- };
- // NOTE: 1) `mode` can be set to `mod` to request mod only,
- // to `div` to request div only, or be absent to
- // request both div & mod
- // 2) `positive` is true if unsigned mod is requested
- BN.prototype.divmod = function divmod (num, mode, positive) {
- assert(!num.isZero());
- if (this.isZero()) {
- return {
- div: new BN(0),
- mod: new BN(0)
- };
- }
- var div, mod, res;
- if (this.negative !== 0 && num.negative === 0) {
- res = this.neg().divmod(num, mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.iadd(num);
- }
- }
- return {
- div: div,
- mod: mod
- };
- }
- if (this.negative === 0 && num.negative !== 0) {
- res = this.divmod(num.neg(), mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- return {
- div: div,
- mod: res.mod
- };
- }
- if ((this.negative & num.negative) !== 0) {
- res = this.neg().divmod(num.neg(), mode);
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.isub(num);
- }
- }
- return {
- div: res.div,
- mod: mod
- };
- }
- // Both numbers are positive at this point
- // Strip both numbers to approximate shift value
- if (num.length > this.length || this.cmp(num) < 0) {
- return {
- div: new BN(0),
- mod: this
- };
- }
- // Very short reduction
- if (num.length === 1) {
- if (mode === 'div') {
- return {
- div: this.divn(num.words[0]),
- mod: null
- };
- }
- if (mode === 'mod') {
- return {
- div: null,
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return {
- div: this.divn(num.words[0]),
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return this._wordDiv(num, mode);
- };
- // Find `this` / `num`
- BN.prototype.div = function div (num) {
- return this.divmod(num, 'div', false).div;
- };
- // Find `this` % `num`
- BN.prototype.mod = function mod (num) {
- return this.divmod(num, 'mod', false).mod;
- };
- BN.prototype.umod = function umod (num) {
- return this.divmod(num, 'mod', true).mod;
- };
- // Find Round(`this` / `num`)
- BN.prototype.divRound = function divRound (num) {
- var dm = this.divmod(num);
- // Fast case - exact division
- if (dm.mod.isZero()) return dm.div;
- var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
- var half = num.ushrn(1);
- var r2 = num.andln(1);
- var cmp = mod.cmp(half);
- // Round down
- if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
- // Round up
- return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
- };
- BN.prototype.modn = function modn (num) {
- assert(num <= 0x3ffffff);
- var p = (1 << 26) % num;
- var acc = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- acc = (p * acc + (this.words[i] | 0)) % num;
- }
- return acc;
- };
- // In-place division by number
- BN.prototype.idivn = function idivn (num) {
- assert(num <= 0x3ffffff);
- var carry = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var w = (this.words[i] | 0) + carry * 0x4000000;
- this.words[i] = (w / num) | 0;
- carry = w % num;
- }
- return this.strip();
- };
- BN.prototype.divn = function divn (num) {
- return this.clone().idivn(num);
- };
- BN.prototype.egcd = function egcd (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var x = this;
- var y = p.clone();
- if (x.negative !== 0) {
- x = x.umod(p);
- } else {
- x = x.clone();
- }
- // A * x + B * y = x
- var A = new BN(1);
- var B = new BN(0);
- // C * x + D * y = y
- var C = new BN(0);
- var D = new BN(1);
- var g = 0;
- while (x.isEven() && y.isEven()) {
- x.iushrn(1);
- y.iushrn(1);
- ++g;
- }
- var yp = y.clone();
- var xp = x.clone();
- while (!x.isZero()) {
- for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- x.iushrn(i);
- while (i-- > 0) {
- if (A.isOdd() || B.isOdd()) {
- A.iadd(yp);
- B.isub(xp);
- }
- A.iushrn(1);
- B.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- y.iushrn(j);
- while (j-- > 0) {
- if (C.isOdd() || D.isOdd()) {
- C.iadd(yp);
- D.isub(xp);
- }
- C.iushrn(1);
- D.iushrn(1);
- }
- }
- if (x.cmp(y) >= 0) {
- x.isub(y);
- A.isub(C);
- B.isub(D);
- } else {
- y.isub(x);
- C.isub(A);
- D.isub(B);
- }
- }
- return {
- a: C,
- b: D,
- gcd: y.iushln(g)
- };
- };
- // This is reduced incarnation of the binary EEA
- // above, designated to invert members of the
- // _prime_ fields F(p) at a maximal speed
- BN.prototype._invmp = function _invmp (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var a = this;
- var b = p.clone();
- if (a.negative !== 0) {
- a = a.umod(p);
- } else {
- a = a.clone();
- }
- var x1 = new BN(1);
- var x2 = new BN(0);
- var delta = b.clone();
- while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
- for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- a.iushrn(i);
- while (i-- > 0) {
- if (x1.isOdd()) {
- x1.iadd(delta);
- }
- x1.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- b.iushrn(j);
- while (j-- > 0) {
- if (x2.isOdd()) {
- x2.iadd(delta);
- }
- x2.iushrn(1);
- }
- }
- if (a.cmp(b) >= 0) {
- a.isub(b);
- x1.isub(x2);
- } else {
- b.isub(a);
- x2.isub(x1);
- }
- }
- var res;
- if (a.cmpn(1) === 0) {
- res = x1;
- } else {
- res = x2;
- }
- if (res.cmpn(0) < 0) {
- res.iadd(p);
- }
- return res;
- };
- BN.prototype.gcd = function gcd (num) {
- if (this.isZero()) return num.abs();
- if (num.isZero()) return this.abs();
- var a = this.clone();
- var b = num.clone();
- a.negative = 0;
- b.negative = 0;
- // Remove common factor of two
- for (var shift = 0; a.isEven() && b.isEven(); shift++) {
- a.iushrn(1);
- b.iushrn(1);
- }
- do {
- while (a.isEven()) {
- a.iushrn(1);
- }
- while (b.isEven()) {
- b.iushrn(1);
- }
- var r = a.cmp(b);
- if (r < 0) {
- // Swap `a` and `b` to make `a` always bigger than `b`
- var t = a;
- a = b;
- b = t;
- } else if (r === 0 || b.cmpn(1) === 0) {
- break;
- }
- a.isub(b);
- } while (true);
- return b.iushln(shift);
- };
- // Invert number in the field F(num)
- BN.prototype.invm = function invm (num) {
- return this.egcd(num).a.umod(num);
- };
- BN.prototype.isEven = function isEven () {
- return (this.words[0] & 1) === 0;
- };
- BN.prototype.isOdd = function isOdd () {
- return (this.words[0] & 1) === 1;
- };
- // And first word and num
- BN.prototype.andln = function andln (num) {
- return this.words[0] & num;
- };
- // Increment at the bit position in-line
- BN.prototype.bincn = function bincn (bit) {
- assert(typeof bit === 'number');
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) {
- this._expand(s + 1);
- this.words[s] |= q;
- return this;
- }
- // Add bit and propagate, if needed
- var carry = q;
- for (var i = s; carry !== 0 && i < this.length; i++) {
- var w = this.words[i] | 0;
- w += carry;
- carry = w >>> 26;
- w &= 0x3ffffff;
- this.words[i] = w;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.isZero = function isZero () {
- return this.length === 1 && this.words[0] === 0;
- };
- BN.prototype.cmpn = function cmpn (num) {
- var negative = num < 0;
- if (this.negative !== 0 && !negative) return -1;
- if (this.negative === 0 && negative) return 1;
- this.strip();
- var res;
- if (this.length > 1) {
- res = 1;
- } else {
- if (negative) {
- num = -num;
- }
- assert(num <= 0x3ffffff, 'Number is too big');
- var w = this.words[0] | 0;
- res = w === num ? 0 : w < num ? -1 : 1;
- }
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Compare two numbers and return:
- // 1 - if `this` > `num`
- // 0 - if `this` == `num`
- // -1 - if `this` < `num`
- BN.prototype.cmp = function cmp (num) {
- if (this.negative !== 0 && num.negative === 0) return -1;
- if (this.negative === 0 && num.negative !== 0) return 1;
- var res = this.ucmp(num);
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Unsigned comparison
- BN.prototype.ucmp = function ucmp (num) {
- // At this point both numbers have the same sign
- if (this.length > num.length) return 1;
- if (this.length < num.length) return -1;
- var res = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var a = this.words[i] | 0;
- var b = num.words[i] | 0;
- if (a === b) continue;
- if (a < b) {
- res = -1;
- } else if (a > b) {
- res = 1;
- }
- break;
- }
- return res;
- };
- BN.prototype.gtn = function gtn (num) {
- return this.cmpn(num) === 1;
- };
- BN.prototype.gt = function gt (num) {
- return this.cmp(num) === 1;
- };
- BN.prototype.gten = function gten (num) {
- return this.cmpn(num) >= 0;
- };
- BN.prototype.gte = function gte (num) {
- return this.cmp(num) >= 0;
- };
- BN.prototype.ltn = function ltn (num) {
- return this.cmpn(num) === -1;
- };
- BN.prototype.lt = function lt (num) {
- return this.cmp(num) === -1;
- };
- BN.prototype.lten = function lten (num) {
- return this.cmpn(num) <= 0;
- };
- BN.prototype.lte = function lte (num) {
- return this.cmp(num) <= 0;
- };
- BN.prototype.eqn = function eqn (num) {
- return this.cmpn(num) === 0;
- };
- BN.prototype.eq = function eq (num) {
- return this.cmp(num) === 0;
- };
- //
- // A reduce context, could be using montgomery or something better, depending
- // on the `m` itself.
- //
- BN.red = function red (num) {
- return new Red(num);
- };
- BN.prototype.toRed = function toRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- assert(this.negative === 0, 'red works only with positives');
- return ctx.convertTo(this)._forceRed(ctx);
- };
- BN.prototype.fromRed = function fromRed () {
- assert(this.red, 'fromRed works only with numbers in reduction context');
- return this.red.convertFrom(this);
- };
- BN.prototype._forceRed = function _forceRed (ctx) {
- this.red = ctx;
- return this;
- };
- BN.prototype.forceRed = function forceRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- return this._forceRed(ctx);
- };
- BN.prototype.redAdd = function redAdd (num) {
- assert(this.red, 'redAdd works only with red numbers');
- return this.red.add(this, num);
- };
- BN.prototype.redIAdd = function redIAdd (num) {
- assert(this.red, 'redIAdd works only with red numbers');
- return this.red.iadd(this, num);
- };
- BN.prototype.redSub = function redSub (num) {
- assert(this.red, 'redSub works only with red numbers');
- return this.red.sub(this, num);
- };
- BN.prototype.redISub = function redISub (num) {
- assert(this.red, 'redISub works only with red numbers');
- return this.red.isub(this, num);
- };
- BN.prototype.redShl = function redShl (num) {
- assert(this.red, 'redShl works only with red numbers');
- return this.red.shl(this, num);
- };
- BN.prototype.redMul = function redMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.mul(this, num);
- };
- BN.prototype.redIMul = function redIMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.imul(this, num);
- };
- BN.prototype.redSqr = function redSqr () {
- assert(this.red, 'redSqr works only with red numbers');
- this.red._verify1(this);
- return this.red.sqr(this);
- };
- BN.prototype.redISqr = function redISqr () {
- assert(this.red, 'redISqr works only with red numbers');
- this.red._verify1(this);
- return this.red.isqr(this);
- };
- // Square root over p
- BN.prototype.redSqrt = function redSqrt () {
- assert(this.red, 'redSqrt works only with red numbers');
- this.red._verify1(this);
- return this.red.sqrt(this);
- };
- BN.prototype.redInvm = function redInvm () {
- assert(this.red, 'redInvm works only with red numbers');
- this.red._verify1(this);
- return this.red.invm(this);
- };
- // Return negative clone of `this` % `red modulo`
- BN.prototype.redNeg = function redNeg () {
- assert(this.red, 'redNeg works only with red numbers');
- this.red._verify1(this);
- return this.red.neg(this);
- };
- BN.prototype.redPow = function redPow (num) {
- assert(this.red && !num.red, 'redPow(normalNum)');
- this.red._verify1(this);
- return this.red.pow(this, num);
- };
- // Prime numbers with efficient reduction
- var primes = {
- k256: null,
- p224: null,
- p192: null,
- p25519: null
- };
- // Pseudo-Mersenne prime
- function MPrime (name, p) {
- // P = 2 ^ N - K
- this.name = name;
- this.p = new BN(p, 16);
- this.n = this.p.bitLength();
- this.k = new BN(1).iushln(this.n).isub(this.p);
- this.tmp = this._tmp();
- }
- MPrime.prototype._tmp = function _tmp () {
- var tmp = new BN(null);
- tmp.words = new Array(Math.ceil(this.n / 13));
- return tmp;
- };
- MPrime.prototype.ireduce = function ireduce (num) {
- // Assumes that `num` is less than `P^2`
- // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
- var r = num;
- var rlen;
- do {
- this.split(r, this.tmp);
- r = this.imulK(r);
- r = r.iadd(this.tmp);
- rlen = r.bitLength();
- } while (rlen > this.n);
- var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
- if (cmp === 0) {
- r.words[0] = 0;
- r.length = 1;
- } else if (cmp > 0) {
- r.isub(this.p);
- } else {
- r.strip();
- }
- return r;
- };
- MPrime.prototype.split = function split (input, out) {
- input.iushrn(this.n, 0, out);
- };
- MPrime.prototype.imulK = function imulK (num) {
- return num.imul(this.k);
- };
- function K256 () {
- MPrime.call(
- this,
- 'k256',
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
- }
- inherits(K256, MPrime);
- K256.prototype.split = function split (input, output) {
- // 256 = 9 * 26 + 22
- var mask = 0x3fffff;
- var outLen = Math.min(input.length, 9);
- for (var i = 0; i < outLen; i++) {
- output.words[i] = input.words[i];
- }
- output.length = outLen;
- if (input.length <= 9) {
- input.words[0] = 0;
- input.length = 1;
- return;
- }
- // Shift by 9 limbs
- var prev = input.words[9];
- output.words[output.length++] = prev & mask;
- for (i = 10; i < input.length; i++) {
- var next = input.words[i] | 0;
- input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
- prev = next;
- }
- prev >>>= 22;
- input.words[i - 10] = prev;
- if (prev === 0 && input.length > 10) {
- input.length -= 10;
- } else {
- input.length -= 9;
- }
- };
- K256.prototype.imulK = function imulK (num) {
- // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
- num.words[num.length] = 0;
- num.words[num.length + 1] = 0;
- num.length += 2;
- // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
- var lo = 0;
- for (var i = 0; i < num.length; i++) {
- var w = num.words[i] | 0;
- lo += w * 0x3d1;
- num.words[i] = lo & 0x3ffffff;
- lo = w * 0x40 + ((lo / 0x4000000) | 0);
- }
- // Fast length reduction
- if (num.words[num.length - 1] === 0) {
- num.length--;
- if (num.words[num.length - 1] === 0) {
- num.length--;
- }
- }
- return num;
- };
- function P224 () {
- MPrime.call(
- this,
- 'p224',
- 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
- }
- inherits(P224, MPrime);
- function P192 () {
- MPrime.call(
- this,
- 'p192',
- 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
- }
- inherits(P192, MPrime);
- function P25519 () {
- // 2 ^ 255 - 19
- MPrime.call(
- this,
- '25519',
- '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
- }
- inherits(P25519, MPrime);
- P25519.prototype.imulK = function imulK (num) {
- // K = 0x13
- var carry = 0;
- for (var i = 0; i < num.length; i++) {
- var hi = (num.words[i] | 0) * 0x13 + carry;
- var lo = hi & 0x3ffffff;
- hi >>>= 26;
- num.words[i] = lo;
- carry = hi;
- }
- if (carry !== 0) {
- num.words[num.length++] = carry;
- }
- return num;
- };
- // Exported mostly for testing purposes, use plain name instead
- BN._prime = function prime (name) {
- // Cached version of prime
- if (primes[name]) return primes[name];
- var prime;
- if (name === 'k256') {
- prime = new K256();
- } else if (name === 'p224') {
- prime = new P224();
- } else if (name === 'p192') {
- prime = new P192();
- } else if (name === 'p25519') {
- prime = new P25519();
- } else {
- throw new Error('Unknown prime ' + name);
- }
- primes[name] = prime;
- return prime;
- };
- //
- // Base reduction engine
- //
- function Red (m) {
- if (typeof m === 'string') {
- var prime = BN._prime(m);
- this.m = prime.p;
- this.prime = prime;
- } else {
- assert(m.gtn(1), 'modulus must be greater than 1');
- this.m = m;
- this.prime = null;
- }
- }
- Red.prototype._verify1 = function _verify1 (a) {
- assert(a.negative === 0, 'red works only with positives');
- assert(a.red, 'red works only with red numbers');
- };
- Red.prototype._verify2 = function _verify2 (a, b) {
- assert((a.negative | b.negative) === 0, 'red works only with positives');
- assert(a.red && a.red === b.red,
- 'red works only with red numbers');
- };
- Red.prototype.imod = function imod (a) {
- if (this.prime) return this.prime.ireduce(a)._forceRed(this);
- return a.umod(this.m)._forceRed(this);
- };
- Red.prototype.neg = function neg (a) {
- if (a.isZero()) {
- return a.clone();
- }
- return this.m.sub(a)._forceRed(this);
- };
- Red.prototype.add = function add (a, b) {
- this._verify2(a, b);
- var res = a.add(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.iadd = function iadd (a, b) {
- this._verify2(a, b);
- var res = a.iadd(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res;
- };
- Red.prototype.sub = function sub (a, b) {
- this._verify2(a, b);
- var res = a.sub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.isub = function isub (a, b) {
- this._verify2(a, b);
- var res = a.isub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res;
- };
- Red.prototype.shl = function shl (a, num) {
- this._verify1(a);
- return this.imod(a.ushln(num));
- };
- Red.prototype.imul = function imul (a, b) {
- this._verify2(a, b);
- return this.imod(a.imul(b));
- };
- Red.prototype.mul = function mul (a, b) {
- this._verify2(a, b);
- return this.imod(a.mul(b));
- };
- Red.prototype.isqr = function isqr (a) {
- return this.imul(a, a.clone());
- };
- Red.prototype.sqr = function sqr (a) {
- return this.mul(a, a);
- };
- Red.prototype.sqrt = function sqrt (a) {
- if (a.isZero()) return a.clone();
- var mod3 = this.m.andln(3);
- assert(mod3 % 2 === 1);
- // Fast case
- if (mod3 === 3) {
- var pow = this.m.add(new BN(1)).iushrn(2);
- return this.pow(a, pow);
- }
- // Tonelli-Shanks algorithm (Totally unoptimized and slow)
- //
- // Find Q and S, that Q * 2 ^ S = (P - 1)
- var q = this.m.subn(1);
- var s = 0;
- while (!q.isZero() && q.andln(1) === 0) {
- s++;
- q.iushrn(1);
- }
- assert(!q.isZero());
- var one = new BN(1).toRed(this);
- var nOne = one.redNeg();
- // Find quadratic non-residue
- // NOTE: Max is such because of generalized Riemann hypothesis.
- var lpow = this.m.subn(1).iushrn(1);
- var z = this.m.bitLength();
- z = new BN(2 * z * z).toRed(this);
- while (this.pow(z, lpow).cmp(nOne) !== 0) {
- z.redIAdd(nOne);
- }
- var c = this.pow(z, q);
- var r = this.pow(a, q.addn(1).iushrn(1));
- var t = this.pow(a, q);
- var m = s;
- while (t.cmp(one) !== 0) {
- var tmp = t;
- for (var i = 0; tmp.cmp(one) !== 0; i++) {
- tmp = tmp.redSqr();
- }
- assert(i < m);
- var b = this.pow(c, new BN(1).iushln(m - i - 1));
- r = r.redMul(b);
- c = b.redSqr();
- t = t.redMul(c);
- m = i;
- }
- return r;
- };
- Red.prototype.invm = function invm (a) {
- var inv = a._invmp(this.m);
- if (inv.negative !== 0) {
- inv.negative = 0;
- return this.imod(inv).redNeg();
- } else {
- return this.imod(inv);
- }
- };
- Red.prototype.pow = function pow (a, num) {
- if (num.isZero()) return new BN(1);
- if (num.cmpn(1) === 0) return a.clone();
- var windowSize = 4;
- var wnd = new Array(1 << windowSize);
- wnd[0] = new BN(1).toRed(this);
- wnd[1] = a;
- for (var i = 2; i < wnd.length; i++) {
- wnd[i] = this.mul(wnd[i - 1], a);
- }
- var res = wnd[0];
- var current = 0;
- var currentLen = 0;
- var start = num.bitLength() % 26;
- if (start === 0) {
- start = 26;
- }
- for (i = num.length - 1; i >= 0; i--) {
- var word = num.words[i];
- for (var j = start - 1; j >= 0; j--) {
- var bit = (word >> j) & 1;
- if (res !== wnd[0]) {
- res = this.sqr(res);
- }
- if (bit === 0 && current === 0) {
- currentLen = 0;
- continue;
- }
- current <<= 1;
- current |= bit;
- currentLen++;
- if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
- res = this.mul(res, wnd[current]);
- currentLen = 0;
- current = 0;
- }
- start = 26;
- }
- return res;
- };
- Red.prototype.convertTo = function convertTo (num) {
- var r = num.umod(this.m);
- return r === num ? r.clone() : r;
- };
- Red.prototype.convertFrom = function convertFrom (num) {
- var res = num.clone();
- res.red = null;
- return res;
- };
- //
- // Montgomery method engine
- //
- BN.mont = function mont (num) {
- return new Mont(num);
- };
- function Mont (m) {
- Red.call(this, m);
- this.shift = this.m.bitLength();
- if (this.shift % 26 !== 0) {
- this.shift += 26 - (this.shift % 26);
- }
- this.r = new BN(1).iushln(this.shift);
- this.r2 = this.imod(this.r.sqr());
- this.rinv = this.r._invmp(this.m);
- this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
- this.minv = this.minv.umod(this.r);
- this.minv = this.r.sub(this.minv);
- }
- inherits(Mont, Red);
- Mont.prototype.convertTo = function convertTo (num) {
- return this.imod(num.ushln(this.shift));
- };
- Mont.prototype.convertFrom = function convertFrom (num) {
- var r = this.imod(num.mul(this.rinv));
- r.red = null;
- return r;
- };
- Mont.prototype.imul = function imul (a, b) {
- if (a.isZero() || b.isZero()) {
- a.words[0] = 0;
- a.length = 1;
- return a;
- }
- var t = a.imul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.mul = function mul (a, b) {
- if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
- var t = a.mul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.invm = function invm (a) {
- // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
- var res = this.imod(a._invmp(this.m).mul(this.r2));
- return res._forceRed(this);
- };
- })(typeof module === 'undefined' || module, this);
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module)))
- /***/ },
- /* 13 */
- /***/ function(module, exports) {
- var g;
- // This works in non-strict mode
- g = (function() { return this; })();
- try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
- } catch(e) {
- // This works if the window reference is available
- if(typeof window === "object")
- g = window;
- }
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
- module.exports = g;
- /***/ },
- /* 14 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(arg) {
- if (Array.isArray) {
- return Array.isArray(arg);
- }
- return objectToString(arg) === '[object Array]';
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- exports.isBuffer = Buffer.isBuffer;
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 15 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.1.15 ToLength
- var toInteger = __webpack_require__(42)
- , min = Math.min;
- module.exports = function(it){
- return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
- };
- /***/ },
- /* 16 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.1.13 ToObject(argument)
- var defined = __webpack_require__(28);
- module.exports = function(it){
- return Object(defined(it));
- };
- /***/ },
- /* 17 */
- /***/ function(module, exports) {
- var hasOwnProperty = {}.hasOwnProperty;
- module.exports = function(it, key){
- return hasOwnProperty.call(it, key);
- };
- /***/ },
- /* 18 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- exports.command = function command(send, name) {
- return function (opts, cb) {
- if (typeof opts === 'function') {
- cb = opts;
- opts = {};
- }
- return send(name, null, opts, null, cb);
- };
- };
- exports.argCommand = function argCommand(send, name) {
- return function (arg, opts, cb) {
- if (typeof opts === 'function') {
- cb = opts;
- opts = {};
- }
- return send(name, arg, opts, null, cb);
- };
- };
- /***/ },
- /* 19 */
- /***/ function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(11)
- , createDesc = __webpack_require__(41);
- module.exports = __webpack_require__(10) ? function(object, key, value){
- return dP.f(object, key, createDesc(1, value));
- } : function(object, key, value){
- object[key] = value;
- return object;
- };
- /***/ },
- /* 20 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var elliptic = exports;
- elliptic.version = __webpack_require__(232).version;
- elliptic.utils = __webpack_require__(499);
- elliptic.rand = __webpack_require__(156);
- elliptic.hmacDRBG = __webpack_require__(497);
- elliptic.curve = __webpack_require__(94);
- elliptic.curves = __webpack_require__(490);
- // Protocols
- elliptic.ec = __webpack_require__(491);
- elliptic.eddsa = __webpack_require__(494);
- /***/ },
- /* 21 */
- /***/ function(module, exports) {
- module.exports = function(it){
- if(typeof it != 'function')throw TypeError(it + ' is not a function!');
- return it;
- };
- /***/ },
- /* 22 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , hide = __webpack_require__(19)
- , has = __webpack_require__(17)
- , SRC = __webpack_require__(53)('src')
- , TO_STRING = 'toString'
- , $toString = Function[TO_STRING]
- , TPL = ('' + $toString).split(TO_STRING);
- __webpack_require__(32).inspectSource = function(it){
- return $toString.call(it);
- };
- (module.exports = function(O, key, val, safe){
- var isFunction = typeof val == 'function';
- if(isFunction)has(val, 'name') || hide(val, 'name', key);
- if(O[key] === val)return;
- if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
- if(O === global){
- O[key] = val;
- } else {
- if(!safe){
- delete O[key];
- hide(O, key, val);
- } else {
- if(O[key])O[key] = val;
- else hide(O, key, val);
- }
- }
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
- })(Function.prototype, TO_STRING, function toString(){
- return typeof this == 'function' && this[SRC] || $toString.call(this);
- });
- /***/ },
- /* 23 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , fails = __webpack_require__(6)
- , defined = __webpack_require__(28)
- , quot = /"/g;
- // B.2.3.2.1 CreateHTML(string, tag, attribute, value)
- var createHTML = function(string, tag, attribute, value) {
- var S = String(defined(string))
- , p1 = '<' + tag;
- if(attribute !== '')p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"';
- return p1 + '>' + S + '</' + tag + '>';
- };
- module.exports = function(NAME, exec){
- var O = {};
- O[NAME] = exec(createHTML);
- $export($export.P + $export.F * fails(function(){
- var test = ''[NAME]('"');
- return test !== test.toLowerCase() || test.split('"').length > 3;
- }), 'String', O);
- };
- /***/ },
- /* 24 */
- /***/ function(module, exports, __webpack_require__) {
- // to indexed object, toObject with fallback for non-array-like ES3 strings
- var IObject = __webpack_require__(70)
- , defined = __webpack_require__(28);
- module.exports = function(it){
- return IObject(defined(it));
- };
- /***/ },
- /* 25 */
- /***/ function(module, exports, __webpack_require__) {
- var pIE = __webpack_require__(71)
- , createDesc = __webpack_require__(41)
- , toIObject = __webpack_require__(24)
- , toPrimitive = __webpack_require__(34)
- , has = __webpack_require__(17)
- , IE8_DOM_DEFINE = __webpack_require__(176)
- , gOPD = Object.getOwnPropertyDescriptor;
- exports.f = __webpack_require__(10) ? gOPD : function getOwnPropertyDescriptor(O, P){
- O = toIObject(O);
- P = toPrimitive(P, true);
- if(IE8_DOM_DEFINE)try {
- return gOPD(O, P);
- } catch(e){ /* empty */ }
- if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
- };
- /***/ },
- /* 26 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
- var has = __webpack_require__(17)
- , toObject = __webpack_require__(16)
- , IE_PROTO = __webpack_require__(119)('IE_PROTO')
- , ObjectProto = Object.prototype;
- module.exports = Object.getPrototypeOf || function(O){
- O = toObject(O);
- if(has(O, IE_PROTO))return O[IE_PROTO];
- if(typeof O.constructor == 'function' && O instanceof O.constructor){
- return O.constructor.prototype;
- } return O instanceof Object ? ObjectProto : null;
- };
- /***/ },
- /* 27 */
- /***/ function(module, exports) {
- var toString = {}.toString;
- module.exports = function(it){
- return toString.call(it).slice(8, -1);
- };
- /***/ },
- /* 28 */
- /***/ function(module, exports) {
- // 7.2.1 RequireObjectCoercible(argument)
- module.exports = function(it){
- if(it == undefined)throw TypeError("Can't call method on " + it);
- return it;
- };
- /***/ },
- /* 29 */
- /***/ function(module, exports, __webpack_require__) {
- var fails = __webpack_require__(6);
- module.exports = function(method, arg){
- return !!method && fails(function(){
- arg ? method.call(null, function(){}, 1) : method.call(null);
- });
- };
- /***/ },
- /* 30 */
- /***/ function(module, exports) {
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
- }
- module.exports = EventEmitter;
- // Backwards-compat with node 0.10.x
- EventEmitter.EventEmitter = EventEmitter;
- EventEmitter.prototype._events = undefined;
- EventEmitter.prototype._maxListeners = undefined;
- // By default EventEmitters will print a warning if more than 10 listeners are
- // added to it. This is a useful default which helps finding memory leaks.
- EventEmitter.defaultMaxListeners = 10;
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
- };
- EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
- if (!this._events)
- this._events = {};
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- } else {
- // At least give some kind of context to the user
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
- err.context = er;
- throw err;
- }
- }
- }
- handler = this._events[type];
- if (isUndefined(handler))
- return false;
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- args = Array.prototype.slice.call(arguments, 1);
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- args = Array.prototype.slice.call(arguments, 1);
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
- return true;
- };
- EventEmitter.prototype.addListener = function(type, listener) {
- var m;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events)
- this._events = {};
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
- return this;
- };
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
- EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- var fired = false;
- function g() {
- this.removeListener(type, g);
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
- g.listener = listener;
- this.on(type, g);
- return this;
- };
- // emits a 'removeListener' event iff the listener was removed
- EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events || !this._events[type])
- return this;
- list = this._events[type];
- length = list.length;
- position = -1;
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
- if (position < 0)
- return this;
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
- return this;
- };
- EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
- if (!this._events)
- return this;
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
- listeners = this._events[type];
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else if (listeners) {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
- return this;
- };
- EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
- };
- EventEmitter.prototype.listenerCount = function(type) {
- if (this._events) {
- var evlistener = this._events[type];
- if (isFunction(evlistener))
- return 1;
- else if (evlistener)
- return evlistener.length;
- }
- return 0;
- };
- EventEmitter.listenerCount = function(emitter, type) {
- return emitter.listenerCount(type);
- };
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- function isUndefined(arg) {
- return arg === void 0;
- }
- /***/ },
- /* 31 */
- /***/ function(module, exports, __webpack_require__) {
- // 0 -> Array#forEach
- // 1 -> Array#map
- // 2 -> Array#filter
- // 3 -> Array#some
- // 4 -> Array#every
- // 5 -> Array#find
- // 6 -> Array#findIndex
- var ctx = __webpack_require__(35)
- , IObject = __webpack_require__(70)
- , toObject = __webpack_require__(16)
- , toLength = __webpack_require__(15)
- , asc = __webpack_require__(297);
- module.exports = function(TYPE, $create){
- var IS_MAP = TYPE == 1
- , IS_FILTER = TYPE == 2
- , IS_SOME = TYPE == 3
- , IS_EVERY = TYPE == 4
- , IS_FIND_INDEX = TYPE == 6
- , NO_HOLES = TYPE == 5 || IS_FIND_INDEX
- , create = $create || asc;
- return function($this, callbackfn, that){
- var O = toObject($this)
- , self = IObject(O)
- , f = ctx(callbackfn, that, 3)
- , length = toLength(self.length)
- , index = 0
- , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined
- , val, res;
- for(;length > index; index++)if(NO_HOLES || index in self){
- val = self[index];
- res = f(val, index, O);
- if(TYPE){
- if(IS_MAP)result[index] = res; // map
- else if(res)switch(TYPE){
- case 3: return true; // some
- case 5: return val; // find
- case 6: return index; // findIndex
- case 2: result.push(val); // filter
- } else if(IS_EVERY)return false; // every
- }
- }
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
- };
- };
- /***/ },
- /* 32 */
- /***/ function(module, exports) {
- var core = module.exports = {version: '2.4.0'};
- if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
- /***/ },
- /* 33 */
- /***/ function(module, exports, __webpack_require__) {
- // most Object methods by ES6 should accept primitives
- var $export = __webpack_require__(0)
- , core = __webpack_require__(32)
- , fails = __webpack_require__(6);
- module.exports = function(KEY, exec){
- var fn = (core.Object || {})[KEY] || Object[KEY]
- , exp = {};
- exp[KEY] = exec(fn);
- $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp);
- };
- /***/ },
- /* 34 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.1.1 ToPrimitive(input [, PreferredType])
- var isObject = __webpack_require__(7);
- // instead of the ES6 spec version, we didn't implement @@toPrimitive case
- // and the second argument - flag - preferred type is a string
- module.exports = function(it, S){
- if(!isObject(it))return it;
- var fn, val;
- if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
- if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
- if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
- throw TypeError("Can't convert object to primitive value");
- };
- /***/ },
- /* 35 */
- /***/ function(module, exports, __webpack_require__) {
- // optional / simple context binding
- var aFunction = __webpack_require__(21);
- module.exports = function(fn, that, length){
- aFunction(fn);
- if(that === undefined)return fn;
- switch(length){
- case 1: return function(a){
- return fn.call(that, a);
- };
- case 2: return function(a, b){
- return fn.call(that, a, b);
- };
- case 3: return function(a, b, c){
- return fn.call(that, a, b, c);
- };
- }
- return function(/* ...args */){
- return fn.apply(that, arguments);
- };
- };
- /***/ },
- /* 36 */
- /***/ function(module, exports, __webpack_require__) {
- var Map = __webpack_require__(191)
- , $export = __webpack_require__(0)
- , shared = __webpack_require__(92)('metadata')
- , store = shared.store || (shared.store = new (__webpack_require__(194)));
- var getOrCreateMetadataMap = function(target, targetKey, create){
- var targetMetadata = store.get(target);
- if(!targetMetadata){
- if(!create)return undefined;
- store.set(target, targetMetadata = new Map);
- }
- var keyMetadata = targetMetadata.get(targetKey);
- if(!keyMetadata){
- if(!create)return undefined;
- targetMetadata.set(targetKey, keyMetadata = new Map);
- } return keyMetadata;
- };
- var ordinaryHasOwnMetadata = function(MetadataKey, O, P){
- var metadataMap = getOrCreateMetadataMap(O, P, false);
- return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
- };
- var ordinaryGetOwnMetadata = function(MetadataKey, O, P){
- var metadataMap = getOrCreateMetadataMap(O, P, false);
- return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
- };
- var ordinaryDefineOwnMetadata = function(MetadataKey, MetadataValue, O, P){
- getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
- };
- var ordinaryOwnMetadataKeys = function(target, targetKey){
- var metadataMap = getOrCreateMetadataMap(target, targetKey, false)
- , keys = [];
- if(metadataMap)metadataMap.forEach(function(_, key){ keys.push(key); });
- return keys;
- };
- var toMetaKey = function(it){
- return it === undefined || typeof it == 'symbol' ? it : String(it);
- };
- var exp = function(O){
- $export($export.S, 'Reflect', O);
- };
- module.exports = {
- store: store,
- map: getOrCreateMetadataMap,
- has: ordinaryHasOwnMetadata,
- get: ordinaryGetOwnMetadata,
- set: ordinaryDefineOwnMetadata,
- keys: ordinaryOwnMetadataKeys,
- key: toMetaKey,
- exp: exp
- };
- /***/ },
- /* 37 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- if(__webpack_require__(10)){
- var LIBRARY = __webpack_require__(46)
- , global = __webpack_require__(5)
- , fails = __webpack_require__(6)
- , $export = __webpack_require__(0)
- , $typed = __webpack_require__(93)
- , $buffer = __webpack_require__(126)
- , ctx = __webpack_require__(35)
- , anInstance = __webpack_require__(39)
- , propertyDesc = __webpack_require__(41)
- , hide = __webpack_require__(19)
- , redefineAll = __webpack_require__(50)
- , isInteger = __webpack_require__(113)
- , toInteger = __webpack_require__(42)
- , toLength = __webpack_require__(15)
- , toIndex = __webpack_require__(52)
- , toPrimitive = __webpack_require__(34)
- , has = __webpack_require__(17)
- , same = __webpack_require__(188)
- , classof = __webpack_require__(59)
- , isObject = __webpack_require__(7)
- , toObject = __webpack_require__(16)
- , isArrayIter = __webpack_require__(111)
- , create = __webpack_require__(47)
- , getPrototypeOf = __webpack_require__(26)
- , gOPN = __webpack_require__(48).f
- , isIterable = __webpack_require__(304)
- , getIterFn = __webpack_require__(128)
- , uid = __webpack_require__(53)
- , wks = __webpack_require__(8)
- , createArrayMethod = __webpack_require__(31)
- , createArrayIncludes = __webpack_require__(82)
- , speciesConstructor = __webpack_require__(120)
- , ArrayIterators = __webpack_require__(129)
- , Iterators = __webpack_require__(45)
- , $iterDetect = __webpack_require__(88)
- , setSpecies = __webpack_require__(51)
- , arrayFill = __webpack_require__(104)
- , arrayCopyWithin = __webpack_require__(169)
- , $DP = __webpack_require__(11)
- , $GOPD = __webpack_require__(25)
- , dP = $DP.f
- , gOPD = $GOPD.f
- , RangeError = global.RangeError
- , TypeError = global.TypeError
- , Uint8Array = global.Uint8Array
- , ARRAY_BUFFER = 'ArrayBuffer'
- , SHARED_BUFFER = 'Shared' + ARRAY_BUFFER
- , BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'
- , PROTOTYPE = 'prototype'
- , ArrayProto = Array[PROTOTYPE]
- , $ArrayBuffer = $buffer.ArrayBuffer
- , $DataView = $buffer.DataView
- , arrayForEach = createArrayMethod(0)
- , arrayFilter = createArrayMethod(2)
- , arraySome = createArrayMethod(3)
- , arrayEvery = createArrayMethod(4)
- , arrayFind = createArrayMethod(5)
- , arrayFindIndex = createArrayMethod(6)
- , arrayIncludes = createArrayIncludes(true)
- , arrayIndexOf = createArrayIncludes(false)
- , arrayValues = ArrayIterators.values
- , arrayKeys = ArrayIterators.keys
- , arrayEntries = ArrayIterators.entries
- , arrayLastIndexOf = ArrayProto.lastIndexOf
- , arrayReduce = ArrayProto.reduce
- , arrayReduceRight = ArrayProto.reduceRight
- , arrayJoin = ArrayProto.join
- , arraySort = ArrayProto.sort
- , arraySlice = ArrayProto.slice
- , arrayToString = ArrayProto.toString
- , arrayToLocaleString = ArrayProto.toLocaleString
- , ITERATOR = wks('iterator')
- , TAG = wks('toStringTag')
- , TYPED_CONSTRUCTOR = uid('typed_constructor')
- , DEF_CONSTRUCTOR = uid('def_constructor')
- , ALL_CONSTRUCTORS = $typed.CONSTR
- , TYPED_ARRAY = $typed.TYPED
- , VIEW = $typed.VIEW
- , WRONG_LENGTH = 'Wrong length!';
- var $map = createArrayMethod(1, function(O, length){
- return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
- });
- var LITTLE_ENDIAN = fails(function(){
- return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
- });
- var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function(){
- new Uint8Array(1).set({});
- });
- var strictToLength = function(it, SAME){
- if(it === undefined)throw TypeError(WRONG_LENGTH);
- var number = +it
- , length = toLength(it);
- if(SAME && !same(number, length))throw RangeError(WRONG_LENGTH);
- return length;
- };
- var toOffset = function(it, BYTES){
- var offset = toInteger(it);
- if(offset < 0 || offset % BYTES)throw RangeError('Wrong offset!');
- return offset;
- };
- var validate = function(it){
- if(isObject(it) && TYPED_ARRAY in it)return it;
- throw TypeError(it + ' is not a typed array!');
- };
- var allocate = function(C, length){
- if(!(isObject(C) && TYPED_CONSTRUCTOR in C)){
- throw TypeError('It is not a typed array constructor!');
- } return new C(length);
- };
- var speciesFromList = function(O, list){
- return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
- };
- var fromList = function(C, list){
- var index = 0
- , length = list.length
- , result = allocate(C, length);
- while(length > index)result[index] = list[index++];
- return result;
- };
- var addGetter = function(it, key, internal){
- dP(it, key, {get: function(){ return this._d[internal]; }});
- };
- var $from = function from(source /*, mapfn, thisArg */){
- var O = toObject(source)
- , aLen = arguments.length
- , mapfn = aLen > 1 ? arguments[1] : undefined
- , mapping = mapfn !== undefined
- , iterFn = getIterFn(O)
- , i, length, values, result, step, iterator;
- if(iterFn != undefined && !isArrayIter(iterFn)){
- for(iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++){
- values.push(step.value);
- } O = values;
- }
- if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2);
- for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){
- result[i] = mapping ? mapfn(O[i], i) : O[i];
- }
- return result;
- };
- var $of = function of(/*...items*/){
- var index = 0
- , length = arguments.length
- , result = allocate(this, length);
- while(length > index)result[index] = arguments[index++];
- return result;
- };
- // iOS Safari 6.x fails here
- var TO_LOCALE_BUG = !!Uint8Array && fails(function(){ arrayToLocaleString.call(new Uint8Array(1)); });
- var $toLocaleString = function toLocaleString(){
- return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
- };
- var proto = {
- copyWithin: function copyWithin(target, start /*, end */){
- return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
- },
- every: function every(callbackfn /*, thisArg */){
- return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- },
- fill: function fill(value /*, start, end */){ // eslint-disable-line no-unused-vars
- return arrayFill.apply(validate(this), arguments);
- },
- filter: function filter(callbackfn /*, thisArg */){
- return speciesFromList(this, arrayFilter(validate(this), callbackfn,
- arguments.length > 1 ? arguments[1] : undefined));
- },
- find: function find(predicate /*, thisArg */){
- return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
- },
- findIndex: function findIndex(predicate /*, thisArg */){
- return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
- },
- forEach: function forEach(callbackfn /*, thisArg */){
- arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- },
- indexOf: function indexOf(searchElement /*, fromIndex */){
- return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
- },
- includes: function includes(searchElement /*, fromIndex */){
- return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
- },
- join: function join(separator){ // eslint-disable-line no-unused-vars
- return arrayJoin.apply(validate(this), arguments);
- },
- lastIndexOf: function lastIndexOf(searchElement /*, fromIndex */){ // eslint-disable-line no-unused-vars
- return arrayLastIndexOf.apply(validate(this), arguments);
- },
- map: function map(mapfn /*, thisArg */){
- return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
- },
- reduce: function reduce(callbackfn /*, initialValue */){ // eslint-disable-line no-unused-vars
- return arrayReduce.apply(validate(this), arguments);
- },
- reduceRight: function reduceRight(callbackfn /*, initialValue */){ // eslint-disable-line no-unused-vars
- return arrayReduceRight.apply(validate(this), arguments);
- },
- reverse: function reverse(){
- var that = this
- , length = validate(that).length
- , middle = Math.floor(length / 2)
- , index = 0
- , value;
- while(index < middle){
- value = that[index];
- that[index++] = that[--length];
- that[length] = value;
- } return that;
- },
- some: function some(callbackfn /*, thisArg */){
- return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- },
- sort: function sort(comparefn){
- return arraySort.call(validate(this), comparefn);
- },
- subarray: function subarray(begin, end){
- var O = validate(this)
- , length = O.length
- , $begin = toIndex(begin, length);
- return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(
- O.buffer,
- O.byteOffset + $begin * O.BYTES_PER_ELEMENT,
- toLength((end === undefined ? length : toIndex(end, length)) - $begin)
- );
- }
- };
- var $slice = function slice(start, end){
- return speciesFromList(this, arraySlice.call(validate(this), start, end));
- };
- var $set = function set(arrayLike /*, offset */){
- validate(this);
- var offset = toOffset(arguments[1], 1)
- , length = this.length
- , src = toObject(arrayLike)
- , len = toLength(src.length)
- , index = 0;
- if(len + offset > length)throw RangeError(WRONG_LENGTH);
- while(index < len)this[offset + index] = src[index++];
- };
- var $iterators = {
- entries: function entries(){
- return arrayEntries.call(validate(this));
- },
- keys: function keys(){
- return arrayKeys.call(validate(this));
- },
- values: function values(){
- return arrayValues.call(validate(this));
- }
- };
- var isTAIndex = function(target, key){
- return isObject(target)
- && target[TYPED_ARRAY]
- && typeof key != 'symbol'
- && key in target
- && String(+key) == String(key);
- };
- var $getDesc = function getOwnPropertyDescriptor(target, key){
- return isTAIndex(target, key = toPrimitive(key, true))
- ? propertyDesc(2, target[key])
- : gOPD(target, key);
- };
- var $setDesc = function defineProperty(target, key, desc){
- if(isTAIndex(target, key = toPrimitive(key, true))
- && isObject(desc)
- && has(desc, 'value')
- && !has(desc, 'get')
- && !has(desc, 'set')
- // TODO: add validation descriptor w/o calling accessors
- && !desc.configurable
- && (!has(desc, 'writable') || desc.writable)
- && (!has(desc, 'enumerable') || desc.enumerable)
- ){
- target[key] = desc.value;
- return target;
- } else return dP(target, key, desc);
- };
- if(!ALL_CONSTRUCTORS){
- $GOPD.f = $getDesc;
- $DP.f = $setDesc;
- }
- $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
- getOwnPropertyDescriptor: $getDesc,
- defineProperty: $setDesc
- });
- if(fails(function(){ arrayToString.call({}); })){
- arrayToString = arrayToLocaleString = function toString(){
- return arrayJoin.call(this);
- }
- }
- var $TypedArrayPrototype$ = redefineAll({}, proto);
- redefineAll($TypedArrayPrototype$, $iterators);
- hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
- redefineAll($TypedArrayPrototype$, {
- slice: $slice,
- set: $set,
- constructor: function(){ /* noop */ },
- toString: arrayToString,
- toLocaleString: $toLocaleString
- });
- addGetter($TypedArrayPrototype$, 'buffer', 'b');
- addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
- addGetter($TypedArrayPrototype$, 'byteLength', 'l');
- addGetter($TypedArrayPrototype$, 'length', 'e');
- dP($TypedArrayPrototype$, TAG, {
- get: function(){ return this[TYPED_ARRAY]; }
- });
- module.exports = function(KEY, BYTES, wrapper, CLAMPED){
- CLAMPED = !!CLAMPED;
- var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array'
- , ISNT_UINT8 = NAME != 'Uint8Array'
- , GETTER = 'get' + KEY
- , SETTER = 'set' + KEY
- , TypedArray = global[NAME]
- , Base = TypedArray || {}
- , TAC = TypedArray && getPrototypeOf(TypedArray)
- , FORCED = !TypedArray || !$typed.ABV
- , O = {}
- , TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
- var getter = function(that, index){
- var data = that._d;
- return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
- };
- var setter = function(that, index, value){
- var data = that._d;
- if(CLAMPED)value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
- data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
- };
- var addElement = function(that, index){
- dP(that, index, {
- get: function(){
- return getter(this, index);
- },
- set: function(value){
- return setter(this, index, value);
- },
- enumerable: true
- });
- };
- if(FORCED){
- TypedArray = wrapper(function(that, data, $offset, $length){
- anInstance(that, TypedArray, NAME, '_d');
- var index = 0
- , offset = 0
- , buffer, byteLength, length, klass;
- if(!isObject(data)){
- length = strictToLength(data, true)
- byteLength = length * BYTES;
- buffer = new $ArrayBuffer(byteLength);
- } else if(data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER){
- buffer = data;
- offset = toOffset($offset, BYTES);
- var $len = data.byteLength;
- if($length === undefined){
- if($len % BYTES)throw RangeError(WRONG_LENGTH);
- byteLength = $len - offset;
- if(byteLength < 0)throw RangeError(WRONG_LENGTH);
- } else {
- byteLength = toLength($length) * BYTES;
- if(byteLength + offset > $len)throw RangeError(WRONG_LENGTH);
- }
- length = byteLength / BYTES;
- } else if(TYPED_ARRAY in data){
- return fromList(TypedArray, data);
- } else {
- return $from.call(TypedArray, data);
- }
- hide(that, '_d', {
- b: buffer,
- o: offset,
- l: byteLength,
- e: length,
- v: new $DataView(buffer)
- });
- while(index < length)addElement(that, index++);
- });
- TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
- hide(TypedArrayPrototype, 'constructor', TypedArray);
- } else if(!$iterDetect(function(iter){
- // V8 works with iterators, but fails in many other cases
- // https://code.google.com/p/v8/issues/detail?id=4552
- new TypedArray(null); // eslint-disable-line no-new
- new TypedArray(iter); // eslint-disable-line no-new
- }, true)){
- TypedArray = wrapper(function(that, data, $offset, $length){
- anInstance(that, TypedArray, NAME);
- var klass;
- // `ws` module bug, temporarily remove validation length for Uint8Array
- // https://github.com/websockets/ws/pull/645
- if(!isObject(data))return new Base(strictToLength(data, ISNT_UINT8));
- if(data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER){
- return $length !== undefined
- ? new Base(data, toOffset($offset, BYTES), $length)
- : $offset !== undefined
- ? new Base(data, toOffset($offset, BYTES))
- : new Base(data);
- }
- if(TYPED_ARRAY in data)return fromList(TypedArray, data);
- return $from.call(TypedArray, data);
- });
- arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function(key){
- if(!(key in TypedArray))hide(TypedArray, key, Base[key]);
- });
- TypedArray[PROTOTYPE] = TypedArrayPrototype;
- if(!LIBRARY)TypedArrayPrototype.constructor = TypedArray;
- }
- var $nativeIterator = TypedArrayPrototype[ITERATOR]
- , CORRECT_ITER_NAME = !!$nativeIterator && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined)
- , $iterator = $iterators.values;
- hide(TypedArray, TYPED_CONSTRUCTOR, true);
- hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
- hide(TypedArrayPrototype, VIEW, true);
- hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
- if(CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)){
- dP(TypedArrayPrototype, TAG, {
- get: function(){ return NAME; }
- });
- }
- O[NAME] = TypedArray;
- $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
- $export($export.S, NAME, {
- BYTES_PER_ELEMENT: BYTES,
- from: $from,
- of: $of
- });
- if(!(BYTES_PER_ELEMENT in TypedArrayPrototype))hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
- $export($export.P, NAME, proto);
- setSpecies(NAME);
- $export($export.P + $export.F * FORCED_SET, NAME, {set: $set});
- $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
- $export($export.P + $export.F * (TypedArrayPrototype.toString != arrayToString), NAME, {toString: arrayToString});
- $export($export.P + $export.F * fails(function(){
- new TypedArray(1).slice();
- }), NAME, {slice: $slice});
- $export($export.P + $export.F * (fails(function(){
- return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString()
- }) || !fails(function(){
- TypedArrayPrototype.toLocaleString.call([1, 2]);
- })), NAME, {toLocaleString: $toLocaleString});
- Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
- if(!LIBRARY && !CORRECT_ITER_NAME)hide(TypedArrayPrototype, ITERATOR, $iterator);
- };
- } else module.exports = function(){ /* empty */ };
- /***/ },
- /* 38 */
- /***/ function(module, exports, __webpack_require__) {
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var Buffer = __webpack_require__(1).Buffer;
- var isBufferEncoding = Buffer.isEncoding
- || function(encoding) {
- switch (encoding && encoding.toLowerCase()) {
- 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;
- default: return false;
- }
- }
- function assertEncoding(encoding) {
- if (encoding && !isBufferEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
- }
- }
- // StringDecoder provides an interface for efficiently splitting a series of
- // buffers into a series of JS strings without breaking apart multi-byte
- // characters. CESU-8 is handled as part of the UTF-8 encoding.
- //
- // @TODO Handling all encodings inside a single object makes it very difficult
- // to reason about this code, so it should be split up in the future.
- // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
- // points as used by CESU-8.
- var StringDecoder = exports.StringDecoder = function(encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
- assertEncoding(encoding);
- switch (this.encoding) {
- case 'utf8':
- // CESU-8 represents each of Surrogate Pair by 3-bytes
- this.surrogateSize = 3;
- break;
- case 'ucs2':
- case 'utf16le':
- // UTF-16 represents each of Surrogate Pair by 2-bytes
- this.surrogateSize = 2;
- this.detectIncompleteChar = utf16DetectIncompleteChar;
- break;
- case 'base64':
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
- this.surrogateSize = 3;
- this.detectIncompleteChar = base64DetectIncompleteChar;
- break;
- default:
- this.write = passThroughWrite;
- return;
- }
- // Enough space to store all bytes of a single character. UTF-8 needs 4
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
- this.charBuffer = new Buffer(6);
- // Number of bytes received for the current incomplete multi-byte character.
- this.charReceived = 0;
- // Number of bytes expected for the current incomplete multi-byte character.
- this.charLength = 0;
- };
- // write decodes the given buffer and returns it as JS string that is
- // guaranteed to not contain any partial multi-byte characters. Any partial
- // character found at the end of the buffer is buffered up, and will be
- // returned when calling write again with the remaining bytes.
- //
- // Note: Converting a Buffer containing an orphan surrogate to a String
- // currently works, but converting a String to a Buffer (via `new Buffer`, or
- // Buffer#write) will replace incomplete surrogates with the unicode
- // replacement character. See https://codereview.chromium.org/121173009/ .
- StringDecoder.prototype.write = function(buffer) {
- var charStr = '';
- // if our last write ended with an incomplete multibyte character
- while (this.charLength) {
- // determine how many remaining bytes this buffer has to offer for this char
- var available = (buffer.length >= this.charLength - this.charReceived) ?
- this.charLength - this.charReceived :
- buffer.length;
- // add the new bytes to the char buffer
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
- this.charReceived += available;
- if (this.charReceived < this.charLength) {
- // still not enough chars in this buffer? wait for more ...
- return '';
- }
- // remove bytes belonging to the current character from the buffer
- buffer = buffer.slice(available, buffer.length);
- // get the character that was split
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- var charCode = charStr.charCodeAt(charStr.length - 1);
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- this.charLength += this.surrogateSize;
- charStr = '';
- continue;
- }
- this.charReceived = this.charLength = 0;
- // if there are no more bytes in this buffer, just emit our char
- if (buffer.length === 0) {
- return charStr;
- }
- break;
- }
- // determine and set charLength / charReceived
- this.detectIncompleteChar(buffer);
- var end = buffer.length;
- if (this.charLength) {
- // buffer the incomplete character bytes we got
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
- end -= this.charReceived;
- }
- charStr += buffer.toString(this.encoding, 0, end);
- var end = charStr.length - 1;
- var charCode = charStr.charCodeAt(end);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- var size = this.surrogateSize;
- this.charLength += size;
- this.charReceived += size;
- this.charBuffer.copy(this.charBuffer, size, 0, size);
- buffer.copy(this.charBuffer, 0, 0, size);
- return charStr.substring(0, end);
- }
- // or just emit the charStr
- return charStr;
- };
- // detectIncompleteChar determines if there is an incomplete UTF-8 character at
- // the end of the given buffer. If so, it sets this.charLength to the byte
- // length that character, and sets this.charReceived to the number of bytes
- // that are available for this character.
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
- // determine how many bytes we have to check at the end of this buffer
- var i = (buffer.length >= 3) ? 3 : buffer.length;
- // Figure out if one of the last i bytes of our buffer announces an
- // incomplete char.
- for (; i > 0; i--) {
- var c = buffer[buffer.length - i];
- // See http://en.wikipedia.org/wiki/UTF-8#Description
- // 110XXXXX
- if (i == 1 && c >> 5 == 0x06) {
- this.charLength = 2;
- break;
- }
- // 1110XXXX
- if (i <= 2 && c >> 4 == 0x0E) {
- this.charLength = 3;
- break;
- }
- // 11110XXX
- if (i <= 3 && c >> 3 == 0x1E) {
- this.charLength = 4;
- break;
- }
- }
- this.charReceived = i;
- };
- StringDecoder.prototype.end = function(buffer) {
- var res = '';
- if (buffer && buffer.length)
- res = this.write(buffer);
- if (this.charReceived) {
- var cr = this.charReceived;
- var buf = this.charBuffer;
- var enc = this.encoding;
- res += buf.slice(0, cr).toString(enc);
- }
- return res;
- };
- function passThroughWrite(buffer) {
- return buffer.toString(this.encoding);
- }
- function utf16DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 2;
- this.charLength = this.charReceived ? 2 : 0;
- }
- function base64DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 3;
- this.charLength = this.charReceived ? 3 : 0;
- }
- /***/ },
- /* 39 */
- /***/ function(module, exports) {
- module.exports = function(it, Constructor, name, forbiddenField){
- if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
- throw TypeError(name + ': incorrect invocation!');
- } return it;
- };
- /***/ },
- /* 40 */
- /***/ function(module, exports, __webpack_require__) {
- var META = __webpack_require__(53)('meta')
- , isObject = __webpack_require__(7)
- , has = __webpack_require__(17)
- , setDesc = __webpack_require__(11).f
- , id = 0;
- var isExtensible = Object.isExtensible || function(){
- return true;
- };
- var FREEZE = !__webpack_require__(6)(function(){
- return isExtensible(Object.preventExtensions({}));
- });
- var setMeta = function(it){
- setDesc(it, META, {value: {
- i: 'O' + ++id, // object ID
- w: {} // weak collections IDs
- }});
- };
- var fastKey = function(it, create){
- // return primitive with prefix
- if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
- if(!has(it, META)){
- // can't set metadata to uncaught frozen object
- if(!isExtensible(it))return 'F';
- // not necessary to add metadata
- if(!create)return 'E';
- // add missing metadata
- setMeta(it);
- // return object ID
- } return it[META].i;
- };
- var getWeak = function(it, create){
- if(!has(it, META)){
- // can't set metadata to uncaught frozen object
- if(!isExtensible(it))return true;
- // not necessary to add metadata
- if(!create)return false;
- // add missing metadata
- setMeta(it);
- // return hash weak collections IDs
- } return it[META].w;
- };
- // add metadata on freeze-family methods calling
- var onFreeze = function(it){
- if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
- return it;
- };
- var meta = module.exports = {
- KEY: META,
- NEED: false,
- fastKey: fastKey,
- getWeak: getWeak,
- onFreeze: onFreeze
- };
- /***/ },
- /* 41 */
- /***/ function(module, exports) {
- module.exports = function(bitmap, value){
- return {
- enumerable : !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable : !(bitmap & 4),
- value : value
- };
- };
- /***/ },
- /* 42 */
- /***/ function(module, exports) {
- // 7.1.4 ToInteger
- var ceil = Math.ceil
- , floor = Math.floor;
- module.exports = function(it){
- return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
- };
- /***/ },
- /* 43 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // resolves . and .. elements in a path array with directory names there
- // must be no slashes, empty elements, or device names (c:\) in the array
- // (so also no leading and trailing slashes - it does not distinguish
- // relative and absolute paths)
- function normalizeArray(parts, allowAboveRoot) {
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
- // if the path is allowed to go above the root, restore leading ..s
- if (allowAboveRoot) {
- for (; up--; up) {
- parts.unshift('..');
- }
- }
- return parts;
- }
- // Split a filename into [root, dir, basename, ext], unix version
- // 'root' is just a slash, or nothing.
- var splitPathRe =
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
- var splitPath = function(filename) {
- return splitPathRe.exec(filename).slice(1);
- };
- // path.resolve([from ...], to)
- // posix version
- exports.resolve = function() {
- var resolvedPath = '',
- resolvedAbsolute = false;
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = (i >= 0) ? arguments[i] : process.cwd();
- // Skip empty and invalid entries
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- continue;
- }
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
- // At this point the path should be resolved to a full absolute path, but
- // handle relative paths to be safe (might happen when process.cwd() fails)
- // Normalize the path
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
- };
- // path.normalize(path)
- // posix version
- exports.normalize = function(path) {
- var isAbsolute = exports.isAbsolute(path),
- trailingSlash = substr(path, -1) === '/';
- // Normalize the path
- path = normalizeArray(filter(path.split('/'), function(p) {
- return !!p;
- }), !isAbsolute).join('/');
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
- return (isAbsolute ? '/' : '') + path;
- };
- // posix version
- exports.isAbsolute = function(path) {
- return path.charAt(0) === '/';
- };
- // posix version
- exports.join = function() {
- var paths = Array.prototype.slice.call(arguments, 0);
- return exports.normalize(filter(paths, function(p, index) {
- if (typeof p !== 'string') {
- throw new TypeError('Arguments to path.join must be strings');
- }
- return p;
- }).join('/'));
- };
- // path.relative(from, to)
- // posix version
- exports.relative = function(from, to) {
- from = exports.resolve(from).substr(1);
- to = exports.resolve(to).substr(1);
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
- return outputParts.join('/');
- };
- exports.sep = '/';
- exports.delimiter = ':';
- exports.dirname = function(path) {
- var result = splitPath(path),
- root = result[0],
- dir = result[1];
- if (!root && !dir) {
- // No dirname whatsoever
- return '.';
- }
- if (dir) {
- // It has a dirname, strip trailing slash
- dir = dir.substr(0, dir.length - 1);
- }
- return root + dir;
- };
- exports.basename = function(path, ext) {
- var f = splitPath(path)[2];
- // TODO: make this comparison case-insensitive on windows?
- if (ext && f.substr(-1 * ext.length) === ext) {
- f = f.substr(0, f.length - ext.length);
- }
- return f;
- };
- exports.extname = function(path) {
- return splitPath(path)[3];
- };
- function filter (xs, f) {
- if (xs.filter) return xs.filter(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- if (f(xs[i], i, xs)) res.push(xs[i]);
- }
- return res;
- }
- // String.prototype.substr - negative index don't work in IE8
- var substr = 'ab'.substr(-1) === 'b'
- ? function (str, start, len) { return str.substr(start, len) }
- : function (str, start, len) {
- if (start < 0) start = str.length + start;
- return str.substr(start, len);
- }
- ;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 44 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var formatRegExp = /%[sdj%]/g;
- exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
- };
- // Mark that a method should not be used.
- // Returns a modified function which warns once by default.
- // If --no-deprecation is set, then it is a no-op.
- exports.deprecate = function(fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
- if (process.noDeprecation === true) {
- return fn;
- }
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
- return deprecated;
- };
- var debugs = {};
- var debugEnviron;
- exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
- }
- }
- return debugs[set];
- };
- /**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
- /* legacy: obj, showHidden, depth, colors*/
- function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
- }
- exports.inspect = inspect;
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
- inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
- };
- // Don't use 'blue' not visible on cmd.exe
- inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
- };
- function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
- }
- }
- function stylizeNoColor(str, styleType) {
- return str;
- }
- function arrayToHash(array) {
- var hash = {};
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
- return hash;
- }
- function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value)
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
- var base = '', array = false, braces = ['{', '}'];
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
- }
- }
- ctx.seen.push(value);
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
- });
- }
- ctx.seen.pop();
- return reduceToSingleString(output, base, braces);
- }
- function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value))
- return ctx.stylize('' + value, 'number');
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
- }
- function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
- }
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
- } else {
- output.push('');
- }
- }
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
- }
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
- }
- }
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
- return name + ': ' + str;
- }
- function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
- }
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(ar) {
- return Array.isArray(ar);
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- exports.isBuffer = __webpack_require__(579);
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
- }
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
- // 26 Feb 16:19:34
- function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
- }
- // log is just a thin wrapper to console.log that prepends a timestamp
- exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
- };
- /**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
- exports.inherits = __webpack_require__(2);
- exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
- };
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(4)))
- /***/ },
- /* 45 */
- /***/ function(module, exports) {
- module.exports = {};
- /***/ },
- /* 46 */
- /***/ function(module, exports) {
- module.exports = false;
- /***/ },
- /* 47 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- var anObject = __webpack_require__(3)
- , dPs = __webpack_require__(181)
- , enumBugKeys = __webpack_require__(107)
- , IE_PROTO = __webpack_require__(119)('IE_PROTO')
- , Empty = function(){ /* empty */ }
- , PROTOTYPE = 'prototype';
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
- var createDict = function(){
- // Thrash, waste and sodomy: IE GC bug
- var iframe = __webpack_require__(106)('iframe')
- , i = enumBugKeys.length
- , gt = '>'
- , iframeDocument;
- iframe.style.display = 'none';
- __webpack_require__(109).appendChild(iframe);
- iframe.src = 'javascript:'; // eslint-disable-line no-script-url
- // createDict = iframe.contentWindow.Object;
- // html.removeChild(iframe);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write('<script>document.F=Object</script' + gt);
- iframeDocument.close();
- createDict = iframeDocument.F;
- while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
- return createDict();
- };
- module.exports = Object.create || function create(O, Properties){
- var result;
- if(O !== null){
- Empty[PROTOTYPE] = anObject(O);
- result = new Empty;
- Empty[PROTOTYPE] = null;
- // add "__proto__" for Object.getPrototypeOf polyfill
- result[IE_PROTO] = O;
- } else result = createDict();
- return Properties === undefined ? result : dPs(result, Properties);
- };
- /***/ },
- /* 48 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
- var $keys = __webpack_require__(183)
- , hiddenKeys = __webpack_require__(107).concat('length', 'prototype');
- exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
- return $keys(O, hiddenKeys);
- };
- /***/ },
- /* 49 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.14 / 15.2.3.14 Object.keys(O)
- var $keys = __webpack_require__(183)
- , enumBugKeys = __webpack_require__(107);
- module.exports = Object.keys || function keys(O){
- return $keys(O, enumBugKeys);
- };
- /***/ },
- /* 50 */
- /***/ function(module, exports, __webpack_require__) {
- var redefine = __webpack_require__(22);
- module.exports = function(target, src, safe){
- for(var key in src)redefine(target, key, src[key], safe);
- return target;
- };
- /***/ },
- /* 51 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var global = __webpack_require__(5)
- , dP = __webpack_require__(11)
- , DESCRIPTORS = __webpack_require__(10)
- , SPECIES = __webpack_require__(8)('species');
- module.exports = function(KEY){
- var C = global[KEY];
- if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
- configurable: true,
- get: function(){ return this; }
- });
- };
- /***/ },
- /* 52 */
- /***/ function(module, exports, __webpack_require__) {
- var toInteger = __webpack_require__(42)
- , max = Math.max
- , min = Math.min;
- module.exports = function(index, length){
- index = toInteger(index);
- return index < 0 ? max(index + length, 0) : min(index, length);
- };
- /***/ },
- /* 53 */
- /***/ function(module, exports) {
- var id = 0
- , px = Math.random();
- module.exports = function(key){
- return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
- };
- /***/ },
- /* 54 */
- /***/ function(module, exports, __webpack_require__) {
- var hash = exports;
- hash.utils = __webpack_require__(509);
- hash.common = __webpack_require__(505);
- hash.sha = __webpack_require__(508);
- hash.ripemd = __webpack_require__(507);
- hash.hmac = __webpack_require__(506);
- // Proxy hash functions to the main object
- hash.sha1 = hash.sha.sha1;
- hash.sha256 = hash.sha.sha256;
- hash.sha224 = hash.sha.sha224;
- hash.sha384 = hash.sha.sha384;
- hash.sha512 = hash.sha.sha512;
- hash.ripemd160 = hash.ripemd.ripemd160;
- /***/ },
- /* 55 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- 'use strict';
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- keys.push(key);
- }return keys;
- };
- /*</replacement>*/
- module.exports = Duplex;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Readable = __webpack_require__(216);
- var Writable = __webpack_require__(139);
- util.inherits(Duplex, Readable);
- var keys = objectKeys(Writable.prototype);
- for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
- }
- function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false) this.readable = false;
- if (options && options.writable === false) this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended) return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- processNextTick(onEndNT, this);
- }
- function onEndNT(self) {
- self.end();
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- /***/ },
- /* 56 */
- /***/ function(module, exports, __webpack_require__) {
- var basex = __webpack_require__(281)
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
- var base58 = basex(ALPHABET)
- module.exports = {
- encode: base58.encode,
- decode: base58.decode
- }
- /***/ },
- /* 57 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var Transform = __webpack_require__(9).Transform
- var inherits = __webpack_require__(2)
- var StringDecoder = __webpack_require__(38).StringDecoder
- module.exports = CipherBase
- inherits(CipherBase, Transform)
- function CipherBase (hashMode) {
- Transform.call(this)
- this.hashMode = typeof hashMode === 'string'
- if (this.hashMode) {
- this[hashMode] = this._finalOrDigest
- } else {
- this.final = this._finalOrDigest
- }
- this._decoder = null
- this._encoding = null
- }
- CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
- if (typeof data === 'string') {
- data = new Buffer(data, inputEnc)
- }
- var outData = this._update(data)
- if (this.hashMode) {
- return this
- }
- if (outputEnc) {
- outData = this._toString(outData, outputEnc)
- }
- return outData
- }
- CipherBase.prototype.setAutoPadding = function () {}
- CipherBase.prototype.getAuthTag = function () {
- throw new Error('trying to get auth tag in unsupported state')
- }
- CipherBase.prototype.setAuthTag = function () {
- throw new Error('trying to set auth tag in unsupported state')
- }
- CipherBase.prototype.setAAD = function () {
- throw new Error('trying to set aad in unsupported state')
- }
- CipherBase.prototype._transform = function (data, _, next) {
- var err
- try {
- if (this.hashMode) {
- this._update(data)
- } else {
- this.push(this._update(data))
- }
- } catch (e) {
- err = e
- } finally {
- next(err)
- }
- }
- CipherBase.prototype._flush = function (done) {
- var err
- try {
- this.push(this._final())
- } catch (e) {
- err = e
- } finally {
- done(err)
- }
- }
- CipherBase.prototype._finalOrDigest = function (outputEnc) {
- var outData = this._final() || new Buffer('')
- if (outputEnc) {
- outData = this._toString(outData, outputEnc, true)
- }
- return outData
- }
- CipherBase.prototype._toString = function (value, enc, final) {
- if (!this._decoder) {
- this._decoder = new StringDecoder(enc)
- this._encoding = enc
- }
- if (this._encoding !== enc) {
- throw new Error('can\'t switch encodings')
- }
- var out = this._decoder.write(value)
- if (final) {
- out += this._decoder.end()
- }
- return out
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 58 */
- /***/ function(module, exports, __webpack_require__) {
- // 22.1.3.31 Array.prototype[@@unscopables]
- var UNSCOPABLES = __webpack_require__(8)('unscopables')
- , ArrayProto = Array.prototype;
- if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(19)(ArrayProto, UNSCOPABLES, {});
- module.exports = function(key){
- ArrayProto[UNSCOPABLES][key] = true;
- };
- /***/ },
- /* 59 */
- /***/ function(module, exports, __webpack_require__) {
- // getting tag from 19.1.3.6 Object.prototype.toString()
- var cof = __webpack_require__(27)
- , TAG = __webpack_require__(8)('toStringTag')
- // ES3 wrong here
- , ARG = cof(function(){ return arguments; }()) == 'Arguments';
- // fallback for IE11 Script Access Denied error
- var tryGet = function(it, key){
- try {
- return it[key];
- } catch(e){ /* empty */ }
- };
- module.exports = function(it){
- var O, T, B;
- return it === undefined ? 'Undefined' : it === null ? 'Null'
- // @@toStringTag case
- : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
- // builtinTag case
- : ARG ? cof(O)
- // ES3 arguments fallback
- : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
- };
- /***/ },
- /* 60 */
- /***/ function(module, exports, __webpack_require__) {
- var ctx = __webpack_require__(35)
- , call = __webpack_require__(177)
- , isArrayIter = __webpack_require__(111)
- , anObject = __webpack_require__(3)
- , toLength = __webpack_require__(15)
- , getIterFn = __webpack_require__(128)
- , BREAK = {}
- , RETURN = {};
- var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
- var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
- , f = ctx(fn, that, entries ? 2 : 1)
- , index = 0
- , length, step, iterator, result;
- if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
- // fast case for arrays with default iterator
- if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
- result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
- if(result === BREAK || result === RETURN)return result;
- } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
- result = call(iterator, f, step.value, entries);
- if(result === BREAK || result === RETURN)return result;
- }
- };
- exports.BREAK = BREAK;
- exports.RETURN = RETURN;
- /***/ },
- /* 61 */
- /***/ function(module, exports, __webpack_require__) {
- var def = __webpack_require__(11).f
- , has = __webpack_require__(17)
- , TAG = __webpack_require__(8)('toStringTag');
- module.exports = function(it, tag, stat){
- if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
- };
- /***/ },
- /* 62 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , defined = __webpack_require__(28)
- , fails = __webpack_require__(6)
- , spaces = __webpack_require__(124)
- , space = '[' + spaces + ']'
- , non = '\u200b\u0085'
- , ltrim = RegExp('^' + space + space + '*')
- , rtrim = RegExp(space + space + '*$');
- var exporter = function(KEY, exec, ALIAS){
- var exp = {};
- var FORCE = fails(function(){
- return !!spaces[KEY]() || non[KEY]() != non;
- });
- var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];
- if(ALIAS)exp[ALIAS] = fn;
- $export($export.P + $export.F * FORCE, 'String', exp);
- };
- // 1 -> String#trimLeft
- // 2 -> String#trimRight
- // 3 -> String#trim
- var trim = exporter.trim = function(string, TYPE){
- string = String(defined(string));
- if(TYPE & 1)string = string.replace(ltrim, '');
- if(TYPE & 2)string = string.replace(rtrim, '');
- return string;
- };
- module.exports = exporter;
- /***/ },
- /* 63 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var inherits = __webpack_require__(2)
- var md5 = __webpack_require__(195)
- var rmd160 = __webpack_require__(554)
- var sha = __webpack_require__(556)
- var Base = __webpack_require__(57)
- function HashNoConstructor(hash) {
- Base.call(this, 'digest')
- this._hash = hash
- this.buffers = []
- }
- inherits(HashNoConstructor, Base)
- HashNoConstructor.prototype._update = function (data) {
- this.buffers.push(data)
- }
- HashNoConstructor.prototype._final = function () {
- var buf = Buffer.concat(this.buffers)
- var r = this._hash(buf)
- this.buffers = null
- return r
- }
- function Hash(hash) {
- Base.call(this, 'digest')
- this._hash = hash
- }
- inherits(Hash, Base)
- Hash.prototype._update = function (data) {
- this._hash.update(data)
- }
- Hash.prototype._final = function () {
- return this._hash.digest()
- }
- module.exports = function createHash (alg) {
- alg = alg.toLowerCase()
- if ('md5' === alg) return new HashNoConstructor(md5)
- if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160)
- return new Hash(sha(alg))
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 64 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
- if (!process.version ||
- process.version.indexOf('v0.') === 0 ||
- process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
- module.exports = nextTick;
- } else {
- module.exports = process.nextTick;
- }
- function nextTick(fn, arg1, arg2, arg3) {
- if (typeof fn !== 'function') {
- throw new TypeError('"callback" argument must be a function');
- }
- var len = arguments.length;
- var args, i;
- switch (len) {
- case 0:
- case 1:
- return process.nextTick(fn);
- case 2:
- return process.nextTick(function afterTickOne() {
- fn.call(null, arg1);
- });
- case 3:
- return process.nextTick(function afterTickTwo() {
- fn.call(null, arg1, arg2);
- });
- case 4:
- return process.nextTick(function afterTickThree() {
- fn.call(null, arg1, arg2, arg3);
- });
- default:
- args = new Array(len - 1);
- i = 0;
- while (i < args.length) {
- args[i++] = arguments[i];
- }
- return process.nextTick(function afterTick() {
- fn.apply(null, args);
- });
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 65 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// prototype class for hash functions
- function Hash (blockSize, finalSize) {
- this._block = new Buffer(blockSize)
- this._finalSize = finalSize
- this._blockSize = blockSize
- this._len = 0
- this._s = 0
- }
- Hash.prototype.update = function (data, enc) {
- if (typeof data === 'string') {
- enc = enc || 'utf8'
- data = new Buffer(data, enc)
- }
- var l = this._len += data.length
- var s = this._s || 0
- var f = 0
- var buffer = this._block
- while (s < l) {
- var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize))
- var ch = (t - f)
- for (var i = 0; i < ch; i++) {
- buffer[(s % this._blockSize) + i] = data[i + f]
- }
- s += ch
- f += ch
- if ((s % this._blockSize) === 0) {
- this._update(buffer)
- }
- }
- this._s = s
- return this
- }
- Hash.prototype.digest = function (enc) {
- // Suppose the length of the message M, in bits, is l
- var l = this._len * 8
- // Append the bit 1 to the end of the message
- this._block[this._len % this._blockSize] = 0x80
- // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize
- this._block.fill(0, this._len % this._blockSize + 1)
- if (l % (this._blockSize * 8) >= this._finalSize * 8) {
- this._update(this._block)
- this._block.fill(0)
- }
- // to this append the block which is equal to the number l written in binary
- // TODO: handle case where l is > Math.pow(2, 29)
- this._block.writeInt32BE(l, this._blockSize - 4)
- var hash = this._update(this._block) || this._hash()
- return enc ? hash.toString(enc) : hash
- }
- Hash.prototype._update = function () {
- throw new Error('_update must be implemented by subclass')
- }
- module.exports = Hash
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 66 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- 'use strict';
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- keys.push(key);
- }return keys;
- };
- /*</replacement>*/
- module.exports = Duplex;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Readable = __webpack_require__(222);
- var Writable = __webpack_require__(224);
- util.inherits(Duplex, Readable);
- var keys = objectKeys(Writable.prototype);
- for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
- }
- function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false) this.readable = false;
- if (options && options.writable === false) this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended) return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- processNextTick(onEndNT, this);
- }
- function onEndNT(self) {
- self.end();
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- /***/ },
- /* 67 */
- /***/ function(module, exports, __webpack_require__) {
- var base = exports;
- base.Reporter = __webpack_require__(237).Reporter;
- base.DecoderBuffer = __webpack_require__(140).DecoderBuffer;
- base.EncoderBuffer = __webpack_require__(140).EncoderBuffer;
- base.Node = __webpack_require__(236);
- /***/ },
- /* 68 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer, process) {'use strict';
- // Load modules
- 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; };
- var Crypto = __webpack_require__(131);
- var Path = __webpack_require__(43);
- var Util = __webpack_require__(44);
- var Escape = __webpack_require__(243);
- // Declare internals
- var internals = {};
- // Clone object or array
- exports.clone = function (obj, seen) {
- if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
- return obj;
- }
- seen = seen || new Map();
- var lookup = seen.get(obj);
- if (lookup) {
- return lookup;
- }
- var newObj = void 0;
- var cloneDeep = false;
- if (!Array.isArray(obj)) {
- if (Buffer.isBuffer(obj)) {
- newObj = new Buffer(obj);
- } else if (obj instanceof Date) {
- newObj = new Date(obj.getTime());
- } else if (obj instanceof RegExp) {
- newObj = new RegExp(obj);
- } else {
- var proto = Object.getPrototypeOf(obj);
- if (proto && proto.isImmutable) {
- newObj = obj;
- } else {
- newObj = Object.create(proto);
- cloneDeep = true;
- }
- }
- } else {
- newObj = [];
- cloneDeep = true;
- }
- seen.set(obj, newObj);
- if (cloneDeep) {
- var keys = Object.getOwnPropertyNames(obj);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- var descriptor = Object.getOwnPropertyDescriptor(obj, key);
- if (descriptor && (descriptor.get || descriptor.set)) {
- Object.defineProperty(newObj, key, descriptor);
- } else {
- newObj[key] = exports.clone(obj[key], seen);
- }
- }
- }
- return newObj;
- };
- // Merge all the properties of source into target, source wins in conflict, and by default null and undefined from source are applied
- /*eslint-disable */
- exports.merge = function (target, source, isNullOverride /* = true */, isMergeArrays /* = true */) {
- /*eslint-enable */
- exports.assert(target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object', 'Invalid target value: must be an object');
- exports.assert(source === null || source === undefined || (typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object', 'Invalid source value: must be null, undefined, or an object');
- if (!source) {
- return target;
- }
- if (Array.isArray(source)) {
- exports.assert(Array.isArray(target), 'Cannot merge array onto an object');
- if (isMergeArrays === false) {
- // isMergeArrays defaults to true
- target.length = 0; // Must not change target assignment
- }
- for (var i = 0; i < source.length; ++i) {
- target.push(exports.clone(source[i]));
- }
- return target;
- }
- var keys = Object.keys(source);
- for (var _i = 0; _i < keys.length; ++_i) {
- var key = keys[_i];
- var value = source[key];
- if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
- if (!target[key] || _typeof(target[key]) !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer.isBuffer(value) || value instanceof RegExp) {
- target[key] = exports.clone(value);
- } else {
- exports.merge(target[key], value, isNullOverride, isMergeArrays);
- }
- } else {
- if (value !== null && value !== undefined) {
- // Explicit to preserve empty strings
- target[key] = value;
- } else if (isNullOverride !== false) {
- // Defaults to true
- target[key] = value;
- }
- }
- }
- return target;
- };
- // Apply options to a copy of the defaults
- exports.applyToDefaults = function (defaults, options, isNullOverride) {
- exports.assert(defaults && (typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) === 'object', 'Invalid defaults value: must be an object');
- exports.assert(!options || options === true || (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object', 'Invalid options value: must be true, falsy or an object');
- if (!options) {
- // If no options, return null
- return null;
- }
- var copy = exports.clone(defaults);
- if (options === true) {
- // If options is set to true, use defaults
- return copy;
- }
- return exports.merge(copy, options, isNullOverride === true, false);
- };
- // Clone an object except for the listed keys which are shallow copied
- exports.cloneWithShallow = function (source, keys) {
- if (!source || (typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') {
- return source;
- }
- var storage = internals.store(source, keys); // Move shallow copy items to storage
- var copy = exports.clone(source); // Deep copy the rest
- internals.restore(copy, source, storage); // Shallow copy the stored items and restore
- return copy;
- };
- internals.store = function (source, keys) {
- var storage = {};
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- var value = exports.reach(source, key);
- if (value !== undefined) {
- storage[key] = value;
- internals.reachSet(source, key, undefined);
- }
- }
- return storage;
- };
- internals.restore = function (copy, source, storage) {
- var keys = Object.keys(storage);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- internals.reachSet(copy, key, storage[key]);
- internals.reachSet(source, key, storage[key]);
- }
- };
- internals.reachSet = function (obj, key, value) {
- var path = key.split('.');
- var ref = obj;
- for (var i = 0; i < path.length; ++i) {
- var segment = path[i];
- if (i + 1 === path.length) {
- ref[segment] = value;
- }
- ref = ref[segment];
- }
- };
- // Apply options to defaults except for the listed keys which are shallow copied from option without merging
- exports.applyToDefaultsWithShallow = function (defaults, options, keys) {
- exports.assert(defaults && (typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) === 'object', 'Invalid defaults value: must be an object');
- exports.assert(!options || options === true || (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object', 'Invalid options value: must be true, falsy or an object');
- exports.assert(keys && Array.isArray(keys), 'Invalid keys');
- if (!options) {
- // If no options, return null
- return null;
- }
- var copy = exports.cloneWithShallow(defaults, keys);
- if (options === true) {
- // If options is set to true, use defaults
- return copy;
- }
- var storage = internals.store(options, keys); // Move shallow copy items to storage
- exports.merge(copy, options, false, false); // Deep copy the rest
- internals.restore(copy, options, storage); // Shallow copy the stored items and restore
- return copy;
- };
- // Deep object or array comparison
- exports.deepEqual = function (obj, ref, options, seen) {
- options = options || { prototype: true };
- var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
- if (type !== (typeof ref === 'undefined' ? 'undefined' : _typeof(ref))) {
- return false;
- }
- if (type !== 'object' || obj === null || ref === null) {
- if (obj === ref) {
- // Copied from Deep-eql, copyright(c) 2013 Jake Luer, [email protected], MIT Licensed, https://github.com/chaijs/deep-eql
- return obj !== 0 || 1 / obj === 1 / ref; // -0 / +0
- }
- return obj !== obj && ref !== ref; // NaN
- }
- seen = seen || [];
- if (seen.indexOf(obj) !== -1) {
- return true; // If previous comparison failed, it would have stopped execution
- }
- seen.push(obj);
- if (Array.isArray(obj)) {
- if (!Array.isArray(ref)) {
- return false;
- }
- if (!options.part && obj.length !== ref.length) {
- return false;
- }
- for (var i = 0; i < obj.length; ++i) {
- if (options.part) {
- var found = false;
- for (var j = 0; j < ref.length; ++j) {
- if (exports.deepEqual(obj[i], ref[j], options)) {
- found = true;
- break;
- }
- }
- return found;
- }
- if (!exports.deepEqual(obj[i], ref[i], options)) {
- return false;
- }
- }
- return true;
- }
- if (Buffer.isBuffer(obj)) {
- if (!Buffer.isBuffer(ref)) {
- return false;
- }
- if (obj.length !== ref.length) {
- return false;
- }
- for (var _i2 = 0; _i2 < obj.length; ++_i2) {
- if (obj[_i2] !== ref[_i2]) {
- return false;
- }
- }
- return true;
- }
- if (obj instanceof Date) {
- return ref instanceof Date && obj.getTime() === ref.getTime();
- }
- if (obj instanceof RegExp) {
- return ref instanceof RegExp && obj.toString() === ref.toString();
- }
- if (options.prototype) {
- if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {
- return false;
- }
- }
- var keys = Object.getOwnPropertyNames(obj);
- if (!options.part && keys.length !== Object.getOwnPropertyNames(ref).length) {
- return false;
- }
- for (var _i3 = 0; _i3 < keys.length; ++_i3) {
- var key = keys[_i3];
- var descriptor = Object.getOwnPropertyDescriptor(obj, key);
- if (descriptor.get) {
- if (!exports.deepEqual(descriptor, Object.getOwnPropertyDescriptor(ref, key), options, seen)) {
- return false;
- }
- } else if (!exports.deepEqual(obj[key], ref[key], options, seen)) {
- return false;
- }
- }
- return true;
- };
- // Remove duplicate items from array
- exports.unique = function (array, key) {
- var result = void 0;
- if (key) {
- (function () {
- result = [];
- var index = new Set();
- array.forEach(function (item) {
- var identifier = item[key];
- if (!index.has(identifier)) {
- index.add(identifier);
- result.push(item);
- }
- });
- })();
- } else {
- result = Array.from(new Set(array));
- }
- return result;
- };
- // Convert array into object
- exports.mapToObject = function (array, key) {
- if (!array) {
- return null;
- }
- var obj = {};
- for (var i = 0; i < array.length; ++i) {
- if (key) {
- if (array[i][key]) {
- obj[array[i][key]] = true;
- }
- } else {
- obj[array[i]] = true;
- }
- }
- return obj;
- };
- // Find the common unique items in two arrays
- exports.intersect = function (array1, array2, justFirst) {
- if (!array1 || !array2) {
- return [];
- }
- var common = [];
- var hash = Array.isArray(array1) ? exports.mapToObject(array1) : array1;
- var found = {};
- for (var i = 0; i < array2.length; ++i) {
- if (hash[array2[i]] && !found[array2[i]]) {
- if (justFirst) {
- return array2[i];
- }
- common.push(array2[i]);
- found[array2[i]] = true;
- }
- }
- return justFirst ? null : common;
- };
- // Test if the reference contains the values
- exports.contain = function (ref, values, options) {
- /*
- string -> string(s)
- array -> item(s)
- object -> key(s)
- object -> object (key:value)
- */
- var valuePairs = null;
- if ((typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object' && (typeof values === 'undefined' ? 'undefined' : _typeof(values)) === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {
- valuePairs = values;
- values = Object.keys(values);
- } else {
- values = [].concat(values);
- }
- options = options || {}; // deep, once, only, part
- exports.assert(arguments.length >= 2, 'Insufficient arguments');
- exports.assert(typeof ref === 'string' || (typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object', 'Reference must be string or an object');
- exports.assert(values.length, 'Values array cannot be empty');
- var compare = void 0;
- var compareFlags = void 0;
- if (options.deep) {
- compare = exports.deepEqual;
- var hasOnly = options.hasOwnProperty('only');
- var hasPart = options.hasOwnProperty('part');
- compareFlags = {
- prototype: hasOnly ? options.only : hasPart ? !options.part : false,
- part: hasOnly ? !options.only : hasPart ? options.part : true
- };
- } else {
- compare = function compare(a, b) {
- return a === b;
- };
- }
- var misses = false;
- var matches = new Array(values.length);
- for (var i = 0; i < matches.length; ++i) {
- matches[i] = 0;
- }
- if (typeof ref === 'string') {
- var pattern = '(';
- for (var _i4 = 0; _i4 < values.length; ++_i4) {
- var value = values[_i4];
- exports.assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
- pattern += (_i4 ? '|' : '') + exports.escapeRegex(value);
- }
- var regex = new RegExp(pattern + ')', 'g');
- var leftovers = ref.replace(regex, function ($0, $1) {
- var index = values.indexOf($1);
- ++matches[index];
- return ''; // Remove from string
- });
- misses = !!leftovers;
- } else if (Array.isArray(ref)) {
- for (var _i5 = 0; _i5 < ref.length; ++_i5) {
- var matched = false;
- for (var j = 0; j < values.length && matched === false; ++j) {
- matched = compare(values[j], ref[_i5], compareFlags) && j;
- }
- if (matched !== false) {
- ++matches[matched];
- } else {
- misses = true;
- }
- }
- } else {
- var keys = Object.keys(ref);
- for (var _i6 = 0; _i6 < keys.length; ++_i6) {
- var key = keys[_i6];
- var pos = values.indexOf(key);
- if (pos !== -1) {
- if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {
- return false;
- }
- ++matches[pos];
- } else {
- misses = true;
- }
- }
- }
- var result = false;
- for (var _i7 = 0; _i7 < matches.length; ++_i7) {
- result = result || !!matches[_i7];
- if (options.once && matches[_i7] > 1 || !options.part && !matches[_i7]) {
- return false;
- }
- }
- if (options.only && misses) {
- return false;
- }
- return result;
- };
- // Flatten array
- exports.flatten = function (array, target) {
- var result = target || [];
- for (var i = 0; i < array.length; ++i) {
- if (Array.isArray(array[i])) {
- exports.flatten(array[i], result);
- } else {
- result.push(array[i]);
- }
- }
- return result;
- };
- // Convert an object key chain string ('a.b.c') to reference (object[a][b][c])
- exports.reach = function (obj, chain, options) {
- if (chain === false || chain === null || typeof chain === 'undefined') {
- return obj;
- }
- options = options || {};
- if (typeof options === 'string') {
- options = { separator: options };
- }
- var path = chain.split(options.separator || '.');
- var ref = obj;
- for (var i = 0; i < path.length; ++i) {
- var key = path[i];
- if (key[0] === '-' && Array.isArray(ref)) {
- key = key.slice(1, key.length);
- key = ref.length - key;
- }
- 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) {
- // Only object and function can have properties
- exports.assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
- exports.assert((typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
- ref = options.default;
- break;
- }
- ref = ref[key];
- }
- return ref;
- };
- exports.reachTemplate = function (obj, template, options) {
- return template.replace(/{([^}]+)}/g, function ($0, chain) {
- var value = exports.reach(obj, chain, options);
- return value === undefined || value === null ? '' : value;
- });
- };
- exports.formatStack = function (stack) {
- var trace = [];
- for (var i = 0; i < stack.length; ++i) {
- var item = stack[i];
- trace.push([item.getFileName(), item.getLineNumber(), item.getColumnNumber(), item.getFunctionName(), item.isConstructor()]);
- }
- return trace;
- };
- exports.formatTrace = function (trace) {
- var display = [];
- for (var i = 0; i < trace.length; ++i) {
- var row = trace[i];
- display.push((row[4] ? 'new ' : '') + row[3] + ' (' + row[0] + ':' + row[1] + ':' + row[2] + ')');
- }
- return display;
- };
- exports.callStack = function (slice) {
- // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
- var v8 = Error.prepareStackTrace;
- Error.prepareStackTrace = function (_, stack) {
- return stack;
- };
- var capture = {};
- 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
- var stack = capture.stack;
- Error.prepareStackTrace = v8;
- var trace = exports.formatStack(stack);
- return trace.slice(1 + slice);
- };
- exports.displayStack = function (slice) {
- var trace = exports.callStack(slice === undefined ? 1 : slice + 1);
- return exports.formatTrace(trace);
- };
- exports.abortThrow = false;
- exports.abort = function (message, hideStack) {
- if (process.env.NODE_ENV === 'test' || exports.abortThrow === true) {
- throw new Error(message || 'Unknown error');
- }
- var stack = '';
- if (!hideStack) {
- stack = exports.displayStack(1).join('\n\t');
- }
- console.log('ABORT: ' + message + '\n\t' + stack);
- process.exit(1);
- };
- exports.assert = function (condition /*, msg1, msg2, msg3 */) {
- if (condition) {
- return;
- }
- if (arguments.length === 2 && arguments[1] instanceof Error) {
- throw arguments[1];
- }
- var msgs = [];
- for (var i = 1; i < arguments.length; ++i) {
- if (arguments[i] !== '') {
- msgs.push(arguments[i]); // Avoids Array.slice arguments leak, allowing for V8 optimizations
- }
- }
- msgs = msgs.map(function (msg) {
- return typeof msg === 'string' ? msg : msg instanceof Error ? msg.message : exports.stringify(msg);
- });
- throw new Error(msgs.join(' ') || 'Unknown error');
- };
- exports.Timer = function () {
- this.ts = 0;
- this.reset();
- };
- exports.Timer.prototype.reset = function () {
- this.ts = Date.now();
- };
- exports.Timer.prototype.elapsed = function () {
- return Date.now() - this.ts;
- };
- exports.Bench = function () {
- this.ts = 0;
- this.reset();
- };
- exports.Bench.prototype.reset = function () {
- this.ts = exports.Bench.now();
- };
- exports.Bench.prototype.elapsed = function () {
- return exports.Bench.now() - this.ts;
- };
- exports.Bench.now = function () {
- var ts = process.hrtime();
- return ts[0] * 1e3 + ts[1] / 1e6;
- };
- // Escape string for Regex construction
- exports.escapeRegex = function (string) {
- // Escape ^$.*+-?=!:|\/()[]{},
- return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&');
- };
- // Base64url (RFC 4648) encode
- exports.base64urlEncode = function (value, encoding) {
- exports.assert(typeof value === 'string' || Buffer.isBuffer(value), 'value must be string or buffer');
- var buf = Buffer.isBuffer(value) ? value : new Buffer(value, encoding || 'binary');
- return buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
- };
- // Base64url (RFC 4648) decode
- exports.base64urlDecode = function (value, encoding) {
- if (typeof value !== 'string') {
- return new Error('Value not a string');
- }
- if (!/^[\w\-]*$/.test(value)) {
- return new Error('Invalid character');
- }
- var buf = new Buffer(value, 'base64');
- return encoding === 'buffer' ? buf : buf.toString(encoding || 'binary');
- };
- // Escape attribute value for use in HTTP header
- exports.escapeHeaderAttribute = function (attribute) {
- // Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, "
- exports.assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')');
- return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash
- };
- exports.escapeHtml = function (string) {
- return Escape.escapeHtml(string);
- };
- exports.escapeJavaScript = function (string) {
- return Escape.escapeJavaScript(string);
- };
- exports.nextTick = function (callback) {
- return function () {
- var args = arguments;
- process.nextTick(function () {
- callback.apply(null, args);
- });
- };
- };
- exports.once = function (method) {
- if (method._hoekOnce) {
- return method;
- }
- var once = false;
- var wrapped = function wrapped() {
- if (!once) {
- once = true;
- method.apply(null, arguments);
- }
- };
- wrapped._hoekOnce = true;
- return wrapped;
- };
- exports.isInteger = function (value) {
- return typeof value === 'number' && parseFloat(value) === parseInt(value, 10) && !isNaN(value);
- };
- exports.ignore = function () {};
- exports.inherits = Util.inherits;
- exports.format = Util.format;
- exports.transform = function (source, transform, options) {
- 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');
- var separator = (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && options !== null ? options.separator || '.' : '.';
- if (Array.isArray(source)) {
- var results = [];
- for (var i = 0; i < source.length; ++i) {
- results.push(exports.transform(source[i], transform, options));
- }
- return results;
- }
- var result = {};
- var keys = Object.keys(transform);
- for (var _i8 = 0; _i8 < keys.length; ++_i8) {
- var key = keys[_i8];
- var path = key.split(separator);
- var sourcePath = transform[key];
- exports.assert(typeof sourcePath === 'string', 'All mappings must be "." delineated strings');
- var segment = void 0;
- var res = result;
- while (path.length > 1) {
- segment = path.shift();
- if (!res[segment]) {
- res[segment] = {};
- }
- res = res[segment];
- }
- segment = path.shift();
- res[segment] = exports.reach(source, sourcePath, options);
- }
- return result;
- };
- exports.uniqueFilename = function (path, extension) {
- if (extension) {
- extension = extension[0] !== '.' ? '.' + extension : extension;
- } else {
- extension = '';
- }
- path = Path.resolve(path);
- var name = [Date.now(), process.pid, Crypto.randomBytes(8).toString('hex')].join('-') + extension;
- return Path.join(path, name);
- };
- exports.stringify = function () {
- try {
- return JSON.stringify.apply(null, arguments);
- } catch (err) {
- return '[Cannot display object: ' + err.message + ']';
- }
- };
- exports.shallow = function (source) {
- var target = {};
- var keys = Object.keys(source);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- target[key] = source[key];
- }
- return target;
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(4)))
- /***/ },
- /* 69 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function xor (a, b) {
- var length = Math.min(a.length, b.length)
- var buffer = new Buffer(length)
- for (var i = 0; i < length; ++i) {
- buffer[i] = a[i] ^ b[i]
- }
- return buffer
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 70 */
- /***/ function(module, exports, __webpack_require__) {
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
- var cof = __webpack_require__(27);
- module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
- return cof(it) == 'String' ? it.split('') : Object(it);
- };
- /***/ },
- /* 71 */
- /***/ function(module, exports) {
- exports.f = {}.propertyIsEnumerable;
- /***/ },
- /* 72 */
- /***/ function(module, exports) {
- module.exports = assert;
- function assert(val, msg) {
- if (!val)
- throw new Error(msg || 'Assertion failed');
- }
- assert.equal = function assertEqual(l, r, msg) {
- if (l != r)
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
- };
- /***/ },
- /* 73 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global, Buffer, process) {'use strict'
- function oldBrowser () {
- throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
- }
- var crypto = global.crypto || global.msCrypto
- if (crypto && crypto.getRandomValues) {
- module.exports = randomBytes
- } else {
- module.exports = oldBrowser
- }
- function randomBytes (size, cb) {
- // phantomjs needs to throw
- if (size > 65536) throw new Error('requested too many random bytes')
- // in case browserify isn't using the Uint8Array version
- var rawBytes = new global.Uint8Array(size)
- // This will not work in older browsers.
- // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
- if (size > 0) { // getRandomValues fails on IE if size == 0
- crypto.getRandomValues(rawBytes)
- }
- // phantomjs doesn't like a buffer being passed here
- var bytes = new Buffer(rawBytes.buffer)
- if (typeof cb === 'function') {
- return process.nextTick(function () {
- cb(null, bytes)
- })
- }
- return bytes
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(1).Buffer, __webpack_require__(4)))
- /***/ },
- /* 74 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(4).nextTick;
- var apply = Function.prototype.apply;
- var slice = Array.prototype.slice;
- var immediateIds = {};
- var nextImmediateId = 0;
- // DOM APIs, for completeness
- exports.setTimeout = function() {
- return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
- };
- exports.setInterval = function() {
- return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
- };
- exports.clearTimeout =
- exports.clearInterval = function(timeout) { timeout.close(); };
- function Timeout(id, clearFn) {
- this._id = id;
- this._clearFn = clearFn;
- }
- Timeout.prototype.unref = Timeout.prototype.ref = function() {};
- Timeout.prototype.close = function() {
- this._clearFn.call(window, this._id);
- };
- // Does not start the time, just sets up the members needed.
- exports.enroll = function(item, msecs) {
- clearTimeout(item._idleTimeoutId);
- item._idleTimeout = msecs;
- };
- exports.unenroll = function(item) {
- clearTimeout(item._idleTimeoutId);
- item._idleTimeout = -1;
- };
- exports._unrefActive = exports.active = function(item) {
- clearTimeout(item._idleTimeoutId);
- var msecs = item._idleTimeout;
- if (msecs >= 0) {
- item._idleTimeoutId = setTimeout(function onTimeout() {
- if (item._onTimeout)
- item._onTimeout();
- }, msecs);
- }
- };
- // That's not how node.js implements it but the exposed api is the same.
- exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
- var id = nextImmediateId++;
- var args = arguments.length < 2 ? false : slice.call(arguments, 1);
- immediateIds[id] = true;
- nextTick(function onNextTick() {
- if (immediateIds[id]) {
- // fn.call() is faster so we optimize for the common use-case
- // @see http://jsperf.com/call-apply-segu
- if (args) {
- fn.apply(null, args);
- } else {
- fn.call(null);
- }
- // Prevent ids from leaking
- exports.clearImmediate(id);
- }
- });
- return id;
- };
- exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
- delete immediateIds[id];
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(74).setImmediate, __webpack_require__(74).clearImmediate))
- /***/ },
- /* 75 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = {
- encode: __webpack_require__(581)
- , decode: __webpack_require__(580)
- , encodingLength: __webpack_require__(582)
- }
- /***/ },
- /* 76 */
- /***/ function(module, exports) {
- module.exports = function(module) {
- if(!module.webpackPolyfill) {
- module.deprecate = function() {};
- module.paths = [];
- // module.parent = undefined by default
- if(!module.children) module.children = [];
- Object.defineProperty(module, "loaded", {
- enumerable: true,
- configurable: false,
- get: function() { return module.l; }
- });
- Object.defineProperty(module, "id", {
- enumerable: true,
- configurable: false,
- get: function() { return module.i; }
- });
- module.webpackPolyfill = 1;
- }
- return module;
- }
- /***/ },
- /* 77 */
- /***/ function(module, exports, __webpack_require__) {
- var asn1 = exports;
- asn1.bignum = __webpack_require__(12);
- asn1.define = __webpack_require__(235).define;
- asn1.base = __webpack_require__(67);
- asn1.constants = __webpack_require__(141);
- asn1.decoders = __webpack_require__(239);
- asn1.encoders = __webpack_require__(241);
- /***/ },
- /* 78 */
- /***/ function(module, exports) {
- "use strict";
- /** PROMISIFY CALLBACK-STYLE FUNCTIONS TO ES6 PROMISES
- *
- * EXAMPLE:
- * const fn = promisify( (callback) => callback(null, "Hello world!") );
- * fn((err, str) => console.log(str));
- * fn().then((str) => console.log(str));
- * //Both functions, will log 'Hello world!'
- *
- * Note: The function you pass, may have any arguments you want, but the latest
- * have to be the callback, which you will call with: next(err, value)
- *
- * @param method: Function/Array/Map = The function(s) to promisify
- * @param options: Map =
- * "context" (default is function): The context which to apply the called function
- * "replace" (default is falsy): When passed an array/map, if to replace the original object
- *
- * @return: A promise if passed a function, otherwise the object with the promises
- *
- * @license: MIT
- * @version: 1.0.1
- * @author: Manuel Di Iorio
- **/
- "use strict";
- var createCallback = function createCallback(method, context) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return new Promise(function (solve, reject) {
- args.push(function (err, val) {
- if (err) return reject(err);
- solve(val);
- });
- method.apply(context, args);
- });
- };
- };
- module.exports = function (methods, options) {
- options = options || {};
- var type = Object.prototype.toString.call(methods);
- if (type === "[object Object]" || type === "[object Array]") {
- var obj = options.replace ? methods : {};
- for (var key in methods) {
- if (methods.hasOwnProperty(key)) obj[key] = createCallback(methods[key]);
- }return obj;
- }
- return createCallback(methods, options.context || methods);
- };
- /***/ },
- /* 79 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// based on the aes implimentation in triple sec
- // https://github.com/keybase/triplesec
- // which is in turn based on the one from crypto-js
- // https://code.google.com/p/crypto-js/
- var uint_max = Math.pow(2, 32)
- function fixup_uint32 (x) {
- var ret, x_pos
- ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
- return ret
- }
- function scrub_vec (v) {
- for (var i = 0; i < v.length; v++) {
- v[i] = 0
- }
- return false
- }
- function Global () {
- this.SBOX = []
- this.INV_SBOX = []
- this.SUB_MIX = [[], [], [], []]
- this.INV_SUB_MIX = [[], [], [], []]
- this.init()
- this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
- }
- Global.prototype.init = function () {
- var d, i, sx, t, x, x2, x4, x8, xi, _i
- d = (function () {
- var _i, _results
- _results = []
- for (i = _i = 0; _i < 256; i = ++_i) {
- if (i < 128) {
- _results.push(i << 1)
- } else {
- _results.push((i << 1) ^ 0x11b)
- }
- }
- return _results
- })()
- x = 0
- xi = 0
- for (i = _i = 0; _i < 256; i = ++_i) {
- sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
- sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
- this.SBOX[x] = sx
- this.INV_SBOX[sx] = x
- x2 = d[x]
- x4 = d[x2]
- x8 = d[x4]
- t = (d[sx] * 0x101) ^ (sx * 0x1010100)
- this.SUB_MIX[0][x] = (t << 24) | (t >>> 8)
- this.SUB_MIX[1][x] = (t << 16) | (t >>> 16)
- this.SUB_MIX[2][x] = (t << 8) | (t >>> 24)
- this.SUB_MIX[3][x] = t
- t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
- this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
- this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
- this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
- this.INV_SUB_MIX[3][sx] = t
- if (x === 0) {
- x = xi = 1
- } else {
- x = x2 ^ d[d[d[x8 ^ x2]]]
- xi ^= d[d[xi]]
- }
- }
- return true
- }
- var G = new Global()
- AES.blockSize = 4 * 4
- AES.prototype.blockSize = AES.blockSize
- AES.keySize = 256 / 8
- AES.prototype.keySize = AES.keySize
- function bufferToArray (buf) {
- var len = buf.length / 4
- var out = new Array(len)
- var i = -1
- while (++i < len) {
- out[i] = buf.readUInt32BE(i * 4)
- }
- return out
- }
- function AES (key) {
- this._key = bufferToArray(key)
- this._doReset()
- }
- AES.prototype._doReset = function () {
- var invKsRow, keySize, keyWords, ksRow, ksRows, t
- keyWords = this._key
- keySize = keyWords.length
- this._nRounds = keySize + 6
- ksRows = (this._nRounds + 1) * 4
- this._keySchedule = []
- for (ksRow = 0; ksRow < ksRows; ksRow++) {
- 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)
- }
- this._invKeySchedule = []
- for (invKsRow = 0; invKsRow < ksRows; invKsRow++) {
- ksRow = ksRows - invKsRow
- t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)]
- 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]]
- }
- return true
- }
- AES.prototype.encryptBlock = function (M) {
- M = bufferToArray(new Buffer(M))
- var out = this._doCryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX)
- var buf = new Buffer(16)
- buf.writeUInt32BE(out[0], 0)
- buf.writeUInt32BE(out[1], 4)
- buf.writeUInt32BE(out[2], 8)
- buf.writeUInt32BE(out[3], 12)
- return buf
- }
- AES.prototype.decryptBlock = function (M) {
- M = bufferToArray(new Buffer(M))
- var temp = [M[3], M[1]]
- M[1] = temp[0]
- M[3] = temp[1]
- var out = this._doCryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX)
- var buf = new Buffer(16)
- buf.writeUInt32BE(out[0], 0)
- buf.writeUInt32BE(out[3], 4)
- buf.writeUInt32BE(out[2], 8)
- buf.writeUInt32BE(out[1], 12)
- return buf
- }
- AES.prototype.scrub = function () {
- scrub_vec(this._keySchedule)
- scrub_vec(this._invKeySchedule)
- scrub_vec(this._key)
- }
- AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) {
- var ksRow, s0, s1, s2, s3, t0, t1, t2, t3
- s0 = M[0] ^ keySchedule[0]
- s1 = M[1] ^ keySchedule[1]
- s2 = M[2] ^ keySchedule[2]
- s3 = M[3] ^ keySchedule[3]
- ksRow = 4
- for (var round = 1; round < this._nRounds; round++) {
- 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++]
- 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++]
- 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++]
- 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++]
- s0 = t0
- s1 = t1
- s2 = t2
- s3 = t3
- }
- t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
- t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
- t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
- t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
- return [
- fixup_uint32(t0),
- fixup_uint32(t1),
- fixup_uint32(t2),
- fixup_uint32(t3)
- ]
- }
- exports.AES = AES
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 80 */
- /***/ function(module, exports) {
- exports['aes-128-ecb'] = {
- cipher: 'AES',
- key: 128,
- iv: 0,
- mode: 'ECB',
- type: 'block'
- }
- exports['aes-192-ecb'] = {
- cipher: 'AES',
- key: 192,
- iv: 0,
- mode: 'ECB',
- type: 'block'
- }
- exports['aes-256-ecb'] = {
- cipher: 'AES',
- key: 256,
- iv: 0,
- mode: 'ECB',
- type: 'block'
- }
- exports['aes-128-cbc'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'CBC',
- type: 'block'
- }
- exports['aes-192-cbc'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'CBC',
- type: 'block'
- }
- exports['aes-256-cbc'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'CBC',
- type: 'block'
- }
- exports['aes128'] = exports['aes-128-cbc']
- exports['aes192'] = exports['aes-192-cbc']
- exports['aes256'] = exports['aes-256-cbc']
- exports['aes-128-cfb'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'CFB',
- type: 'stream'
- }
- exports['aes-192-cfb'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'CFB',
- type: 'stream'
- }
- exports['aes-256-cfb'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'CFB',
- type: 'stream'
- }
- exports['aes-128-cfb8'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'CFB8',
- type: 'stream'
- }
- exports['aes-192-cfb8'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'CFB8',
- type: 'stream'
- }
- exports['aes-256-cfb8'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'CFB8',
- type: 'stream'
- }
- exports['aes-128-cfb1'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'CFB1',
- type: 'stream'
- }
- exports['aes-192-cfb1'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'CFB1',
- type: 'stream'
- }
- exports['aes-256-cfb1'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'CFB1',
- type: 'stream'
- }
- exports['aes-128-ofb'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'OFB',
- type: 'stream'
- }
- exports['aes-192-ofb'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'OFB',
- type: 'stream'
- }
- exports['aes-256-ofb'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'OFB',
- type: 'stream'
- }
- exports['aes-128-ctr'] = {
- cipher: 'AES',
- key: 128,
- iv: 16,
- mode: 'CTR',
- type: 'stream'
- }
- exports['aes-192-ctr'] = {
- cipher: 'AES',
- key: 192,
- iv: 16,
- mode: 'CTR',
- type: 'stream'
- }
- exports['aes-256-ctr'] = {
- cipher: 'AES',
- key: 256,
- iv: 16,
- mode: 'CTR',
- type: 'stream'
- }
- exports['aes-128-gcm'] = {
- cipher: 'AES',
- key: 128,
- iv: 12,
- mode: 'GCM',
- type: 'auth'
- }
- exports['aes-192-gcm'] = {
- cipher: 'AES',
- key: 192,
- iv: 12,
- mode: 'GCM',
- type: 'auth'
- }
- exports['aes-256-gcm'] = {
- cipher: 'AES',
- key: 256,
- iv: 12,
- mode: 'GCM',
- type: 'auth'
- }
- /***/ },
- /* 81 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
- function incr32 (iv) {
- var len = iv.length
- var item
- while (len--) {
- item = iv.readUInt8(len)
- if (item === 255) {
- iv.writeUInt8(0, len)
- } else {
- item++
- iv.writeUInt8(item, len)
- break
- }
- }
- }
- function getBlock (self) {
- var out = self._cipher.encryptBlock(self._prev)
- incr32(self._prev)
- return out
- }
- exports.encrypt = function (self, chunk) {
- while (self._cache.length < chunk.length) {
- self._cache = Buffer.concat([self._cache, getBlock(self)])
- }
- var pad = self._cache.slice(0, chunk.length)
- self._cache = self._cache.slice(chunk.length)
- return xor(chunk, pad)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 82 */
- /***/ function(module, exports, __webpack_require__) {
- // false -> Array#indexOf
- // true -> Array#includes
- var toIObject = __webpack_require__(24)
- , toLength = __webpack_require__(15)
- , toIndex = __webpack_require__(52);
- module.exports = function(IS_INCLUDES){
- return function($this, el, fromIndex){
- var O = toIObject($this)
- , length = toLength(O.length)
- , index = toIndex(fromIndex, length)
- , value;
- // Array#includes uses SameValueZero equality algorithm
- if(IS_INCLUDES && el != el)while(length > index){
- value = O[index++];
- if(value != value)return true;
- // Array#toIndex ignores holes, Array#includes - not
- } else for(;length > index; index++)if(IS_INCLUDES || index in O){
- if(O[index] === el)return IS_INCLUDES || index || 0;
- } return !IS_INCLUDES && -1;
- };
- };
- /***/ },
- /* 83 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var global = __webpack_require__(5)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(22)
- , redefineAll = __webpack_require__(50)
- , meta = __webpack_require__(40)
- , forOf = __webpack_require__(60)
- , anInstance = __webpack_require__(39)
- , isObject = __webpack_require__(7)
- , fails = __webpack_require__(6)
- , $iterDetect = __webpack_require__(88)
- , setToStringTag = __webpack_require__(61)
- , inheritIfRequired = __webpack_require__(110);
- module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
- var Base = global[NAME]
- , C = Base
- , ADDER = IS_MAP ? 'set' : 'add'
- , proto = C && C.prototype
- , O = {};
- var fixMethod = function(KEY){
- var fn = proto[KEY];
- redefine(proto, KEY,
- KEY == 'delete' ? function(a){
- return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'has' ? function has(a){
- return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'get' ? function get(a){
- return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
- : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
- );
- };
- if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){
- new C().entries().next();
- }))){
- // create collection constructor
- C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
- redefineAll(C.prototype, methods);
- meta.NEED = true;
- } else {
- var instance = new C
- // early implementations not supports chaining
- , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance
- // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
- , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); })
- // most early implementations doesn't supports iterables, most modern - not close it correctly
- , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new
- // for early implementations -0 and +0 not the same
- , BUGGY_ZERO = !IS_WEAK && fails(function(){
- // V8 ~ Chromium 42- fails only with 5+ elements
- var $instance = new C()
- , index = 5;
- while(index--)$instance[ADDER](index, index);
- return !$instance.has(-0);
- });
- if(!ACCEPT_ITERABLES){
- C = wrapper(function(target, iterable){
- anInstance(target, C, NAME);
- var that = inheritIfRequired(new Base, target, C);
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- return that;
- });
- C.prototype = proto;
- proto.constructor = C;
- }
- if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){
- fixMethod('delete');
- fixMethod('has');
- IS_MAP && fixMethod('get');
- }
- if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER);
- // weak collections should not contains .clear method
- if(IS_WEAK && proto.clear)delete proto.clear;
- }
- setToStringTag(C, NAME);
- O[NAME] = C;
- $export($export.G + $export.W + $export.F * (C != Base), O);
- if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
- return C;
- };
- /***/ },
- /* 84 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var hide = __webpack_require__(19)
- , redefine = __webpack_require__(22)
- , fails = __webpack_require__(6)
- , defined = __webpack_require__(28)
- , wks = __webpack_require__(8);
- module.exports = function(KEY, length, exec){
- var SYMBOL = wks(KEY)
- , fns = exec(defined, SYMBOL, ''[KEY])
- , strfn = fns[0]
- , rxfn = fns[1];
- if(fails(function(){
- var O = {};
- O[SYMBOL] = function(){ return 7; };
- return ''[KEY](O) != 7;
- })){
- redefine(String.prototype, KEY, strfn);
- hide(RegExp.prototype, SYMBOL, length == 2
- // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
- // 21.2.5.11 RegExp.prototype[@@split](string, limit)
- ? function(string, arg){ return rxfn.call(string, this, arg); }
- // 21.2.5.6 RegExp.prototype[@@match](string)
- // 21.2.5.9 RegExp.prototype[@@search](string)
- : function(string){ return rxfn.call(string, this); }
- );
- }
- };
- /***/ },
- /* 85 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 21.2.5.3 get RegExp.prototype.flags
- var anObject = __webpack_require__(3);
- module.exports = function(){
- var that = anObject(this)
- , result = '';
- if(that.global) result += 'g';
- if(that.ignoreCase) result += 'i';
- if(that.multiline) result += 'm';
- if(that.unicode) result += 'u';
- if(that.sticky) result += 'y';
- return result;
- };
- /***/ },
- /* 86 */
- /***/ function(module, exports) {
- // fast apply, http://jsperf.lnkit.com/fast-apply/5
- module.exports = function(fn, args, that){
- var un = that === undefined;
- switch(args.length){
- case 0: return un ? fn()
- : fn.call(that);
- case 1: return un ? fn(args[0])
- : fn.call(that, args[0]);
- case 2: return un ? fn(args[0], args[1])
- : fn.call(that, args[0], args[1]);
- case 3: return un ? fn(args[0], args[1], args[2])
- : fn.call(that, args[0], args[1], args[2]);
- case 4: return un ? fn(args[0], args[1], args[2], args[3])
- : fn.call(that, args[0], args[1], args[2], args[3]);
- } return fn.apply(that, args);
- };
- /***/ },
- /* 87 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.2.8 IsRegExp(argument)
- var isObject = __webpack_require__(7)
- , cof = __webpack_require__(27)
- , MATCH = __webpack_require__(8)('match');
- module.exports = function(it){
- var isRegExp;
- return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
- };
- /***/ },
- /* 88 */
- /***/ function(module, exports, __webpack_require__) {
- var ITERATOR = __webpack_require__(8)('iterator')
- , SAFE_CLOSING = false;
- try {
- var riter = [7][ITERATOR]();
- riter['return'] = function(){ SAFE_CLOSING = true; };
- Array.from(riter, function(){ throw 2; });
- } catch(e){ /* empty */ }
- module.exports = function(exec, skipClosing){
- if(!skipClosing && !SAFE_CLOSING)return false;
- var safe = false;
- try {
- var arr = [7]
- , iter = arr[ITERATOR]();
- iter.next = function(){ return {done: safe = true}; };
- arr[ITERATOR] = function(){ return iter; };
- exec(arr);
- } catch(e){ /* empty */ }
- return safe;
- };
- /***/ },
- /* 89 */
- /***/ function(module, exports, __webpack_require__) {
- // Forced replacement prototype accessors methods
- module.exports = __webpack_require__(46)|| !__webpack_require__(6)(function(){
- var K = Math.random();
- // In FF throws only define methods
- __defineSetter__.call(null, K, function(){ /* empty */});
- delete __webpack_require__(5)[K];
- });
- /***/ },
- /* 90 */
- /***/ function(module, exports) {
- exports.f = Object.getOwnPropertySymbols;
- /***/ },
- /* 91 */
- /***/ function(module, exports, __webpack_require__) {
- // Works with __proto__ only. Old v8 can't work with null proto objects.
- /* eslint-disable no-proto */
- var isObject = __webpack_require__(7)
- , anObject = __webpack_require__(3);
- var check = function(O, proto){
- anObject(O);
- if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
- };
- module.exports = {
- set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
- function(test, buggy, set){
- try {
- set = __webpack_require__(35)(Function.call, __webpack_require__(25).f(Object.prototype, '__proto__').set, 2);
- set(test, []);
- buggy = !(test instanceof Array);
- } catch(e){ buggy = true; }
- return function setPrototypeOf(O, proto){
- check(O, proto);
- if(buggy)O.__proto__ = proto;
- else set(O, proto);
- return O;
- };
- }({}, false) : undefined),
- check: check
- };
- /***/ },
- /* 92 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , SHARED = '__core-js_shared__'
- , store = global[SHARED] || (global[SHARED] = {});
- module.exports = function(key){
- return store[key] || (store[key] = {});
- };
- /***/ },
- /* 93 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , hide = __webpack_require__(19)
- , uid = __webpack_require__(53)
- , TYPED = uid('typed_array')
- , VIEW = uid('view')
- , ABV = !!(global.ArrayBuffer && global.DataView)
- , CONSTR = ABV
- , i = 0, l = 9, Typed;
- var TypedArrayConstructors = (
- 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'
- ).split(',');
- while(i < l){
- if(Typed = global[TypedArrayConstructors[i++]]){
- hide(Typed.prototype, TYPED, true);
- hide(Typed.prototype, VIEW, true);
- } else CONSTR = false;
- }
- module.exports = {
- ABV: ABV,
- CONSTR: CONSTR,
- TYPED: TYPED,
- VIEW: VIEW
- };
- /***/ },
- /* 94 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var curve = exports;
- curve.base = __webpack_require__(486);
- curve.short = __webpack_require__(489);
- curve.mont = __webpack_require__(488);
- curve.edwards = __webpack_require__(487);
- /***/ },
- /* 95 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var md5 = __webpack_require__(195)
- module.exports = EVP_BytesToKey
- function EVP_BytesToKey (password, salt, keyLen, ivLen) {
- if (!Buffer.isBuffer(password)) {
- password = new Buffer(password, 'binary')
- }
- if (salt && !Buffer.isBuffer(salt)) {
- salt = new Buffer(salt, 'binary')
- }
- keyLen = keyLen / 8
- ivLen = ivLen || 0
- var ki = 0
- var ii = 0
- var key = new Buffer(keyLen)
- var iv = new Buffer(ivLen)
- var addmd = 0
- var md_buf
- var i
- var bufs = []
- while (true) {
- if (addmd++ > 0) {
- bufs.push(md_buf)
- }
- bufs.push(password)
- if (salt) {
- bufs.push(salt)
- }
- md_buf = md5(Buffer.concat(bufs))
- bufs = []
- i = 0
- if (keyLen > 0) {
- while (true) {
- if (keyLen === 0) {
- break
- }
- if (i === md_buf.length) {
- break
- }
- key[ki++] = md_buf[i]
- keyLen--
- i++
- }
- }
- if (ivLen > 0 && i !== md_buf.length) {
- while (true) {
- if (ivLen === 0) {
- break
- }
- if (i === md_buf.length) {
- break
- }
- iv[ii++] = md_buf[i]
- ivLen--
- i++
- }
- }
- if (keyLen === 0 && ivLen === 0) {
- break
- }
- }
- for (i = 0; i < md_buf.length; i++) {
- md_buf[i] = 0
- }
- return {
- key: key,
- iv: iv
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 96 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var bs58 = __webpack_require__(56);
- var cs = __webpack_require__(525);
- exports.toHexString = function toHexString(m) {
- if (!Buffer.isBuffer(m)) {
- throw new Error('must be passed a buffer');
- }
- return m.toString('hex');
- };
- exports.fromHexString = function fromHexString(s) {
- return new Buffer(s, 'hex');
- };
- exports.toB58String = function toB58String(m) {
- if (!Buffer.isBuffer(m)) {
- throw new Error('must be passed a buffer');
- }
- return bs58.encode(m);
- };
- exports.fromB58String = function fromB58String(s) {
- var encoded = s;
- if (Buffer.isBuffer(s)) {
- encoded = s.toString();
- }
- return new Buffer(bs58.decode(encoded));
- };
- // Decode a hash from the given Multihash.
- exports.decode = function decode(buf) {
- exports.validate(buf);
- var code = buf[0];
- return {
- code: code,
- name: cs.codes[code],
- length: buf[1],
- digest: buf.slice(2)
- };
- };
- // Encode a hash digest along with the specified function code.
- // Note: the length is derived from the length of the digest itself.
- exports.encode = function encode(digest, code, length) {
- if (!digest || !code) {
- throw new Error('multihash encode requires at least two args: digest, code');
- }
- // ensure it's a hashfunction code.
- var hashfn = exports.coerceCode(code);
- if (!Buffer.isBuffer(digest)) {
- throw new Error('digest should be a Buffer');
- }
- if (length == null) {
- length = digest.length;
- }
- if (length && digest.length !== length) {
- throw new Error('digest length should be equal to specified length.');
- }
- if (length > 127) {
- throw new Error('multihash does not yet support digest lengths greater than 127 bytes.');
- }
- return Buffer.concat([new Buffer([hashfn, length]), digest]);
- };
- // Converts a hashfn name into the matching code
- exports.coerceCode = function coerceCode(name) {
- var code = name;
- if (typeof name === 'string') {
- if (!cs.names[name]) {
- throw new Error('Unrecognized hash function named: ' + name);
- }
- code = cs.names[name];
- }
- if (typeof code !== 'number') {
- throw new Error('Hash function code should be a number. Got: ' + code);
- }
- if (!cs.codes[code] && !exports.isAppCode(code)) {
- throw new Error('Unrecognized function code: ' + code);
- }
- return code;
- };
- // Checks wether a code is part of the app range
- exports.isAppCode = function appCode(code) {
- return code > 0 && code < 0x10;
- };
- // Checks whether a multihash code is valid.
- exports.isValidCode = function validCode(code) {
- if (exports.isAppCode(code)) {
- return true;
- }
- if (cs.codes[code]) {
- return true;
- }
- return false;
- };
- exports.validate = function validate(multihash) {
- if (!Buffer.isBuffer(multihash)) {
- throw new Error('multihash must be a Buffer');
- }
- if (multihash.length < 3) {
- throw new Error('multihash too short. must be > 3 bytes.');
- }
- if (multihash.length > 129) {
- throw new Error('multihash too long. must be < 129 bytes.');
- }
- var code = multihash[0];
- if (!exports.isValidCode(code)) {
- throw new Error('multihash unknown function code: 0x' + code.toString(16));
- }
- if (multihash.slice(2).length !== multihash[1]) {
- throw new Error('multihash length inconsistent: 0x' + multihash.toString('hex'));
- }
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 97 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var asn1 = __webpack_require__(533)
- var aesid = __webpack_require__(233)
- var fixProc = __webpack_require__(534)
- var ciphers = __webpack_require__(102)
- var compat = __webpack_require__(210)
- module.exports = parseKeys
- function parseKeys (buffer) {
- var password
- if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
- password = buffer.passphrase
- buffer = buffer.key
- }
- if (typeof buffer === 'string') {
- buffer = new Buffer(buffer)
- }
- var stripped = fixProc(buffer, password)
- var type = stripped.tag
- var data = stripped.data
- var subtype, ndata
- switch (type) {
- case 'PUBLIC KEY':
- ndata = asn1.PublicKey.decode(data, 'der')
- subtype = ndata.algorithm.algorithm.join('.')
- switch (subtype) {
- case '1.2.840.113549.1.1.1':
- return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
- case '1.2.840.10045.2.1':
- ndata.subjectPrivateKey = ndata.subjectPublicKey
- return {
- type: 'ec',
- data: ndata
- }
- case '1.2.840.10040.4.1':
- ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
- return {
- type: 'dsa',
- data: ndata.algorithm.params
- }
- default: throw new Error('unknown key id ' + subtype)
- }
- throw new Error('unknown key type ' + type)
- case 'ENCRYPTED PRIVATE KEY':
- data = asn1.EncryptedPrivateKey.decode(data, 'der')
- data = decrypt(data, password)
- // falls through
- case 'PRIVATE KEY':
- ndata = asn1.PrivateKey.decode(data, 'der')
- subtype = ndata.algorithm.algorithm.join('.')
- switch (subtype) {
- case '1.2.840.113549.1.1.1':
- return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
- case '1.2.840.10045.2.1':
- return {
- curve: ndata.algorithm.curve,
- privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
- }
- case '1.2.840.10040.4.1':
- ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
- return {
- type: 'dsa',
- params: ndata.algorithm.params
- }
- default: throw new Error('unknown key id ' + subtype)
- }
- throw new Error('unknown key type ' + type)
- case 'RSA PUBLIC KEY':
- return asn1.RSAPublicKey.decode(data, 'der')
- case 'RSA PRIVATE KEY':
- return asn1.RSAPrivateKey.decode(data, 'der')
- case 'DSA PRIVATE KEY':
- return {
- type: 'dsa',
- params: asn1.DSAPrivateKey.decode(data, 'der')
- }
- case 'EC PRIVATE KEY':
- data = asn1.ECPrivateKey.decode(data, 'der')
- return {
- curve: data.parameters.value,
- privateKey: data.privateKey
- }
- default: throw new Error('unknown key type ' + type)
- }
- }
- parseKeys.signature = asn1.signature
- function decrypt (data, password) {
- var salt = data.algorithm.decrypt.kde.kdeparams.salt
- var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
- var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
- var iv = data.algorithm.decrypt.cipher.iv
- var cipherText = data.subjectPrivateKey
- var keylen = parseInt(algo.split('-')[1], 10) / 8
- var key = compat.pbkdf2Sync(password, salt, iters, keylen)
- var cipher = ciphers.createDecipheriv(algo, key, iv)
- var out = []
- out.push(cipher.update(cipherText))
- out.push(cipher.final())
- return Buffer.concat(out)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 98 */
- /***/ function(module, exports) {
- module.exports = extend
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function extend() {
- var target = {}
- for (var i = 0; i < arguments.length; i++) {
- var source = arguments[i]
- for (var key in source) {
- if (hasOwnProperty.call(source, key)) {
- target[key] = source[key]
- }
- }
- }
- return target
- }
- /***/ },
- /* 99 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- exports.DAGNode = __webpack_require__(149);
- exports.DAGLink = __webpack_require__(148);
- exports.DAGService = __webpack_require__(246);
- exports.Batch = __webpack_require__(245);
- exports.util = __webpack_require__(150);
- /***/ },
- /* 100 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var async = __webpack_require__(145);
- var getDagNode = __webpack_require__(276);
- // transform { Hash: '...' } objects into { path: 'string', node: DAGNode }
- module.exports = function (err, res, send, done) {
- if (err) {
- return done(err);
- }
- async.map(res, function map(entry, next) {
- getDagNode(send, entry.Hash, function (err, node) {
- if (err) {
- return next(err);
- }
- var obj = {
- path: entry.Name,
- node: node
- };
- next(null, obj);
- });
- }, function (err, res) {
- done(err, res);
- });
- };
- /***/ },
- /* 101 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var isStream = __webpack_require__(517);
- var addToDagNodesTransform = __webpack_require__(100);
- var promisify = __webpack_require__(78);
- module.exports = function (send) {
- return promisify(function (files, callback) {
- var good = Buffer.isBuffer(files) || isStream.isReadable(files) || Array.isArray(files);
- if (!good) {
- callback(new Error('"files" must be a buffer, readable stream, or array of objects'));
- }
- var sendWithTransform = send.withTransform(addToDagNodesTransform);
- sendWithTransform('add', null, {}, files, callback);
- });
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 102 */
- /***/ function(module, exports, __webpack_require__) {
- var ciphers = __webpack_require__(285)
- exports.createCipher = exports.Cipher = ciphers.createCipher
- exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
- var deciphers = __webpack_require__(284)
- exports.createDecipher = exports.Decipher = deciphers.createDecipher
- exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
- var modes = __webpack_require__(80)
- function getCiphers () {
- return Object.keys(modes)
- }
- exports.listCiphers = exports.getCiphers = getCiphers
- /***/ },
- /* 103 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(12);
- var randomBytes = __webpack_require__(73);
- module.exports = crt;
- function blind(priv) {
- var r = getr(priv);
- var blinder = r.toRed(bn.mont(priv.modulus))
- .redPow(new bn(priv.publicExponent)).fromRed();
- return {
- blinder: blinder,
- unblinder:r.invm(priv.modulus)
- };
- }
- function crt(msg, priv) {
- var blinds = blind(priv);
- var len = priv.modulus.byteLength();
- var mod = bn.mont(priv.modulus);
- var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
- var c1 = blinded.toRed(bn.mont(priv.prime1));
- var c2 = blinded.toRed(bn.mont(priv.prime2));
- var qinv = priv.coefficient;
- var p = priv.prime1;
- var q = priv.prime2;
- var m1 = c1.redPow(priv.exponent1);
- var m2 = c2.redPow(priv.exponent2);
- m1 = m1.fromRed();
- m2 = m2.fromRed();
- var h = m1.isub(m2).imul(qinv).umod(p);
- h.imul(q);
- m2.iadd(h);
- return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
- }
- crt.getr = getr;
- function getr(priv) {
- var len = priv.modulus.byteLength();
- var r = new bn(randomBytes(len));
- while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
- r = new bn(randomBytes(len));
- }
- return r;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 104 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
- 'use strict';
- var toObject = __webpack_require__(16)
- , toIndex = __webpack_require__(52)
- , toLength = __webpack_require__(15);
- module.exports = function fill(value /*, start = 0, end = @length */){
- var O = toObject(this)
- , length = toLength(O.length)
- , aLen = arguments.length
- , index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
- , end = aLen > 2 ? arguments[2] : undefined
- , endPos = end === undefined ? length : toIndex(end, length);
- while(endPos > index)O[index++] = value;
- return O;
- };
- /***/ },
- /* 105 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $defineProperty = __webpack_require__(11)
- , createDesc = __webpack_require__(41);
- module.exports = function(object, index, value){
- if(index in object)$defineProperty.f(object, index, createDesc(0, value));
- else object[index] = value;
- };
- /***/ },
- /* 106 */
- /***/ function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(7)
- , document = __webpack_require__(5).document
- // in old IE typeof document.createElement is 'object'
- , is = isObject(document) && isObject(document.createElement);
- module.exports = function(it){
- return is ? document.createElement(it) : {};
- };
- /***/ },
- /* 107 */
- /***/ function(module, exports) {
- // IE 8- don't enum bug keys
- module.exports = (
- 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
- ).split(',');
- /***/ },
- /* 108 */
- /***/ function(module, exports, __webpack_require__) {
- var MATCH = __webpack_require__(8)('match');
- module.exports = function(KEY){
- var re = /./;
- try {
- '/./'[KEY](re);
- } catch(e){
- try {
- re[MATCH] = false;
- return !'/./'[KEY](re);
- } catch(f){ /* empty */ }
- } return true;
- };
- /***/ },
- /* 109 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(5).document && document.documentElement;
- /***/ },
- /* 110 */
- /***/ function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(7)
- , setPrototypeOf = __webpack_require__(91).set;
- module.exports = function(that, target, C){
- var P, S = target.constructor;
- if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){
- setPrototypeOf(that, P);
- } return that;
- };
- /***/ },
- /* 111 */
- /***/ function(module, exports, __webpack_require__) {
- // check on default Array iterator
- var Iterators = __webpack_require__(45)
- , ITERATOR = __webpack_require__(8)('iterator')
- , ArrayProto = Array.prototype;
- module.exports = function(it){
- return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
- };
- /***/ },
- /* 112 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.2.2 IsArray(argument)
- var cof = __webpack_require__(27);
- module.exports = Array.isArray || function isArray(arg){
- return cof(arg) == 'Array';
- };
- /***/ },
- /* 113 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.3 Number.isInteger(number)
- var isObject = __webpack_require__(7)
- , floor = Math.floor;
- module.exports = function isInteger(it){
- return !isObject(it) && isFinite(it) && floor(it) === it;
- };
- /***/ },
- /* 114 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var create = __webpack_require__(47)
- , descriptor = __webpack_require__(41)
- , setToStringTag = __webpack_require__(61)
- , IteratorPrototype = {};
- // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
- __webpack_require__(19)(IteratorPrototype, __webpack_require__(8)('iterator'), function(){ return this; });
- module.exports = function(Constructor, NAME, next){
- Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
- setToStringTag(Constructor, NAME + ' Iterator');
- };
- /***/ },
- /* 115 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var LIBRARY = __webpack_require__(46)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(22)
- , hide = __webpack_require__(19)
- , has = __webpack_require__(17)
- , Iterators = __webpack_require__(45)
- , $iterCreate = __webpack_require__(114)
- , setToStringTag = __webpack_require__(61)
- , getPrototypeOf = __webpack_require__(26)
- , ITERATOR = __webpack_require__(8)('iterator')
- , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
- , FF_ITERATOR = '@@iterator'
- , KEYS = 'keys'
- , VALUES = 'values';
- var returnThis = function(){ return this; };
- module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
- $iterCreate(Constructor, NAME, next);
- var getMethod = function(kind){
- if(!BUGGY && kind in proto)return proto[kind];
- switch(kind){
- case KEYS: return function keys(){ return new Constructor(this, kind); };
- case VALUES: return function values(){ return new Constructor(this, kind); };
- } return function entries(){ return new Constructor(this, kind); };
- };
- var TAG = NAME + ' Iterator'
- , DEF_VALUES = DEFAULT == VALUES
- , VALUES_BUG = false
- , proto = Base.prototype
- , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
- , $default = $native || getMethod(DEFAULT)
- , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
- , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
- , methods, key, IteratorPrototype;
- // Fix native
- if($anyNative){
- IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
- if(IteratorPrototype !== Object.prototype){
- // Set @@toStringTag to native iterators
- setToStringTag(IteratorPrototype, TAG, true);
- // fix for some old engines
- if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
- }
- }
- // fix Array#{values, @@iterator}.name in V8 / FF
- if(DEF_VALUES && $native && $native.name !== VALUES){
- VALUES_BUG = true;
- $default = function values(){ return $native.call(this); };
- }
- // Define iterator
- if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
- hide(proto, ITERATOR, $default);
- }
- // Plug for library
- Iterators[NAME] = $default;
- Iterators[TAG] = returnThis;
- if(DEFAULT){
- methods = {
- values: DEF_VALUES ? $default : getMethod(VALUES),
- keys: IS_SET ? $default : getMethod(KEYS),
- entries: $entries
- };
- if(FORCED)for(key in methods){
- if(!(key in proto))redefine(proto, key, methods[key]);
- } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
- }
- return methods;
- };
- /***/ },
- /* 116 */
- /***/ function(module, exports) {
- // 20.2.2.14 Math.expm1(x)
- var $expm1 = Math.expm1;
- module.exports = (!$expm1
- // Old FF bug
- || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168
- // Tor Browser bug
- || $expm1(-2e-17) != -2e-17
- ) ? function expm1(x){
- return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
- } : $expm1;
- /***/ },
- /* 117 */
- /***/ function(module, exports) {
- // 20.2.2.28 Math.sign(x)
- module.exports = Math.sign || function sign(x){
- return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
- };
- /***/ },
- /* 118 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , macrotask = __webpack_require__(125).set
- , Observer = global.MutationObserver || global.WebKitMutationObserver
- , process = global.process
- , Promise = global.Promise
- , isNode = __webpack_require__(27)(process) == 'process';
- module.exports = function(){
- var head, last, notify;
- var flush = function(){
- var parent, fn;
- if(isNode && (parent = process.domain))parent.exit();
- while(head){
- fn = head.fn;
- head = head.next;
- try {
- fn();
- } catch(e){
- if(head)notify();
- else last = undefined;
- throw e;
- }
- } last = undefined;
- if(parent)parent.enter();
- };
- // Node.js
- if(isNode){
- notify = function(){
- process.nextTick(flush);
- };
- // browsers with MutationObserver
- } else if(Observer){
- var toggle = true
- , node = document.createTextNode('');
- new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
- notify = function(){
- node.data = toggle = !toggle;
- };
- // environments with maybe non-completely correct, but existent Promise
- } else if(Promise && Promise.resolve){
- var promise = Promise.resolve();
- notify = function(){
- promise.then(flush);
- };
- // for other environments - macrotask based on:
- // - setImmediate
- // - MessageChannel
- // - window.postMessag
- // - onreadystatechange
- // - setTimeout
- } else {
- notify = function(){
- // strange IE + webpack dev server bug - use .call(global)
- macrotask.call(global, flush);
- };
- }
- return function(fn){
- var task = {fn: fn, next: undefined};
- if(last)last.next = task;
- if(!head){
- head = task;
- notify();
- } last = task;
- };
- };
- /***/ },
- /* 119 */
- /***/ function(module, exports, __webpack_require__) {
- var shared = __webpack_require__(92)('keys')
- , uid = __webpack_require__(53);
- module.exports = function(key){
- return shared[key] || (shared[key] = uid(key));
- };
- /***/ },
- /* 120 */
- /***/ function(module, exports, __webpack_require__) {
- // 7.3.20 SpeciesConstructor(O, defaultConstructor)
- var anObject = __webpack_require__(3)
- , aFunction = __webpack_require__(21)
- , SPECIES = __webpack_require__(8)('species');
- module.exports = function(O, D){
- var C = anObject(O).constructor, S;
- return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
- };
- /***/ },
- /* 121 */
- /***/ function(module, exports, __webpack_require__) {
- var toInteger = __webpack_require__(42)
- , defined = __webpack_require__(28);
- // true -> String#at
- // false -> String#codePointAt
- module.exports = function(TO_STRING){
- return function(that, pos){
- var s = String(defined(that))
- , i = toInteger(pos)
- , l = s.length
- , a, b;
- if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
- a = s.charCodeAt(i);
- return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
- ? TO_STRING ? s.charAt(i) : a
- : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
- };
- };
- /***/ },
- /* 122 */
- /***/ function(module, exports, __webpack_require__) {
- // helper for String#{startsWith, endsWith, includes}
- var isRegExp = __webpack_require__(87)
- , defined = __webpack_require__(28);
- module.exports = function(that, searchString, NAME){
- if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!");
- return String(defined(that));
- };
- /***/ },
- /* 123 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var toInteger = __webpack_require__(42)
- , defined = __webpack_require__(28);
- module.exports = function repeat(count){
- var str = String(defined(this))
- , res = ''
- , n = toInteger(count);
- if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
- for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
- return res;
- };
- /***/ },
- /* 124 */
- /***/ function(module, exports) {
- module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
- /***/ },
- /* 125 */
- /***/ function(module, exports, __webpack_require__) {
- var ctx = __webpack_require__(35)
- , invoke = __webpack_require__(86)
- , html = __webpack_require__(109)
- , cel = __webpack_require__(106)
- , global = __webpack_require__(5)
- , process = global.process
- , setTask = global.setImmediate
- , clearTask = global.clearImmediate
- , MessageChannel = global.MessageChannel
- , counter = 0
- , queue = {}
- , ONREADYSTATECHANGE = 'onreadystatechange'
- , defer, channel, port;
- var run = function(){
- var id = +this;
- if(queue.hasOwnProperty(id)){
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- };
- var listener = function(event){
- run.call(event.data);
- };
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if(!setTask || !clearTask){
- setTask = function setImmediate(fn){
- var args = [], i = 1;
- while(arguments.length > i)args.push(arguments[i++]);
- queue[++counter] = function(){
- invoke(typeof fn == 'function' ? fn : Function(fn), args);
- };
- defer(counter);
- return counter;
- };
- clearTask = function clearImmediate(id){
- delete queue[id];
- };
- // Node.js 0.8-
- if(__webpack_require__(27)(process) == 'process'){
- defer = function(id){
- process.nextTick(ctx(run, id, 1));
- };
- // Browsers with MessageChannel, includes WebWorkers
- } else if(MessageChannel){
- channel = new MessageChannel;
- port = channel.port2;
- channel.port1.onmessage = listener;
- defer = ctx(port.postMessage, port, 1);
- // Browsers with postMessage, skip WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
- } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
- defer = function(id){
- global.postMessage(id + '', '*');
- };
- global.addEventListener('message', listener, false);
- // IE8-
- } else if(ONREADYSTATECHANGE in cel('script')){
- defer = function(id){
- html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
- html.removeChild(this);
- run.call(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function(id){
- setTimeout(ctx(run, id, 1), 0);
- };
- }
- }
- module.exports = {
- set: setTask,
- clear: clearTask
- };
- /***/ },
- /* 126 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var global = __webpack_require__(5)
- , DESCRIPTORS = __webpack_require__(10)
- , LIBRARY = __webpack_require__(46)
- , $typed = __webpack_require__(93)
- , hide = __webpack_require__(19)
- , redefineAll = __webpack_require__(50)
- , fails = __webpack_require__(6)
- , anInstance = __webpack_require__(39)
- , toInteger = __webpack_require__(42)
- , toLength = __webpack_require__(15)
- , gOPN = __webpack_require__(48).f
- , dP = __webpack_require__(11).f
- , arrayFill = __webpack_require__(104)
- , setToStringTag = __webpack_require__(61)
- , ARRAY_BUFFER = 'ArrayBuffer'
- , DATA_VIEW = 'DataView'
- , PROTOTYPE = 'prototype'
- , WRONG_LENGTH = 'Wrong length!'
- , WRONG_INDEX = 'Wrong index!'
- , $ArrayBuffer = global[ARRAY_BUFFER]
- , $DataView = global[DATA_VIEW]
- , Math = global.Math
- , parseInt = global.parseInt
- , RangeError = global.RangeError
- , Infinity = global.Infinity
- , BaseBuffer = $ArrayBuffer
- , abs = Math.abs
- , pow = Math.pow
- , min = Math.min
- , floor = Math.floor
- , log = Math.log
- , LN2 = Math.LN2
- , BUFFER = 'buffer'
- , BYTE_LENGTH = 'byteLength'
- , BYTE_OFFSET = 'byteOffset'
- , $BUFFER = DESCRIPTORS ? '_b' : BUFFER
- , $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH
- , $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
- // IEEE754 conversions based on https://github.com/feross/ieee754
- var packIEEE754 = function(value, mLen, nBytes){
- var buffer = Array(nBytes)
- , eLen = nBytes * 8 - mLen - 1
- , eMax = (1 << eLen) - 1
- , eBias = eMax >> 1
- , rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0
- , i = 0
- , s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0
- , e, m, c;
- value = abs(value)
- if(value != value || value === Infinity){
- m = value != value ? 1 : 0;
- e = eMax;
- } else {
- e = floor(log(value) / LN2);
- if(value * (c = pow(2, -e)) < 1){
- e--;
- c *= 2;
- }
- if(e + eBias >= 1){
- value += rt / c;
- } else {
- value += rt * pow(2, 1 - eBias);
- }
- if(value * c >= 2){
- e++;
- c /= 2;
- }
- if(e + eBias >= eMax){
- m = 0;
- e = eMax;
- } else if(e + eBias >= 1){
- m = (value * c - 1) * pow(2, mLen);
- e = e + eBias;
- } else {
- m = value * pow(2, eBias - 1) * pow(2, mLen);
- e = 0;
- }
- }
- for(; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);
- e = e << mLen | m;
- eLen += mLen;
- for(; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);
- buffer[--i] |= s * 128;
- return buffer;
- };
- var unpackIEEE754 = function(buffer, mLen, nBytes){
- var eLen = nBytes * 8 - mLen - 1
- , eMax = (1 << eLen) - 1
- , eBias = eMax >> 1
- , nBits = eLen - 7
- , i = nBytes - 1
- , s = buffer[i--]
- , e = s & 127
- , m;
- s >>= 7;
- for(; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);
- m = e & (1 << -nBits) - 1;
- e >>= -nBits;
- nBits += mLen;
- for(; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);
- if(e === 0){
- e = 1 - eBias;
- } else if(e === eMax){
- return m ? NaN : s ? -Infinity : Infinity;
- } else {
- m = m + pow(2, mLen);
- e = e - eBias;
- } return (s ? -1 : 1) * m * pow(2, e - mLen);
- };
- var unpackI32 = function(bytes){
- return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
- };
- var packI8 = function(it){
- return [it & 0xff];
- };
- var packI16 = function(it){
- return [it & 0xff, it >> 8 & 0xff];
- };
- var packI32 = function(it){
- return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
- };
- var packF64 = function(it){
- return packIEEE754(it, 52, 8);
- };
- var packF32 = function(it){
- return packIEEE754(it, 23, 4);
- };
- var addGetter = function(C, key, internal){
- dP(C[PROTOTYPE], key, {get: function(){ return this[internal]; }});
- };
- var get = function(view, bytes, index, isLittleEndian){
- var numIndex = +index
- , intIndex = toInteger(numIndex);
- if(numIndex != intIndex || intIndex < 0 || intIndex + bytes > view[$LENGTH])throw RangeError(WRONG_INDEX);
- var store = view[$BUFFER]._b
- , start = intIndex + view[$OFFSET]
- , pack = store.slice(start, start + bytes);
- return isLittleEndian ? pack : pack.reverse();
- };
- var set = function(view, bytes, index, conversion, value, isLittleEndian){
- var numIndex = +index
- , intIndex = toInteger(numIndex);
- if(numIndex != intIndex || intIndex < 0 || intIndex + bytes > view[$LENGTH])throw RangeError(WRONG_INDEX);
- var store = view[$BUFFER]._b
- , start = intIndex + view[$OFFSET]
- , pack = conversion(+value);
- for(var i = 0; i < bytes; i++)store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
- };
- var validateArrayBufferArguments = function(that, length){
- anInstance(that, $ArrayBuffer, ARRAY_BUFFER);
- var numberLength = +length
- , byteLength = toLength(numberLength);
- if(numberLength != byteLength)throw RangeError(WRONG_LENGTH);
- return byteLength;
- };
- if(!$typed.ABV){
- $ArrayBuffer = function ArrayBuffer(length){
- var byteLength = validateArrayBufferArguments(this, length);
- this._b = arrayFill.call(Array(byteLength), 0);
- this[$LENGTH] = byteLength;
- };
- $DataView = function DataView(buffer, byteOffset, byteLength){
- anInstance(this, $DataView, DATA_VIEW);
- anInstance(buffer, $ArrayBuffer, DATA_VIEW);
- var bufferLength = buffer[$LENGTH]
- , offset = toInteger(byteOffset);
- if(offset < 0 || offset > bufferLength)throw RangeError('Wrong offset!');
- byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
- if(offset + byteLength > bufferLength)throw RangeError(WRONG_LENGTH);
- this[$BUFFER] = buffer;
- this[$OFFSET] = offset;
- this[$LENGTH] = byteLength;
- };
- if(DESCRIPTORS){
- addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
- addGetter($DataView, BUFFER, '_b');
- addGetter($DataView, BYTE_LENGTH, '_l');
- addGetter($DataView, BYTE_OFFSET, '_o');
- }
- redefineAll($DataView[PROTOTYPE], {
- getInt8: function getInt8(byteOffset){
- return get(this, 1, byteOffset)[0] << 24 >> 24;
- },
- getUint8: function getUint8(byteOffset){
- return get(this, 1, byteOffset)[0];
- },
- getInt16: function getInt16(byteOffset /*, littleEndian */){
- var bytes = get(this, 2, byteOffset, arguments[1]);
- return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
- },
- getUint16: function getUint16(byteOffset /*, littleEndian */){
- var bytes = get(this, 2, byteOffset, arguments[1]);
- return bytes[1] << 8 | bytes[0];
- },
- getInt32: function getInt32(byteOffset /*, littleEndian */){
- return unpackI32(get(this, 4, byteOffset, arguments[1]));
- },
- getUint32: function getUint32(byteOffset /*, littleEndian */){
- return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
- },
- getFloat32: function getFloat32(byteOffset /*, littleEndian */){
- return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
- },
- getFloat64: function getFloat64(byteOffset /*, littleEndian */){
- return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
- },
- setInt8: function setInt8(byteOffset, value){
- set(this, 1, byteOffset, packI8, value);
- },
- setUint8: function setUint8(byteOffset, value){
- set(this, 1, byteOffset, packI8, value);
- },
- setInt16: function setInt16(byteOffset, value /*, littleEndian */){
- set(this, 2, byteOffset, packI16, value, arguments[2]);
- },
- setUint16: function setUint16(byteOffset, value /*, littleEndian */){
- set(this, 2, byteOffset, packI16, value, arguments[2]);
- },
- setInt32: function setInt32(byteOffset, value /*, littleEndian */){
- set(this, 4, byteOffset, packI32, value, arguments[2]);
- },
- setUint32: function setUint32(byteOffset, value /*, littleEndian */){
- set(this, 4, byteOffset, packI32, value, arguments[2]);
- },
- setFloat32: function setFloat32(byteOffset, value /*, littleEndian */){
- set(this, 4, byteOffset, packF32, value, arguments[2]);
- },
- setFloat64: function setFloat64(byteOffset, value /*, littleEndian */){
- set(this, 8, byteOffset, packF64, value, arguments[2]);
- }
- });
- } else {
- if(!fails(function(){
- new $ArrayBuffer; // eslint-disable-line no-new
- }) || !fails(function(){
- new $ArrayBuffer(.5); // eslint-disable-line no-new
- })){
- $ArrayBuffer = function ArrayBuffer(length){
- return new BaseBuffer(validateArrayBufferArguments(this, length));
- };
- var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
- for(var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j; ){
- if(!((key = keys[j++]) in $ArrayBuffer))hide($ArrayBuffer, key, BaseBuffer[key]);
- };
- if(!LIBRARY)ArrayBufferProto.constructor = $ArrayBuffer;
- }
- // iOS Safari 7.x bug
- var view = new $DataView(new $ArrayBuffer(2))
- , $setInt8 = $DataView[PROTOTYPE].setInt8;
- view.setInt8(0, 2147483648);
- view.setInt8(1, 2147483649);
- if(view.getInt8(0) || !view.getInt8(1))redefineAll($DataView[PROTOTYPE], {
- setInt8: function setInt8(byteOffset, value){
- $setInt8.call(this, byteOffset, value << 24 >> 24);
- },
- setUint8: function setUint8(byteOffset, value){
- $setInt8.call(this, byteOffset, value << 24 >> 24);
- }
- }, true);
- }
- setToStringTag($ArrayBuffer, ARRAY_BUFFER);
- setToStringTag($DataView, DATA_VIEW);
- hide($DataView[PROTOTYPE], $typed.VIEW, true);
- exports[ARRAY_BUFFER] = $ArrayBuffer;
- exports[DATA_VIEW] = $DataView;
- /***/ },
- /* 127 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , core = __webpack_require__(32)
- , LIBRARY = __webpack_require__(46)
- , wksExt = __webpack_require__(190)
- , defineProperty = __webpack_require__(11).f;
- module.exports = function(name){
- var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
- if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
- };
- /***/ },
- /* 128 */
- /***/ function(module, exports, __webpack_require__) {
- var classof = __webpack_require__(59)
- , ITERATOR = __webpack_require__(8)('iterator')
- , Iterators = __webpack_require__(45);
- module.exports = __webpack_require__(32).getIteratorMethod = function(it){
- if(it != undefined)return it[ITERATOR]
- || it['@@iterator']
- || Iterators[classof(it)];
- };
- /***/ },
- /* 129 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var addToUnscopables = __webpack_require__(58)
- , step = __webpack_require__(178)
- , Iterators = __webpack_require__(45)
- , toIObject = __webpack_require__(24);
- // 22.1.3.4 Array.prototype.entries()
- // 22.1.3.13 Array.prototype.keys()
- // 22.1.3.29 Array.prototype.values()
- // 22.1.3.30 Array.prototype[@@iterator]()
- module.exports = __webpack_require__(115)(Array, 'Array', function(iterated, kind){
- this._t = toIObject(iterated); // target
- this._i = 0; // next index
- this._k = kind; // kind
- // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
- }, function(){
- var O = this._t
- , kind = this._k
- , index = this._i++;
- if(!O || index >= O.length){
- this._t = undefined;
- return step(1);
- }
- if(kind == 'keys' )return step(0, index);
- if(kind == 'values')return step(0, O[index]);
- return step(0, [index, O[index]]);
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
- Iterators.Arguments = Iterators.Array;
- addToUnscopables('keys');
- addToUnscopables('values');
- addToUnscopables('entries');
- /***/ },
- /* 130 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var createHash = __webpack_require__(63);
- var inherits = __webpack_require__(2)
- var Transform = __webpack_require__(9).Transform
- var ZEROS = new Buffer(128)
- ZEROS.fill(0)
- function Hmac(alg, key) {
- Transform.call(this)
- alg = alg.toLowerCase()
- if (typeof key === 'string') {
- key = new Buffer(key)
- }
- var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
- this._alg = alg
- this._key = key
- if (key.length > blocksize) {
- key = createHash(alg).update(key).digest()
- } else if (key.length < blocksize) {
- key = Buffer.concat([key, ZEROS], blocksize)
- }
- var ipad = this._ipad = new Buffer(blocksize)
- var opad = this._opad = new Buffer(blocksize)
- for (var i = 0; i < blocksize; i++) {
- ipad[i] = key[i] ^ 0x36
- opad[i] = key[i] ^ 0x5C
- }
- this._hash = createHash(alg).update(ipad)
- }
- inherits(Hmac, Transform)
- Hmac.prototype.update = function (data, enc) {
- this._hash.update(data, enc)
- return this
- }
- Hmac.prototype._transform = function (data, _, next) {
- this._hash.update(data)
- next()
- }
- Hmac.prototype._flush = function (next) {
- this.push(this.digest())
- next()
- }
- Hmac.prototype.digest = function (enc) {
- var h = this._hash.digest()
- return createHash(this._alg).update(this._opad).update(h).digest(enc)
- }
- module.exports = function createHmac(alg, key) {
- return new Hmac(alg, key)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 131 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict'
- exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(73)
- exports.createHash = exports.Hash = __webpack_require__(63)
- exports.createHmac = exports.Hmac = __webpack_require__(130)
- var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(__webpack_require__(165)))
- exports.getHashes = function () {
- return hashes
- }
- var p = __webpack_require__(210)
- exports.pbkdf2 = p.pbkdf2
- exports.pbkdf2Sync = p.pbkdf2Sync
- var aes = __webpack_require__(287)
- ;[
- 'Cipher',
- 'createCipher',
- 'Cipheriv',
- 'createCipheriv',
- 'Decipher',
- 'createDecipher',
- 'Decipheriv',
- 'createDecipheriv',
- 'getCiphers',
- 'listCiphers'
- ].forEach(function (key) {
- exports[key] = aes[key]
- })
- var dh = __webpack_require__(484)
- ;[
- 'DiffieHellmanGroup',
- 'createDiffieHellmanGroup',
- 'getDiffieHellman',
- 'createDiffieHellman',
- 'DiffieHellman'
- ].forEach(function (key) {
- exports[key] = dh[key]
- })
- var sign = __webpack_require__(290)
- ;[
- 'createSign',
- 'Sign',
- 'createVerify',
- 'Verify'
- ].forEach(function (key) {
- exports[key] = sign[key]
- })
- exports.createECDH = __webpack_require__(477)
- var publicEncrypt = __webpack_require__(542)
- ;[
- 'publicEncrypt',
- 'privateEncrypt',
- 'publicDecrypt',
- 'privateDecrypt'
- ].forEach(function (key) {
- exports[key] = publicEncrypt[key]
- })
- // the least I can do is make error messages for the rest of the node.js/crypto api.
- ;[
- 'createCredentials'
- ].forEach(function (name) {
- exports[name] = function () {
- throw new Error([
- 'sorry, ' + name + ' is not implemented yet',
- 'we accept pull requests',
- 'https://github.com/crypto-browserify/crypto-browserify'
- ].join('\n'))
- }
- })
- /***/ },
- /* 132 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- exports.utils = __webpack_require__(483);
- exports.Cipher = __webpack_require__(480);
- exports.DES = __webpack_require__(481);
- exports.CBC = __webpack_require__(479);
- exports.EDE = __webpack_require__(482);
- /***/ },
- /* 133 */
- /***/ function(module, exports) {
- var toString = {}.toString;
- module.exports = Array.isArray || function (arr) {
- return toString.call(arr) == '[object Array]';
- };
- /***/ },
- /* 134 */
- /***/ function(module, exports, __webpack_require__) {
- /**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- var baseEach = __webpack_require__(202),
- baseIteratee = __webpack_require__(203);
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /** `Object#toString` result references. */
- var funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]';
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /**
- * The base implementation of `_.map` without support for iteratee shorthands.
- *
- * @private
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function baseMap(collection, iteratee) {
- var index = -1,
- result = isArrayLike(collection) ? Array(collection.length) : [];
- baseEach(collection, function(value, key, collection) {
- result[++index] = iteratee(value, key, collection);
- });
- return result;
- }
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
- /**
- * Creates an array of values by running each element in `collection` thru
- * `iteratee`. The iteratee is invoked with three arguments:
- * (value, index|key, collection).
- *
- * Many lodash methods are guarded to work as iteratees for methods like
- * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
- *
- * The guarded methods are:
- * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
- * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
- * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
- * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Collection
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- * @example
- *
- * function square(n) {
- * return n * n;
- * }
- *
- * _.map([4, 8], square);
- * // => [16, 64]
- *
- * _.map({ 'a': 4, 'b': 8 }, square);
- * // => [16, 64] (iteration order is not guaranteed)
- *
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
- * ];
- *
- * // The `_.property` iteratee shorthand.
- * _.map(users, 'user');
- * // => ['barney', 'fred']
- */
- function map(collection, iteratee) {
- var func = isArray(collection) ? arrayMap : baseMap;
- return func(collection, baseIteratee(iteratee, 3));
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @type {Function}
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
- }
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- module.exports = map;
- /***/ },
- /* 135 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = minimatch
- minimatch.Minimatch = Minimatch
- var path = { sep: '/' }
- try {
- path = __webpack_require__(43)
- } catch (er) {}
- var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
- var expand = __webpack_require__(283)
- // any single thing other than /
- // don't need to escape / when using new RegExp()
- var qmark = '[^/]'
- // * => any number of characters
- var star = qmark + '*?'
- // ** when dots are allowed. Anything goes, except .. and .
- // not (^ or / followed by one or two dots followed by $ or /),
- // followed by anything, any number of times.
- var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
- // not a ^ or / followed by a dot,
- // followed by anything, any number of times.
- var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
- // characters that need to be escaped in RegExp.
- var reSpecials = charSet('().*{}+?[]^$\\!')
- // "abc" -> { a:true, b:true, c:true }
- function charSet (s) {
- return s.split('').reduce(function (set, c) {
- set[c] = true
- return set
- }, {})
- }
- // normalizes slashes.
- var slashSplit = /\/+/
- minimatch.filter = filter
- function filter (pattern, options) {
- options = options || {}
- return function (p, i, list) {
- return minimatch(p, pattern, options)
- }
- }
- function ext (a, b) {
- a = a || {}
- b = b || {}
- var t = {}
- Object.keys(b).forEach(function (k) {
- t[k] = b[k]
- })
- Object.keys(a).forEach(function (k) {
- t[k] = a[k]
- })
- return t
- }
- minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return minimatch
- var orig = minimatch
- var m = function minimatch (p, pattern, options) {
- return orig.minimatch(p, pattern, ext(def, options))
- }
- m.Minimatch = function Minimatch (pattern, options) {
- return new orig.Minimatch(pattern, ext(def, options))
- }
- return m
- }
- Minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return Minimatch
- return minimatch.defaults(def).Minimatch
- }
- function minimatch (p, pattern, options) {
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required')
- }
- if (!options) options = {}
- // shortcut: comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- return false
- }
- // "" only matches ""
- if (pattern.trim() === '') return p === ''
- return new Minimatch(pattern, options).match(p)
- }
- function Minimatch (pattern, options) {
- if (!(this instanceof Minimatch)) {
- return new Minimatch(pattern, options)
- }
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required')
- }
- if (!options) options = {}
- pattern = pattern.trim()
- // windows support: need to use /, not \
- if (path.sep !== '/') {
- pattern = pattern.split(path.sep).join('/')
- }
- this.options = options
- this.set = []
- this.pattern = pattern
- this.regexp = null
- this.negate = false
- this.comment = false
- this.empty = false
- // make the set of regexps etc.
- this.make()
- }
- Minimatch.prototype.debug = function () {}
- Minimatch.prototype.make = make
- function make () {
- // don't do it more than once.
- if (this._made) return
- var pattern = this.pattern
- var options = this.options
- // empty patterns and comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- this.comment = true
- return
- }
- if (!pattern) {
- this.empty = true
- return
- }
- // step 1: figure out negation, etc.
- this.parseNegate()
- // step 2: expand braces
- var set = this.globSet = this.braceExpand()
- if (options.debug) this.debug = console.error
- this.debug(this.pattern, set)
- // step 3: now we have a set, so turn each one into a series of path-portion
- // matching patterns.
- // These will be regexps, except in the case of "**", which is
- // set to the GLOBSTAR object for globstar behavior,
- // and will not contain any / characters
- set = this.globParts = set.map(function (s) {
- return s.split(slashSplit)
- })
- this.debug(this.pattern, set)
- // glob --> regexps
- set = set.map(function (s, si, set) {
- return s.map(this.parse, this)
- }, this)
- this.debug(this.pattern, set)
- // filter out everything that didn't compile properly.
- set = set.filter(function (s) {
- return s.indexOf(false) === -1
- })
- this.debug(this.pattern, set)
- this.set = set
- }
- Minimatch.prototype.parseNegate = parseNegate
- function parseNegate () {
- var pattern = this.pattern
- var negate = false
- var options = this.options
- var negateOffset = 0
- if (options.nonegate) return
- for (var i = 0, l = pattern.length
- ; i < l && pattern.charAt(i) === '!'
- ; i++) {
- negate = !negate
- negateOffset++
- }
- if (negateOffset) this.pattern = pattern.substr(negateOffset)
- this.negate = negate
- }
- // Brace expansion:
- // a{b,c}d -> abd acd
- // a{b,}c -> abc ac
- // a{0..3}d -> a0d a1d a2d a3d
- // a{b,c{d,e}f}g -> abg acdfg acefg
- // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
- //
- // Invalid sets are not expanded.
- // a{2..}b -> a{2..}b
- // a{b}c -> a{b}c
- minimatch.braceExpand = function (pattern, options) {
- return braceExpand(pattern, options)
- }
- Minimatch.prototype.braceExpand = braceExpand
- function braceExpand (pattern, options) {
- if (!options) {
- if (this instanceof Minimatch) {
- options = this.options
- } else {
- options = {}
- }
- }
- pattern = typeof pattern === 'undefined'
- ? this.pattern : pattern
- if (typeof pattern === 'undefined') {
- throw new TypeError('undefined pattern')
- }
- if (options.nobrace ||
- !pattern.match(/\{.*\}/)) {
- // shortcut. no need to expand.
- return [pattern]
- }
- return expand(pattern)
- }
- // parse a component of the expanded set.
- // At this point, no pattern may contain "/" in it
- // so we're going to return a 2d array, where each entry is the full
- // pattern, split on '/', and then turned into a regular expression.
- // A regexp is made at the end which joins each array with an
- // escaped /, and another full one which joins each regexp with |.
- //
- // Following the lead of Bash 4.1, note that "**" only has special meaning
- // when it is the *only* thing in a path portion. Otherwise, any series
- // of * is equivalent to a single *. Globstar behavior is enabled by
- // default, and can be disabled by setting options.noglobstar.
- Minimatch.prototype.parse = parse
- var SUBPARSE = {}
- function parse (pattern, isSub) {
- if (pattern.length > 1024 * 64) {
- throw new TypeError('pattern is too long')
- }
- var options = this.options
- // shortcuts
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
- if (pattern === '') return ''
- var re = ''
- var hasMagic = !!options.nocase
- var escaping = false
- // ? => one single character
- var patternListStack = []
- var negativeLists = []
- var plType
- var stateChar
- var inClass = false
- var reClassStart = -1
- var classStart = -1
- // . and .. never match anything that doesn't start with .,
- // even when options.dot is set.
- var patternStart = pattern.charAt(0) === '.' ? '' // anything
- // not (start or / followed by . or .. followed by / or end)
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
- : '(?!\\.)'
- var self = this
- function clearStateChar () {
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case '*':
- re += star
- hasMagic = true
- break
- case '?':
- re += qmark
- hasMagic = true
- break
- default:
- re += '\\' + stateChar
- break
- }
- self.debug('clearStateChar %j %j', stateChar, re)
- stateChar = false
- }
- }
- for (var i = 0, len = pattern.length, c
- ; (i < len) && (c = pattern.charAt(i))
- ; i++) {
- this.debug('%s\t%s %s %j', pattern, i, re, c)
- // skip over any that are escaped.
- if (escaping && reSpecials[c]) {
- re += '\\' + c
- escaping = false
- continue
- }
- switch (c) {
- case '/':
- // completely not allowed, even escaped.
- // Should already be path-split by now.
- return false
- case '\\':
- clearStateChar()
- escaping = true
- continue
- // the various stateChar values
- // for the "extglob" stuff.
- case '?':
- case '*':
- case '+':
- case '@':
- case '!':
- this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
- // all of those are literals inside a class, except that
- // the glob [!a] means [^a] in regexp
- if (inClass) {
- this.debug(' in class')
- if (c === '!' && i === classStart + 1) c = '^'
- re += c
- continue
- }
- // if we already have a stateChar, then it means
- // that there was something like ** or +? in there.
- // Handle the stateChar, then proceed with this one.
- self.debug('call clearStateChar %j', stateChar)
- clearStateChar()
- stateChar = c
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
- // just clear the statechar *now*, rather than even diving into
- // the patternList stuff.
- if (options.noext) clearStateChar()
- continue
- case '(':
- if (inClass) {
- re += '('
- continue
- }
- if (!stateChar) {
- re += '\\('
- continue
- }
- plType = stateChar
- patternListStack.push({
- type: plType,
- start: i - 1,
- reStart: re.length
- })
- // negation is (?:(?!js)[^/]*)
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
- this.debug('plType %j %j', stateChar, re)
- stateChar = false
- continue
- case ')':
- if (inClass || !patternListStack.length) {
- re += '\\)'
- continue
- }
- clearStateChar()
- hasMagic = true
- re += ')'
- var pl = patternListStack.pop()
- plType = pl.type
- // negation is (?:(?!js)[^/]*)
- // The others are (?:<pattern>)<type>
- switch (plType) {
- case '!':
- negativeLists.push(pl)
- re += ')[^/]*?)'
- pl.reEnd = re.length
- break
- case '?':
- case '+':
- case '*':
- re += plType
- break
- case '@': break // the default anyway
- }
- continue
- case '|':
- if (inClass || !patternListStack.length || escaping) {
- re += '\\|'
- escaping = false
- continue
- }
- clearStateChar()
- re += '|'
- continue
- // these are mostly the same in regexp and glob
- case '[':
- // swallow any state-tracking char before the [
- clearStateChar()
- if (inClass) {
- re += '\\' + c
- continue
- }
- inClass = true
- classStart = i
- reClassStart = re.length
- re += c
- continue
- case ']':
- // a right bracket shall lose its special
- // meaning and represent itself in
- // a bracket expression if it occurs
- // first in the list. -- POSIX.2 2.8.3.2
- if (i === classStart + 1 || !inClass) {
- re += '\\' + c
- escaping = false
- continue
- }
- // handle the case where we left a class open.
- // "[z-a]" is valid, equivalent to "\[z-a\]"
- if (inClass) {
- // split where the last [ was, make sure we don't have
- // an invalid re. if so, re-walk the contents of the
- // would-be class to re-translate any characters that
- // were passed through as-is
- // TODO: It would probably be faster to determine this
- // without a try/catch and a new RegExp, but it's tricky
- // to do safely. For now, this is safe and works.
- var cs = pattern.substring(classStart + 1, i)
- try {
- RegExp('[' + cs + ']')
- } catch (er) {
- // not a valid class!
- var sp = this.parse(cs, SUBPARSE)
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
- hasMagic = hasMagic || sp[1]
- inClass = false
- continue
- }
- }
- // finish up the class.
- hasMagic = true
- inClass = false
- re += c
- continue
- default:
- // swallow any state char that wasn't consumed
- clearStateChar()
- if (escaping) {
- // no need
- escaping = false
- } else if (reSpecials[c]
- && !(c === '^' && inClass)) {
- re += '\\'
- }
- re += c
- } // switch
- } // for
- // handle the case where we left a class open.
- // "[abc" is valid, equivalent to "\[abc"
- if (inClass) {
- // split where the last [ was, and escape it
- // this is a huge pita. We now have to re-walk
- // the contents of the would-be class to re-translate
- // any characters that were passed through as-is
- cs = pattern.substr(classStart + 1)
- sp = this.parse(cs, SUBPARSE)
- re = re.substr(0, reClassStart) + '\\[' + sp[0]
- hasMagic = hasMagic || sp[1]
- }
- // handle the case where we had a +( thing at the *end*
- // of the pattern.
- // each pattern list stack adds 3 chars, and we need to go through
- // and escape any | chars that were passed through as-is for the regexp.
- // Go through and escape them, taking care not to double-escape any
- // | chars that were already escaped.
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
- var tail = re.slice(pl.reStart + 3)
- // maybe some even number of \, then maybe 1 \, followed by a |
- tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
- if (!$2) {
- // the | isn't already escaped, so escape it.
- $2 = '\\'
- }
- // need to escape all those slashes *again*, without escaping the
- // one that we need for escaping the | character. As it works out,
- // escaping an even number of slashes can be done by simply repeating
- // it exactly after itself. That's why this trick works.
- //
- // I am sorry that you have to see this.
- return $1 + $1 + $2 + '|'
- })
- this.debug('tail=%j\n %s', tail, tail)
- var t = pl.type === '*' ? star
- : pl.type === '?' ? qmark
- : '\\' + pl.type
- hasMagic = true
- re = re.slice(0, pl.reStart) + t + '\\(' + tail
- }
- // handle trailing things that only matter at the very end.
- clearStateChar()
- if (escaping) {
- // trailing \\
- re += '\\\\'
- }
- // only need to apply the nodot start if the re starts with
- // something that could conceivably capture a dot
- var addPatternStart = false
- switch (re.charAt(0)) {
- case '.':
- case '[':
- case '(': addPatternStart = true
- }
- // Hack to work around lack of negative lookbehind in JS
- // A pattern like: *.!(x).!(y|z) needs to ensure that a name
- // like 'a.xyz.yz' doesn't match. So, the first negative
- // lookahead, has to look ALL the way ahead, to the end of
- // the pattern.
- for (var n = negativeLists.length - 1; n > -1; n--) {
- var nl = negativeLists[n]
- var nlBefore = re.slice(0, nl.reStart)
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
- var nlAfter = re.slice(nl.reEnd)
- nlLast += nlAfter
- // Handle nested stuff like *(*.js|!(*.json)), where open parens
- // mean that we should *not* include the ) in the bit that is considered
- // "after" the negated section.
- var openParensBefore = nlBefore.split('(').length - 1
- var cleanAfter = nlAfter
- for (i = 0; i < openParensBefore; i++) {
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
- }
- nlAfter = cleanAfter
- var dollar = ''
- if (nlAfter === '' && isSub !== SUBPARSE) {
- dollar = '$'
- }
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
- re = newRe
- }
- // if the re is not "" at this point, then we need to make sure
- // it doesn't match against an empty path part.
- // Otherwise a/* will match a/, which it should not.
- if (re !== '' && hasMagic) {
- re = '(?=.)' + re
- }
- if (addPatternStart) {
- re = patternStart + re
- }
- // parsing just a piece of a larger pattern.
- if (isSub === SUBPARSE) {
- return [re, hasMagic]
- }
- // skip the regexp for non-magical patterns
- // unescape anything in it, though, so that it'll be
- // an exact match against a file etc.
- if (!hasMagic) {
- return globUnescape(pattern)
- }
- var flags = options.nocase ? 'i' : ''
- try {
- var regExp = new RegExp('^' + re + '$', flags)
- } catch (er) {
- // If it was an invalid regular expression, then it can't match
- // anything. This trick looks for a character after the end of
- // the string, which is of course impossible, except in multi-line
- // mode, but it's not a /m regex.
- return new RegExp('$.')
- }
- regExp._glob = pattern
- regExp._src = re
- return regExp
- }
- minimatch.makeRe = function (pattern, options) {
- return new Minimatch(pattern, options || {}).makeRe()
- }
- Minimatch.prototype.makeRe = makeRe
- function makeRe () {
- if (this.regexp || this.regexp === false) return this.regexp
- // at this point, this.set is a 2d array of partial
- // pattern strings, or "**".
- //
- // It's better to use .match(). This function shouldn't
- // be used, really, but it's pretty convenient sometimes,
- // when you just want to work with a regex.
- var set = this.set
- if (!set.length) {
- this.regexp = false
- return this.regexp
- }
- var options = this.options
- var twoStar = options.noglobstar ? star
- : options.dot ? twoStarDot
- : twoStarNoDot
- var flags = options.nocase ? 'i' : ''
- var re = set.map(function (pattern) {
- return pattern.map(function (p) {
- return (p === GLOBSTAR) ? twoStar
- : (typeof p === 'string') ? regExpEscape(p)
- : p._src
- }).join('\\\/')
- }).join('|')
- // must match entire pattern
- // ending in a * or ** will make it less strict.
- re = '^(?:' + re + ')$'
- // can match anything, as long as it's not this.
- if (this.negate) re = '^(?!' + re + ').*$'
- try {
- this.regexp = new RegExp(re, flags)
- } catch (ex) {
- this.regexp = false
- }
- return this.regexp
- }
- minimatch.match = function (list, pattern, options) {
- options = options || {}
- var mm = new Minimatch(pattern, options)
- list = list.filter(function (f) {
- return mm.match(f)
- })
- if (mm.options.nonull && !list.length) {
- list.push(pattern)
- }
- return list
- }
- Minimatch.prototype.match = match
- function match (f, partial) {
- this.debug('match', f, this.pattern)
- // short-circuit in the case of busted things.
- // comments, etc.
- if (this.comment) return false
- if (this.empty) return f === ''
- if (f === '/' && partial) return true
- var options = this.options
- // windows: need to use /, not \
- if (path.sep !== '/') {
- f = f.split(path.sep).join('/')
- }
- // treat the test path as a set of pathparts.
- f = f.split(slashSplit)
- this.debug(this.pattern, 'split', f)
- // just ONE of the pattern sets in this.set needs to match
- // in order for it to be valid. If negating, then just one
- // match means that we have failed.
- // Either way, return on the first hit.
- var set = this.set
- this.debug(this.pattern, 'set', set)
- // Find the basename of the path by looking for the last non-empty segment
- var filename
- var i
- for (i = f.length - 1; i >= 0; i--) {
- filename = f[i]
- if (filename) break
- }
- for (i = 0; i < set.length; i++) {
- var pattern = set[i]
- var file = f
- if (options.matchBase && pattern.length === 1) {
- file = [filename]
- }
- var hit = this.matchOne(file, pattern, partial)
- if (hit) {
- if (options.flipNegate) return true
- return !this.negate
- }
- }
- // didn't get any hits. this is success if it's a negative
- // pattern, failure otherwise.
- if (options.flipNegate) return false
- return this.negate
- }
- // set partial to true to test if, for example,
- // "/a/b" matches the start of "/*/b/*/d"
- // Partial means, if you run out of file before you run
- // out of pattern, then that's fine, as long as all
- // the parts match.
- Minimatch.prototype.matchOne = function (file, pattern, partial) {
- var options = this.options
- this.debug('matchOne',
- { 'this': this, file: file, pattern: pattern })
- this.debug('matchOne', file.length, pattern.length)
- for (var fi = 0,
- pi = 0,
- fl = file.length,
- pl = pattern.length
- ; (fi < fl) && (pi < pl)
- ; fi++, pi++) {
- this.debug('matchOne loop')
- var p = pattern[pi]
- var f = file[fi]
- this.debug(pattern, p, f)
- // should be impossible.
- // some invalid regexp stuff in the set.
- if (p === false) return false
- if (p === GLOBSTAR) {
- this.debug('GLOBSTAR', [pattern, p, f])
- // "**"
- // a/**/b/**/c would match the following:
- // a/b/x/y/z/c
- // a/x/y/z/b/c
- // a/b/x/b/x/c
- // a/b/c
- // To do this, take the rest of the pattern after
- // the **, and see if it would match the file remainder.
- // If so, return success.
- // If not, the ** "swallows" a segment, and try again.
- // This is recursively awful.
- //
- // a/**/b/**/c matching a/b/x/y/z/c
- // - a matches a
- // - doublestar
- // - matchOne(b/x/y/z/c, b/**/c)
- // - b matches b
- // - doublestar
- // - matchOne(x/y/z/c, c) -> no
- // - matchOne(y/z/c, c) -> no
- // - matchOne(z/c, c) -> no
- // - matchOne(c, c) yes, hit
- var fr = fi
- var pr = pi + 1
- if (pr === pl) {
- this.debug('** at the end')
- // a ** at the end will just swallow the rest.
- // We have found a match.
- // however, it will not swallow /.x, unless
- // options.dot is set.
- // . and .. are *never* matched by **, for explosively
- // exponential reasons.
- for (; fi < fl; fi++) {
- if (file[fi] === '.' || file[fi] === '..' ||
- (!options.dot && file[fi].charAt(0) === '.')) return false
- }
- return true
- }
- // ok, let's see if we can swallow whatever we can.
- while (fr < fl) {
- var swallowee = file[fr]
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
- // XXX remove this slice. Just pass the start index.
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
- this.debug('globstar found match!', fr, fl, swallowee)
- // found a match.
- return true
- } else {
- // can't swallow "." or ".." ever.
- // can only swallow ".foo" when explicitly asked.
- if (swallowee === '.' || swallowee === '..' ||
- (!options.dot && swallowee.charAt(0) === '.')) {
- this.debug('dot detected!', file, fr, pattern, pr)
- break
- }
- // ** swallows a segment, and continue.
- this.debug('globstar swallow a segment, and continue')
- fr++
- }
- }
- // no match was found.
- // However, in partial mode, we can't say this is necessarily over.
- // If there's more *pattern* left, then
- if (partial) {
- // ran out of file
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
- if (fr === fl) return true
- }
- return false
- }
- // something other than **
- // non-magic patterns just have to match exactly
- // patterns with magic have been turned into regexps.
- var hit
- if (typeof p === 'string') {
- if (options.nocase) {
- hit = f.toLowerCase() === p.toLowerCase()
- } else {
- hit = f === p
- }
- this.debug('string match', p, f, hit)
- } else {
- hit = f.match(p)
- this.debug('pattern match', p, f, hit)
- }
- if (!hit) return false
- }
- // Note: ending in / means that we'll get a final ""
- // at the end of the pattern. This can only match a
- // corresponding "" at the end of the file.
- // If the file ends in /, then it can only match a
- // a pattern that ends in /, unless the pattern just
- // doesn't have any more for it. But, a/b/ should *not*
- // match "a/b/*", even though "" matches against the
- // [^/]*? pattern, except in partial mode, where it might
- // simply not be reached yet.
- // However, a/b/ should still satisfy a/*
- // now either we fell off the end of the pattern, or we're done.
- if (fi === fl && pi === pl) {
- // ran out of pattern and filename at the same time.
- // an exact hit!
- return true
- } else if (fi === fl) {
- // ran out of file, but still had pattern left.
- // this is ok if we're doing the match as part of
- // a glob fs traversal.
- return partial
- } else if (pi === pl) {
- // ran out of pattern, still have file left.
- // this is only acceptable if we're on the very last
- // empty segment of a file with a trailing slash.
- // a/* should match a/b/
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
- return emptyFileEnd
- }
- // should be unreachable.
- throw new Error('wtf?')
- }
- // replace stuff like \* with *
- function globUnescape (s) {
- return s.replace(/\\(.)/g, '$1')
- }
- function regExpEscape (s) {
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
- }
- /***/ },
- /* 136 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var map = __webpack_require__(134);
- module.exports = Protocols;
- function Protocols(proto) {
- if (typeof proto === 'number') {
- if (Protocols.codes[proto]) {
- return Protocols.codes[proto];
- }
- throw new Error('no protocol with code: ' + proto);
- } else if (typeof proto === 'string' || proto instanceof String) {
- if (Protocols.names[proto]) {
- return Protocols.names[proto];
- }
- throw new Error('no protocol with name: ' + proto);
- }
- throw new Error('invalid protocol id type: ' + proto);
- }
- Protocols.lengthPrefixedVarSize = -1;
- // replicating table here to:
- // 1. avoid parsing the csv
- // 2. ensuring errors in the csv don't screw up code.
- // 3. changing a number has to happen in two places.
- Protocols.table = [[4, 32, 'ip4'], [6, 16, 'tcp'], [17, 16, 'udp'], [33, 16, 'dccp'], [41, 128, 'ip6'], [132, 16, 'sctp'],
- // these require varint for the protocol code
- [302, 0, 'utp'], [421, Protocols.lengthPrefixedVarSize, 'ipfs'], [480, 0, 'http'], [443, 0, 'https'], [477, 0, 'ws'], [275, 0, 'libp2p-webrtc-star']];
- Protocols.names = {};
- Protocols.codes = {};
- // populate tables
- map(Protocols.table, function (e) {
- var proto = p.apply(this, e);
- Protocols.codes[proto.code] = proto;
- Protocols.names[proto.name] = proto;
- });
- Protocols.object = p;
- function p(code, size, name) {
- return { code: code, size: size, name: name };
- }
- /***/ },
- /* 137 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
- function posix(path) {
- return path.charAt(0) === '/';
- };
- function win32(path) {
- // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
- var result = splitDeviceRe.exec(path);
- var device = result[1] || '';
- var isUnc = !!device && device.charAt(1) !== ':';
- // UNC paths are always absolute
- return !!result[2] || isUnc;
- };
- module.exports = process.platform === 'win32' ? win32 : posix;
- module.exports.posix = posix;
- module.exports.win32 = win32;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 138 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- 'use strict';
- module.exports = Transform;
- var Duplex = __webpack_require__(55);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(stream) {
- this.afterTransform = function (er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- this.writeencoding = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (data !== null && data !== undefined) stream.push(data);
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
- Duplex.call(this, options);
- this._transformState = new TransformState(this);
- // when the writable side finishes, then flush out anything remaining.
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
- if (typeof options.flush === 'function') this._flush = options.flush;
- }
- this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er) {
- done(stream, er);
- });else done(stream);
- });
- }
- Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('not implemented');
- };
- Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function (n) {
- var ts = this._transformState;
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er) {
- if (er) return stream.emit('error', er);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
- if (ws.length) throw new Error('calling transform done when ws.length != 0');
- if (ts.transforming) throw new Error('calling transform done when still transforming');
- return stream.push(null);
- }
- /***/ },
- /* 139 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process, setImmediate) {// A bit simpler than readable streams.
- // Implement an async ._write(chunk, encoding, cb), and it'll handle all
- // the drain event emission and buffering.
- 'use strict';
- module.exports = Writable;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
- /*</replacement>*/
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- /*<replacement>*/
- var internalUtil = {
- deprecate: __webpack_require__(227)
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(9);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(30).EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- util.inherits(Writable, Stream);
- function nop() {}
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- this.next = null;
- }
- var Duplex;
- function WritableState(options, stream) {
- Duplex = Duplex || __webpack_require__(55);
- options = options || {};
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function (er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.bufferedRequest = null;
- this.lastBufferedRequest = null;
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- // count buffered requests
- this.bufferedRequestCount = 0;
- // create the two objects needed to store the corked requests
- // they are not a linked list, as no new elements are inserted in there
- this.corkedRequestsFree = new CorkedRequest(this);
- this.corkedRequestsFree.next = new CorkedRequest(this);
- }
- WritableState.prototype.getBuffer = function writableStateGetBuffer() {
- var current = this.bufferedRequest;
- var out = [];
- while (current) {
- out.push(current);
- current = current.next;
- }
- return out;
- };
- (function () {
- try {
- Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function () {
- return this.getBuffer();
- }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
- });
- } catch (_) {}
- })();
- var Duplex;
- function Writable(options) {
- Duplex = Duplex || __webpack_require__(55);
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- if (options) {
- if (typeof options.write === 'function') this._write = options.write;
- if (typeof options.writev === 'function') this._writev = options.writev;
- }
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function () {
- this.emit('error', new Error('Cannot pipe. Not readable.'));
- };
- function writeAfterEnd(stream, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- processNextTick(cb, er);
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
- var er = new TypeError('Invalid non-string/buffer chunk');
- stream.emit('error', er);
- processNextTick(cb, er);
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function (chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
- if (typeof cb !== 'function') cb = nop;
- if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- }
- return ret;
- };
- Writable.prototype.cork = function () {
- var state = this._writableState;
- state.corked++;
- };
- Writable.prototype.uncork = function () {
- var state = this._writableState;
- if (state.corked) {
- state.corked--;
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
- }
- };
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
- // node::ParseEncoding() requires lower case.
- if (typeof encoding === 'string') encoding = encoding.toLowerCase();
- 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);
- this._writableState.defaultEncoding = encoding;
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
- chunk = new Buffer(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret) state.needDrain = true;
- if (state.writing || state.corked) {
- var last = state.lastBufferedRequest;
- state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
- if (last) {
- last.next = state.lastBufferedRequest;
- } else {
- state.bufferedRequest = state.lastBufferedRequest;
- }
- state.bufferedRequestCount += 1;
- } else {
- doWrite(stream, state, false, len, chunk, encoding, cb);
- }
- return ret;
- }
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- --state.pendingcb;
- if (sync) processNextTick(cb, er);else cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er) onwriteError(stream, state, sync, er, cb);else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(state);
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
- clearBuffer(stream, state);
- }
- if (sync) {
- /*<replacement>*/
- asyncWrite(afterWrite, stream, state, finished, cb);
- /*</replacement>*/
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished) onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- var entry = state.bufferedRequest;
- if (stream._writev && entry && entry.next) {
- // Fast case, write everything using _writev()
- var l = state.bufferedRequestCount;
- var buffer = new Array(l);
- var holder = state.corkedRequestsFree;
- holder.entry = entry;
- var count = 0;
- while (entry) {
- buffer[count] = entry;
- entry = entry.next;
- count += 1;
- }
- doWrite(stream, state, true, state.length, buffer, '', holder.finish);
- // doWrite is always async, defer these to save a bit of time
- // as the hot path ends with doWrite
- state.pendingcb++;
- state.lastBufferedRequest = null;
- state.corkedRequestsFree = holder.next;
- holder.next = null;
- } else {
- // Slow case, write chunks one-by-one
- while (entry) {
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, false, len, chunk, encoding, cb);
- entry = entry.next;
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- break;
- }
- }
- if (entry === null) state.lastBufferedRequest = null;
- }
- state.bufferedRequestCount = 0;
- state.bufferedRequest = entry;
- state.bufferProcessing = false;
- }
- Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('not implemented'));
- };
- Writable.prototype._writev = null;
- Writable.prototype.end = function (chunk, encoding, cb) {
- var state = this._writableState;
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished) endWritable(this, state, cb);
- };
- function needFinish(state) {
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
- }
- function prefinish(stream, state) {
- if (!state.prefinished) {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
- function finishMaybe(stream, state) {
- var need = needFinish(state);
- if (need) {
- if (state.pendingcb === 0) {
- prefinish(stream, state);
- state.finished = true;
- stream.emit('finish');
- } else {
- prefinish(stream, state);
- }
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished) processNextTick(cb);else stream.once('finish', cb);
- }
- state.ended = true;
- stream.writable = false;
- }
- // It seems a linked list but it is not
- // there will be only 2 of these for each stream
- function CorkedRequest(state) {
- var _this = this;
- this.next = null;
- this.entry = null;
- this.finish = function (err) {
- var entry = _this.entry;
- _this.entry = null;
- while (entry) {
- var cb = entry.callback;
- state.pendingcb--;
- cb(err);
- entry = entry.next;
- }
- if (state.corkedRequestsFree) {
- state.corkedRequestsFree.next = _this;
- } else {
- state.corkedRequestsFree = _this;
- }
- };
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(74).setImmediate))
- /***/ },
- /* 140 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- var Reporter = __webpack_require__(67).Reporter;
- var Buffer = __webpack_require__(1).Buffer;
- function DecoderBuffer(base, options) {
- Reporter.call(this, options);
- if (!Buffer.isBuffer(base)) {
- this.error('Input not Buffer');
- return;
- }
- this.base = base;
- this.offset = 0;
- this.length = base.length;
- }
- inherits(DecoderBuffer, Reporter);
- exports.DecoderBuffer = DecoderBuffer;
- DecoderBuffer.prototype.save = function save() {
- return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
- };
- DecoderBuffer.prototype.restore = function restore(save) {
- // Return skipped data
- var res = new DecoderBuffer(this.base);
- res.offset = save.offset;
- res.length = this.offset;
- this.offset = save.offset;
- Reporter.prototype.restore.call(this, save.reporter);
- return res;
- };
- DecoderBuffer.prototype.isEmpty = function isEmpty() {
- return this.offset === this.length;
- };
- DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
- if (this.offset + 1 <= this.length)
- return this.base.readUInt8(this.offset++, true);
- else
- return this.error(fail || 'DecoderBuffer overrun');
- }
- DecoderBuffer.prototype.skip = function skip(bytes, fail) {
- if (!(this.offset + bytes <= this.length))
- return this.error(fail || 'DecoderBuffer overrun');
- var res = new DecoderBuffer(this.base);
- // Share reporter state
- res._reporterState = this._reporterState;
- res.offset = this.offset;
- res.length = this.offset + bytes;
- this.offset += bytes;
- return res;
- }
- DecoderBuffer.prototype.raw = function raw(save) {
- return this.base.slice(save ? save.offset : this.offset, this.length);
- }
- function EncoderBuffer(value, reporter) {
- if (Array.isArray(value)) {
- this.length = 0;
- this.value = value.map(function(item) {
- if (!(item instanceof EncoderBuffer))
- item = new EncoderBuffer(item, reporter);
- this.length += item.length;
- return item;
- }, this);
- } else if (typeof value === 'number') {
- if (!(0 <= value && value <= 0xff))
- return reporter.error('non-byte EncoderBuffer value');
- this.value = value;
- this.length = 1;
- } else if (typeof value === 'string') {
- this.value = value;
- this.length = Buffer.byteLength(value);
- } else if (Buffer.isBuffer(value)) {
- this.value = value;
- this.length = value.length;
- } else {
- return reporter.error('Unsupported type: ' + typeof value);
- }
- }
- exports.EncoderBuffer = EncoderBuffer;
- EncoderBuffer.prototype.join = function join(out, offset) {
- if (!out)
- out = new Buffer(this.length);
- if (!offset)
- offset = 0;
- if (this.length === 0)
- return out;
- if (Array.isArray(this.value)) {
- this.value.forEach(function(item) {
- item.join(out, offset);
- offset += item.length;
- });
- } else {
- if (typeof this.value === 'number')
- out[offset] = this.value;
- else if (typeof this.value === 'string')
- out.write(this.value, offset);
- else if (Buffer.isBuffer(this.value))
- this.value.copy(out, offset);
- offset += this.length;
- }
- return out;
- };
- /***/ },
- /* 141 */
- /***/ function(module, exports, __webpack_require__) {
- var constants = exports;
- // Helper
- constants._reverse = function reverse(map) {
- var res = {};
- Object.keys(map).forEach(function(key) {
- // Convert key to integer if it is stringified
- if ((key | 0) == key)
- key = key | 0;
- var value = map[key];
- res[value] = key;
- });
- return res;
- };
- constants.der = __webpack_require__(238);
- /***/ },
- /* 142 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- var asn1 = __webpack_require__(77);
- var base = asn1.base;
- var bignum = asn1.bignum;
- // Import DER constants
- var der = asn1.constants.der;
- function DERDecoder(entity) {
- this.enc = 'der';
- this.name = entity.name;
- this.entity = entity;
- // Construct base tree
- this.tree = new DERNode();
- this.tree._init(entity.body);
- };
- module.exports = DERDecoder;
- DERDecoder.prototype.decode = function decode(data, options) {
- if (!(data instanceof base.DecoderBuffer))
- data = new base.DecoderBuffer(data, options);
- return this.tree._decode(data, options);
- };
- // Tree methods
- function DERNode(parent) {
- base.Node.call(this, 'der', parent);
- }
- inherits(DERNode, base.Node);
- DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
- if (buffer.isEmpty())
- return false;
- var state = buffer.save();
- var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
- if (buffer.isError(decodedTag))
- return decodedTag;
- buffer.restore(state);
- return decodedTag.tag === tag || decodedTag.tagStr === tag ||
- (decodedTag.tagStr + 'of') === tag || any;
- };
- DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
- var decodedTag = derDecodeTag(buffer,
- 'Failed to decode tag of "' + tag + '"');
- if (buffer.isError(decodedTag))
- return decodedTag;
- var len = derDecodeLen(buffer,
- decodedTag.primitive,
- 'Failed to get length of "' + tag + '"');
- // Failure
- if (buffer.isError(len))
- return len;
- if (!any &&
- decodedTag.tag !== tag &&
- decodedTag.tagStr !== tag &&
- decodedTag.tagStr + 'of' !== tag) {
- return buffer.error('Failed to match tag: "' + tag + '"');
- }
- if (decodedTag.primitive || len !== null)
- return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
- // Indefinite length... find END tag
- var state = buffer.save();
- var res = this._skipUntilEnd(
- buffer,
- 'Failed to skip indefinite length body: "' + this.tag + '"');
- if (buffer.isError(res))
- return res;
- len = buffer.offset - state.offset;
- buffer.restore(state);
- return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
- };
- DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
- while (true) {
- var tag = derDecodeTag(buffer, fail);
- if (buffer.isError(tag))
- return tag;
- var len = derDecodeLen(buffer, tag.primitive, fail);
- if (buffer.isError(len))
- return len;
- var res;
- if (tag.primitive || len !== null)
- res = buffer.skip(len)
- else
- res = this._skipUntilEnd(buffer, fail);
- // Failure
- if (buffer.isError(res))
- return res;
- if (tag.tagStr === 'end')
- break;
- }
- };
- DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder) {
- var result = [];
- while (!buffer.isEmpty()) {
- var possibleEnd = this._peekTag(buffer, 'end');
- if (buffer.isError(possibleEnd))
- return possibleEnd;
- var res = decoder.decode(buffer, 'der');
- if (buffer.isError(res) && possibleEnd)
- break;
- result.push(res);
- }
- return result;
- };
- DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
- if (tag === 'bitstr') {
- var unused = buffer.readUInt8();
- if (buffer.isError(unused))
- return unused;
- return { unused: unused, data: buffer.raw() };
- } else if (tag === 'bmpstr') {
- var raw = buffer.raw();
- if (raw.length % 2 === 1)
- return buffer.error('Decoding of string type: bmpstr length mismatch');
- var str = '';
- for (var i = 0; i < raw.length / 2; i++) {
- str += String.fromCharCode(raw.readUInt16BE(i * 2));
- }
- return str;
- } else if (tag === 'numstr') {
- var numstr = buffer.raw().toString('ascii');
- if (!this._isNumstr(numstr)) {
- return buffer.error('Decoding of string type: ' +
- 'numstr unsupported characters');
- }
- return numstr;
- } else if (tag === 'octstr') {
- return buffer.raw();
- } else if (tag === 'printstr') {
- var printstr = buffer.raw().toString('ascii');
- if (!this._isPrintstr(printstr)) {
- return buffer.error('Decoding of string type: ' +
- 'printstr unsupported characters');
- }
- return printstr;
- } else if (/str$/.test(tag)) {
- return buffer.raw().toString();
- } else {
- return buffer.error('Decoding of string type: ' + tag + ' unsupported');
- }
- };
- DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
- var result;
- var identifiers = [];
- var ident = 0;
- while (!buffer.isEmpty()) {
- var subident = buffer.readUInt8();
- ident <<= 7;
- ident |= subident & 0x7f;
- if ((subident & 0x80) === 0) {
- identifiers.push(ident);
- ident = 0;
- }
- }
- if (subident & 0x80)
- identifiers.push(ident);
- var first = (identifiers[0] / 40) | 0;
- var second = identifiers[0] % 40;
- if (relative)
- result = identifiers;
- else
- result = [first, second].concat(identifiers.slice(1));
- if (values) {
- var tmp = values[result.join(' ')];
- if (tmp === undefined)
- tmp = values[result.join('.')];
- if (tmp !== undefined)
- result = tmp;
- }
- return result;
- };
- DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
- var str = buffer.raw().toString();
- if (tag === 'gentime') {
- var year = str.slice(0, 4) | 0;
- var mon = str.slice(4, 6) | 0;
- var day = str.slice(6, 8) | 0;
- var hour = str.slice(8, 10) | 0;
- var min = str.slice(10, 12) | 0;
- var sec = str.slice(12, 14) | 0;
- } else if (tag === 'utctime') {
- var year = str.slice(0, 2) | 0;
- var mon = str.slice(2, 4) | 0;
- var day = str.slice(4, 6) | 0;
- var hour = str.slice(6, 8) | 0;
- var min = str.slice(8, 10) | 0;
- var sec = str.slice(10, 12) | 0;
- if (year < 70)
- year = 2000 + year;
- else
- year = 1900 + year;
- } else {
- return buffer.error('Decoding ' + tag + ' time is not supported yet');
- }
- return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
- };
- DERNode.prototype._decodeNull = function decodeNull(buffer) {
- return null;
- };
- DERNode.prototype._decodeBool = function decodeBool(buffer) {
- var res = buffer.readUInt8();
- if (buffer.isError(res))
- return res;
- else
- return res !== 0;
- };
- DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
- // Bigint, return as it is (assume big endian)
- var raw = buffer.raw();
- var res = new bignum(raw);
- if (values)
- res = values[res.toString(10)] || res;
- return res;
- };
- DERNode.prototype._use = function use(entity, obj) {
- if (typeof entity === 'function')
- entity = entity(obj);
- return entity._getDecoder('der').tree;
- };
- // Utility methods
- function derDecodeTag(buf, fail) {
- var tag = buf.readUInt8(fail);
- if (buf.isError(tag))
- return tag;
- var cls = der.tagClass[tag >> 6];
- var primitive = (tag & 0x20) === 0;
- // Multi-octet tag - load
- if ((tag & 0x1f) === 0x1f) {
- var oct = tag;
- tag = 0;
- while ((oct & 0x80) === 0x80) {
- oct = buf.readUInt8(fail);
- if (buf.isError(oct))
- return oct;
- tag <<= 7;
- tag |= oct & 0x7f;
- }
- } else {
- tag &= 0x1f;
- }
- var tagStr = der.tag[tag];
- return {
- cls: cls,
- primitive: primitive,
- tag: tag,
- tagStr: tagStr
- };
- }
- function derDecodeLen(buf, primitive, fail) {
- var len = buf.readUInt8(fail);
- if (buf.isError(len))
- return len;
- // Indefinite form
- if (!primitive && len === 0x80)
- return null;
- // Definite form
- if ((len & 0x80) === 0) {
- // Short form
- return len;
- }
- // Long form
- var num = len & 0x7f;
- if (num >= 4)
- return buf.error('length octect is too long');
- len = 0;
- for (var i = 0; i < num; i++) {
- len <<= 8;
- var j = buf.readUInt8(fail);
- if (buf.isError(j))
- return j;
- len |= j;
- }
- return len;
- }
- /***/ },
- /* 143 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- var Buffer = __webpack_require__(1).Buffer;
- var asn1 = __webpack_require__(77);
- var base = asn1.base;
- // Import DER constants
- var der = asn1.constants.der;
- function DEREncoder(entity) {
- this.enc = 'der';
- this.name = entity.name;
- this.entity = entity;
- // Construct base tree
- this.tree = new DERNode();
- this.tree._init(entity.body);
- };
- module.exports = DEREncoder;
- DEREncoder.prototype.encode = function encode(data, reporter) {
- return this.tree._encode(data, reporter).join();
- };
- // Tree methods
- function DERNode(parent) {
- base.Node.call(this, 'der', parent);
- }
- inherits(DERNode, base.Node);
- DERNode.prototype._encodeComposite = function encodeComposite(tag,
- primitive,
- cls,
- content) {
- var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
- // Short form
- if (content.length < 0x80) {
- var header = new Buffer(2);
- header[0] = encodedTag;
- header[1] = content.length;
- return this._createEncoderBuffer([ header, content ]);
- }
- // Long form
- // Count octets required to store length
- var lenOctets = 1;
- for (var i = content.length; i >= 0x100; i >>= 8)
- lenOctets++;
- var header = new Buffer(1 + 1 + lenOctets);
- header[0] = encodedTag;
- header[1] = 0x80 | lenOctets;
- for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
- header[i] = j & 0xff;
- return this._createEncoderBuffer([ header, content ]);
- };
- DERNode.prototype._encodeStr = function encodeStr(str, tag) {
- if (tag === 'bitstr') {
- return this._createEncoderBuffer([ str.unused | 0, str.data ]);
- } else if (tag === 'bmpstr') {
- var buf = new Buffer(str.length * 2);
- for (var i = 0; i < str.length; i++) {
- buf.writeUInt16BE(str.charCodeAt(i), i * 2);
- }
- return this._createEncoderBuffer(buf);
- } else if (tag === 'numstr') {
- if (!this._isNumstr(str)) {
- return this.reporter.error('Encoding of string type: numstr supports ' +
- 'only digits and space');
- }
- return this._createEncoderBuffer(str);
- } else if (tag === 'printstr') {
- if (!this._isPrintstr(str)) {
- return this.reporter.error('Encoding of string type: printstr supports ' +
- 'only latin upper and lower case letters, ' +
- 'digits, space, apostrophe, left and rigth ' +
- 'parenthesis, plus sign, comma, hyphen, ' +
- 'dot, slash, colon, equal sign, ' +
- 'question mark');
- }
- return this._createEncoderBuffer(str);
- } else if (/str$/.test(tag)) {
- return this._createEncoderBuffer(str);
- } else {
- return this.reporter.error('Encoding of string type: ' + tag +
- ' unsupported');
- }
- };
- DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
- if (typeof id === 'string') {
- if (!values)
- return this.reporter.error('string objid given, but no values map found');
- if (!values.hasOwnProperty(id))
- return this.reporter.error('objid not found in values map');
- id = values[id].split(/[\s\.]+/g);
- for (var i = 0; i < id.length; i++)
- id[i] |= 0;
- } else if (Array.isArray(id)) {
- id = id.slice();
- for (var i = 0; i < id.length; i++)
- id[i] |= 0;
- }
- if (!Array.isArray(id)) {
- return this.reporter.error('objid() should be either array or string, ' +
- 'got: ' + JSON.stringify(id));
- }
- if (!relative) {
- if (id[1] >= 40)
- return this.reporter.error('Second objid identifier OOB');
- id.splice(0, 2, id[0] * 40 + id[1]);
- }
- // Count number of octets
- var size = 0;
- for (var i = 0; i < id.length; i++) {
- var ident = id[i];
- for (size++; ident >= 0x80; ident >>= 7)
- size++;
- }
- var objid = new Buffer(size);
- var offset = objid.length - 1;
- for (var i = id.length - 1; i >= 0; i--) {
- var ident = id[i];
- objid[offset--] = ident & 0x7f;
- while ((ident >>= 7) > 0)
- objid[offset--] = 0x80 | (ident & 0x7f);
- }
- return this._createEncoderBuffer(objid);
- };
- function two(num) {
- if (num < 10)
- return '0' + num;
- else
- return num;
- }
- DERNode.prototype._encodeTime = function encodeTime(time, tag) {
- var str;
- var date = new Date(time);
- if (tag === 'gentime') {
- str = [
- two(date.getFullYear()),
- two(date.getUTCMonth() + 1),
- two(date.getUTCDate()),
- two(date.getUTCHours()),
- two(date.getUTCMinutes()),
- two(date.getUTCSeconds()),
- 'Z'
- ].join('');
- } else if (tag === 'utctime') {
- str = [
- two(date.getFullYear() % 100),
- two(date.getUTCMonth() + 1),
- two(date.getUTCDate()),
- two(date.getUTCHours()),
- two(date.getUTCMinutes()),
- two(date.getUTCSeconds()),
- 'Z'
- ].join('');
- } else {
- this.reporter.error('Encoding ' + tag + ' time is not supported yet');
- }
- return this._encodeStr(str, 'octstr');
- };
- DERNode.prototype._encodeNull = function encodeNull() {
- return this._createEncoderBuffer('');
- };
- DERNode.prototype._encodeInt = function encodeInt(num, values) {
- if (typeof num === 'string') {
- if (!values)
- return this.reporter.error('String int or enum given, but no values map');
- if (!values.hasOwnProperty(num)) {
- return this.reporter.error('Values map doesn\'t contain: ' +
- JSON.stringify(num));
- }
- num = values[num];
- }
- // Bignum, assume big endian
- if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
- var numArray = num.toArray();
- if (!num.sign && numArray[0] & 0x80) {
- numArray.unshift(0);
- }
- num = new Buffer(numArray);
- }
- if (Buffer.isBuffer(num)) {
- var size = num.length;
- if (num.length === 0)
- size++;
- var out = new Buffer(size);
- num.copy(out);
- if (num.length === 0)
- out[0] = 0
- return this._createEncoderBuffer(out);
- }
- if (num < 0x80)
- return this._createEncoderBuffer(num);
- if (num < 0x100)
- return this._createEncoderBuffer([0, num]);
- var size = 1;
- for (var i = num; i >= 0x100; i >>= 8)
- size++;
- var out = new Array(size);
- for (var i = out.length - 1; i >= 0; i--) {
- out[i] = num & 0xff;
- num >>= 8;
- }
- if(out[0] & 0x80) {
- out.unshift(0);
- }
- return this._createEncoderBuffer(new Buffer(out));
- };
- DERNode.prototype._encodeBool = function encodeBool(value) {
- return this._createEncoderBuffer(value ? 0xff : 0);
- };
- DERNode.prototype._use = function use(entity, obj) {
- if (typeof entity === 'function')
- entity = entity(obj);
- return entity._getEncoder('der').tree;
- };
- DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
- var state = this._baseState;
- var i;
- if (state['default'] === null)
- return false;
- var data = dataBuffer.join();
- if (state.defaultBuffer === undefined)
- state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
- if (data.length !== state.defaultBuffer.length)
- return false;
- for (i=0; i < data.length; i++)
- if (data[i] !== state.defaultBuffer[i])
- return false;
- return true;
- };
- // Utility methods
- function encodeTag(tag, primitive, cls, reporter) {
- var res;
- if (tag === 'seqof')
- tag = 'seq';
- else if (tag === 'setof')
- tag = 'set';
- if (der.tagByName.hasOwnProperty(tag))
- res = der.tagByName[tag];
- else if (typeof tag === 'number' && (tag | 0) === tag)
- res = tag;
- else
- return reporter.error('Unknown tag: ' + tag);
- if (res >= 0x1f)
- return reporter.error('Multi-octet tag encoding unsupported');
- if (!primitive)
- res |= 0x20;
- res |= (der.tagClassByName[cls || 'universal'] << 6);
- return res;
- }
- /***/ },
- /* 144 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {'use strict';
- // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
- // original notice:
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license MIT
- */
- function compare(a, b) {
- if (a === b) {
- return 0;
- }
- var x = a.length;
- var y = b.length;
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i];
- y = b[i];
- break;
- }
- }
- if (x < y) {
- return -1;
- }
- if (y < x) {
- return 1;
- }
- return 0;
- }
- function isBuffer(b) {
- if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
- return global.Buffer.isBuffer(b);
- }
- return !!(b != null && b._isBuffer);
- }
- // based on node assert, original notice:
- // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
- //
- // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
- //
- // Originally from narwhal.js (http://narwhaljs.org)
- // Copyright (c) 2009 Thomas Robinson <280north.com>
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the 'Software'), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- var util = __webpack_require__(44);
- var hasOwn = Object.prototype.hasOwnProperty;
- var pSlice = Array.prototype.slice;
- var functionsHaveNames = (function () {
- return function foo() {}.name === 'foo';
- }());
- function pToString (obj) {
- return Object.prototype.toString.call(obj);
- }
- function isView(arrbuf) {
- if (isBuffer(arrbuf)) {
- return false;
- }
- if (typeof global.ArrayBuffer !== 'function') {
- return false;
- }
- if (typeof ArrayBuffer.isView === 'function') {
- return ArrayBuffer.isView(arrbuf);
- }
- if (!arrbuf) {
- return false;
- }
- if (arrbuf instanceof DataView) {
- return true;
- }
- if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
- return true;
- }
- return false;
- }
- // 1. The assert module provides functions that throw
- // AssertionError's when particular conditions are not met. The
- // assert module must conform to the following interface.
- var assert = module.exports = ok;
- // 2. The AssertionError is defined in assert.
- // new assert.AssertionError({ message: message,
- // actual: actual,
- // expected: expected })
- var regex = /\s*function\s+([^\(\s]*)\s*/;
- // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
- function getName(func) {
- if (!util.isFunction(func)) {
- return;
- }
- if (functionsHaveNames) {
- return func.name;
- }
- var str = func.toString();
- var match = str.match(regex);
- return match && match[1];
- }
- assert.AssertionError = function AssertionError(options) {
- this.name = 'AssertionError';
- this.actual = options.actual;
- this.expected = options.expected;
- this.operator = options.operator;
- if (options.message) {
- this.message = options.message;
- this.generatedMessage = false;
- } else {
- this.message = getMessage(this);
- this.generatedMessage = true;
- }
- var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- } else {
- // non v8 browsers so we can have a stacktrace
- var err = new Error();
- if (err.stack) {
- var out = err.stack;
- // try to strip useless frames
- var fn_name = getName(stackStartFunction);
- var idx = out.indexOf('\n' + fn_name);
- if (idx >= 0) {
- // once we have located the function frame
- // we need to strip out everything before it (and its line)
- var next_line = out.indexOf('\n', idx + 1);
- out = out.substring(next_line + 1);
- }
- this.stack = out;
- }
- }
- };
- // assert.AssertionError instanceof Error
- util.inherits(assert.AssertionError, Error);
- function truncate(s, n) {
- if (typeof s === 'string') {
- return s.length < n ? s : s.slice(0, n);
- } else {
- return s;
- }
- }
- function inspect(something) {
- if (functionsHaveNames || !util.isFunction(something)) {
- return util.inspect(something);
- }
- var rawname = getName(something);
- var name = rawname ? ': ' + rawname : '';
- return '[Function' + name + ']';
- }
- function getMessage(self) {
- return truncate(inspect(self.actual), 128) + ' ' +
- self.operator + ' ' +
- truncate(inspect(self.expected), 128);
- }
- // At present only the three keys mentioned above are used and
- // understood by the spec. Implementations or sub modules can pass
- // other keys to the AssertionError's constructor - they will be
- // ignored.
- // 3. All of the following functions must throw an AssertionError
- // when a corresponding condition is not met, with a message that
- // may be undefined if not provided. All assertion methods provide
- // both the actual and expected values to the assertion error for
- // display purposes.
- function fail(actual, expected, message, operator, stackStartFunction) {
- throw new assert.AssertionError({
- message: message,
- actual: actual,
- expected: expected,
- operator: operator,
- stackStartFunction: stackStartFunction
- });
- }
- // EXTENSION! allows for well behaved errors defined elsewhere.
- assert.fail = fail;
- // 4. Pure assertion tests whether a value is truthy, as determined
- // by !!guard.
- // assert.ok(guard, message_opt);
- // This statement is equivalent to assert.equal(true, !!guard,
- // message_opt);. To test strictly for the value true, use
- // assert.strictEqual(true, guard, message_opt);.
- function ok(value, message) {
- if (!value) fail(value, true, message, '==', assert.ok);
- }
- assert.ok = ok;
- // 5. The equality assertion tests shallow, coercive equality with
- // ==.
- // assert.equal(actual, expected, message_opt);
- assert.equal = function equal(actual, expected, message) {
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
- };
- // 6. The non-equality assertion tests for whether two objects are not equal
- // with != assert.notEqual(actual, expected, message_opt);
- assert.notEqual = function notEqual(actual, expected, message) {
- if (actual == expected) {
- fail(actual, expected, message, '!=', assert.notEqual);
- }
- };
- // 7. The equivalence assertion tests a deep equality relation.
- // assert.deepEqual(actual, expected, message_opt);
- assert.deepEqual = function deepEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
- }
- };
- assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
- }
- };
- function _deepEqual(actual, expected, strict, memos) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
- } else if (isBuffer(actual) && isBuffer(expected)) {
- return compare(actual, expected) === 0;
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (util.isDate(actual) && util.isDate(expected)) {
- return actual.getTime() === expected.getTime();
- // 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source and
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
- return actual.source === expected.source &&
- actual.global === expected.global &&
- actual.multiline === expected.multiline &&
- actual.lastIndex === expected.lastIndex &&
- actual.ignoreCase === expected.ignoreCase;
- // 7.4. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if ((actual === null || typeof actual !== 'object') &&
- (expected === null || typeof expected !== 'object')) {
- return strict ? actual === expected : actual == expected;
- // If both values are instances of typed arrays, wrap their underlying
- // ArrayBuffers in a Buffer each to increase performance
- // This optimization requires the arrays to have the same type as checked by
- // Object.prototype.toString (aka pToString). Never perform binary
- // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
- // bit patterns are not identical.
- } else if (isView(actual) && isView(expected) &&
- pToString(actual) === pToString(expected) &&
- !(actual instanceof Float32Array ||
- actual instanceof Float64Array)) {
- return compare(new Uint8Array(actual.buffer),
- new Uint8Array(expected.buffer)) === 0;
- // 7.5 For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else if (isBuffer(actual) !== isBuffer(expected)) {
- return false;
- } else {
- memos = memos || {actual: [], expected: []};
- var actualIndex = memos.actual.indexOf(actual);
- if (actualIndex !== -1) {
- if (actualIndex === memos.expected.indexOf(expected)) {
- return true;
- }
- }
- memos.actual.push(actual);
- memos.expected.push(expected);
- return objEquiv(actual, expected, strict, memos);
- }
- }
- function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
- }
- function objEquiv(a, b, strict, actualVisitedObjects) {
- if (a === null || a === undefined || b === null || b === undefined)
- return false;
- // if one is a primitive, the other must be same
- if (util.isPrimitive(a) || util.isPrimitive(b))
- return a === b;
- if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
- return false;
- var aIsArgs = isArguments(a);
- var bIsArgs = isArguments(b);
- if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
- return false;
- if (aIsArgs) {
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b, strict);
- }
- var ka = objectKeys(a);
- var kb = objectKeys(b);
- var key, i;
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length !== kb.length)
- return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] !== kb[i])
- return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
- return false;
- }
- return true;
- }
- // 8. The non-equivalence assertion tests for any deep inequality.
- // assert.notDeepEqual(actual, expected, message_opt);
- assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
- }
- };
- assert.notDeepStrictEqual = notDeepStrictEqual;
- function notDeepStrictEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
- }
- }
- // 9. The strict equality assertion tests strict equality, as determined by ===.
- // assert.strictEqual(actual, expected, message_opt);
- assert.strictEqual = function strictEqual(actual, expected, message) {
- if (actual !== expected) {
- fail(actual, expected, message, '===', assert.strictEqual);
- }
- };
- // 10. The strict non-equality assertion tests for strict inequality, as
- // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
- if (actual === expected) {
- fail(actual, expected, message, '!==', assert.notStrictEqual);
- }
- };
- function expectedException(actual, expected) {
- if (!actual || !expected) {
- return false;
- }
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
- return expected.test(actual);
- }
- try {
- if (actual instanceof expected) {
- return true;
- }
- } catch (e) {
- // Ignore. The instanceof check doesn't work for arrow functions.
- }
- if (Error.isPrototypeOf(expected)) {
- return false;
- }
- return expected.call({}, actual) === true;
- }
- function _tryBlock(block) {
- var error;
- try {
- block();
- } catch (e) {
- error = e;
- }
- return error;
- }
- function _throws(shouldThrow, block, expected, message) {
- var actual;
- if (typeof block !== 'function') {
- throw new TypeError('"block" argument must be a function');
- }
- if (typeof expected === 'string') {
- message = expected;
- expected = null;
- }
- actual = _tryBlock(block);
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
- (message ? ' ' + message : '.');
- if (shouldThrow && !actual) {
- fail(actual, expected, 'Missing expected exception' + message);
- }
- var userProvidedMessage = typeof message === 'string';
- var isUnwantedException = !shouldThrow && util.isError(actual);
- var isUnexpectedException = !shouldThrow && actual && !expected;
- if ((isUnwantedException &&
- userProvidedMessage &&
- expectedException(actual, expected)) ||
- isUnexpectedException) {
- fail(actual, expected, 'Got unwanted exception' + message);
- }
- if ((shouldThrow && actual && expected &&
- !expectedException(actual, expected)) || (!shouldThrow && actual)) {
- throw actual;
- }
- }
- // 11. Expected to throw an error:
- // assert.throws(block, Error_opt, message_opt);
- assert.throws = function(block, /*optional*/error, /*optional*/message) {
- _throws(true, block, error, message);
- };
- // EXTENSION! This is annoying to write outside this module.
- assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
- _throws(false, block, error, message);
- };
- assert.ifError = function(err) { if (err) throw err; };
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- if (hasOwn.call(obj, key)) keys.push(key);
- }
- return keys;
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 145 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global, setImmediate, process) {(function (global, factory) {
- true ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (factory((global.async = global.async || {})));
- }(this, function (exports) { 'use strict';
- /**
- * A faster alternative to `Function#apply`, this function invokes `func`
- * with the `this` binding of `thisArg` and the arguments of `args`.
- *
- * @private
- * @param {Function} func The function to invoke.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} args The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply(func, thisArg, args) {
- var length = args.length;
- switch (length) {
- case 0: return func.call(thisArg);
- case 1: return func.call(thisArg, args[0]);
- case 2: return func.call(thisArg, args[0], args[1]);
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
- }
- return func.apply(thisArg, args);
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- var funcTag = '[object Function]';
- var genTag = '[object GeneratorFunction]';
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- /** `Object#toString` result references. */
- var symbolTag = '[object Symbol]';
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$1 = objectProto$1.toString;
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString$1.call(value) == symbolTag);
- }
- /** Used as references for various `Number` constants. */
- var NAN = 0 / 0;
- /** Used to match leading and trailing whitespace. */
- var reTrim = /^\s+|\s+$/g;
- /** Used to detect bad signed hexadecimal string values. */
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
- /** Used to detect binary string values. */
- var reIsBinary = /^0b[01]+$/i;
- /** Used to detect octal string values. */
- var reIsOctal = /^0o[0-7]+$/i;
- /** Built-in method references without a dependency on `root`. */
- var freeParseInt = parseInt;
- /**
- * Converts `value` to a number.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {number} Returns the number.
- * @example
- *
- * _.toNumber(3.2);
- * // => 3.2
- *
- * _.toNumber(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toNumber(Infinity);
- * // => Infinity
- *
- * _.toNumber('3.2');
- * // => 3.2
- */
- function toNumber(value) {
- if (typeof value == 'number') {
- return value;
- }
- if (isSymbol(value)) {
- return NAN;
- }
- if (isObject(value)) {
- var other = isFunction(value.valueOf) ? value.valueOf() : value;
- value = isObject(other) ? (other + '') : other;
- }
- if (typeof value != 'string') {
- return value === 0 ? value : +value;
- }
- value = value.replace(reTrim, '');
- var isBinary = reIsBinary.test(value);
- return (isBinary || reIsOctal.test(value))
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
- : (reIsBadHex.test(value) ? NAN : +value);
- }
- var INFINITY = 1 / 0;
- var MAX_INTEGER = 1.7976931348623157e+308;
- /**
- * Converts `value` to a finite number.
- *
- * @static
- * @memberOf _
- * @since 4.12.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted number.
- * @example
- *
- * _.toFinite(3.2);
- * // => 3.2
- *
- * _.toFinite(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toFinite(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toFinite('3.2');
- * // => 3.2
- */
- function toFinite(value) {
- if (!value) {
- return value === 0 ? value : 0;
- }
- value = toNumber(value);
- if (value === INFINITY || value === -INFINITY) {
- var sign = (value < 0 ? -1 : 1);
- return sign * MAX_INTEGER;
- }
- return value === value ? value : 0;
- }
- /**
- * Converts `value` to an integer.
- *
- * **Note:** This method is loosely based on
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted integer.
- * @example
- *
- * _.toInteger(3.2);
- * // => 3
- *
- * _.toInteger(Number.MIN_VALUE);
- * // => 0
- *
- * _.toInteger(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toInteger('3.2');
- * // => 3
- */
- function toInteger(value) {
- var result = toFinite(value),
- remainder = result % 1;
- return result === result ? (remainder ? result - remainder : result) : 0;
- }
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a function that invokes `func` with the `this` binding of the
- * created function and arguments from `start` and beyond provided as
- * an array.
- *
- * **Note:** This method is based on the
- * [rest parameter](https://mdn.io/rest_parameters).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Function
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var say = _.rest(function(what, names) {
- * return what + ' ' + _.initial(names).join(', ') +
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
- * });
- *
- * say('hello', 'fred', 'barney', 'pebbles');
- * // => 'hello fred, barney, & pebbles'
- */
- function rest(func, start) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
- while (++index < length) {
- array[index] = args[start + index];
- }
- switch (start) {
- case 0: return func.call(this, array);
- case 1: return func.call(this, args[0], array);
- case 2: return func.call(this, args[0], args[1], array);
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = array;
- return apply(func, this, otherArgs);
- };
- }
- function initialParams (fn) {
- return rest(function (args /*..., callback*/) {
- var callback = args.pop();
- fn.call(this, args, callback);
- });
- }
- function applyEach$1(eachfn) {
- return rest(function (fns, args) {
- var go = initialParams(function (args, callback) {
- var that = this;
- return eachfn(fns, function (fn, cb) {
- fn.apply(that, args.concat([cb]));
- }, callback);
- });
- if (args.length) {
- return go.apply(this, args);
- } else {
- return go;
- }
- });
- }
- /**
- * A method that returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
- function noop() {
- // No operation performed.
- }
- function once(fn) {
- return function () {
- if (fn === null) return;
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
- }
- var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
- function getIterator (coll) {
- return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
- }
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetPrototype = Object.getPrototypeOf;
- /**
- * Gets the `[[Prototype]]` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
- */
- function getPrototype(value) {
- return nativeGetPrototype(Object(value));
- }
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto$2.hasOwnProperty;
- /**
- * The base implementation of `_.has` without support for deep paths.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHas(object, key) {
- // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
- // that are composed entirely of index properties, return `false` for
- // `hasOwnProperty` checks of them.
- return object != null &&
- (hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototype(object) === null));
- }
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeKeys = Object.keys;
- /**
- * The base implementation of `_.keys` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- return nativeKeys(Object(object));
- }
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object,
- * else `false`.
- * @example
- *
- * _.isArrayLikeObject([1, 2, 3]);
- * // => true
- *
- * _.isArrayLikeObject(document.body.children);
- * // => true
- *
- * _.isArrayLikeObject('abc');
- * // => false
- *
- * _.isArrayLikeObject(_.noop);
- * // => false
- */
- function isArrayLikeObject(value) {
- return isObjectLike(value) && isArrayLike(value);
- }
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]';
- /** Used for built-in method references. */
- var objectProto$3 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$3.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$2 = objectProto$3.toString;
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
- return isArrayLikeObject(value) && hasOwnProperty$1.call(value, 'callee') &&
- (!propertyIsEnumerable.call(value, 'callee') || objectToString$2.call(value) == argsTag);
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @type {Function}
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- /** `Object#toString` result references. */
- var stringTag = '[object String]';
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$3 = objectProto$4.toString;
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString$3.call(value) == stringTag);
- }
- /**
- * Creates an array of index keys for `object` values of arrays,
- * `arguments` objects, and strings, otherwise `null` is returned.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array|null} Returns index keys, else `null`.
- */
- function indexKeys(object) {
- var length = object ? object.length : undefined;
- if (isLength(length) &&
- (isArray(object) || isString(object) || isArguments(object))) {
- return baseTimes(length, String);
- }
- return null;
- }
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
- return !!length &&
- (typeof value == 'number' || reIsUint.test(value)) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
- return value === proto;
- }
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- var isProto = isPrototype(object);
- if (!(isProto || isArrayLike(object))) {
- return baseKeys(object);
- }
- var indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
- for (var key in object) {
- if (baseHas(object, key) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(isProto && key == 'constructor')) {
- result.push(key);
- }
- }
- return result;
- }
- function iterator(coll) {
- var i = -1;
- var len;
- if (isArrayLike(coll)) {
- len = coll.length;
- return function next() {
- i++;
- return i < len ? { value: coll[i], key: i } : null;
- };
- }
- var iterate = getIterator(coll);
- if (iterate) {
- return function next() {
- var item = iterate.next();
- if (item.done) return null;
- i++;
- return { value: item.value, key: i };
- };
- }
- var okeys = keys(coll);
- len = okeys.length;
- return function next() {
- i++;
- var key = okeys[i];
- return i < len ? { value: coll[key], key: key } : null;
- };
- }
- function onlyOnce(fn) {
- return function () {
- if (fn === null) throw new Error("Callback was already called.");
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
- function _eachOfLimit(limit) {
- return function (obj, iteratee, callback) {
- callback = once(callback || noop);
- obj = obj || [];
- var nextElem = iterator(obj);
- if (limit <= 0) {
- return callback(null);
- }
- var done = false;
- var running = 0;
- var errored = false;
- (function replenish() {
- if (done && running <= 0) {
- return callback(null);
- }
- while (running < limit && !errored) {
- var elem = nextElem();
- if (elem === null) {
- done = true;
- if (running <= 0) {
- callback(null);
- }
- return;
- }
- running += 1;
- iteratee(elem.value, elem.key, onlyOnce(function (err) {
- running -= 1;
- if (err) {
- callback(err);
- errored = true;
- } else {
- replenish();
- }
- }));
- }
- })();
- };
- }
- function doParallelLimit(fn) {
- return function (obj, limit, iteratee, callback) {
- return fn(_eachOfLimit(limit), obj, iteratee, callback);
- };
- }
- function _asyncMap(eachfn, arr, iteratee, callback) {
- callback = once(callback || noop);
- arr = arr || [];
- var results = [];
- var counter = 0;
- eachfn(arr, function (value, _, callback) {
- var index = counter++;
- iteratee(value, function (err, v) {
- results[index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
- /**
- * The same as `map` but runs a maximum of `limit` async operations at a time.
- *
- * @name mapLimit
- * @static
- * @memberOf async
- * @see async.map
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a transformed
- * item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapLimit = doParallelLimit(_asyncMap);
- function doLimit(fn, limit) {
- return function (iterable, iteratee, callback) {
- return fn(iterable, limit, iteratee, callback);
- };
- }
- /**
- * Produces a new collection of values by mapping each value in `coll` through
- * the `iteratee` function. The `iteratee` is called with an item from `coll`
- * and a callback for when it has finished processing. Each of these callback
- * takes 2 arguments: an `error`, and the transformed item from `coll`. If
- * `iteratee` passes an error to its callback, the main `callback` (for the
- * `map` function) is immediately called with the error.
- *
- * Note, that since this function applies the `iteratee` to each item in
- * parallel, there is no guarantee that the `iteratee` functions will complete
- * in order. However, the results array will be in the same order as the
- * original `coll`.
- *
- * If `map` is passed an Object, the results will be an Array. The results
- * will roughly be in the order of the original Objects' keys (but this can
- * vary across JavaScript engines)
- *
- * @name map
- * @static
- * @memberOf async
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an Array of the
- * transformed items from the `coll`. Invoked with (err, results).
- * @example
- *
- * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
- * // results is now an array of stats for each file
- * });
- */
- var map = doLimit(mapLimit, Infinity);
- /**
- * Applies the provided arguments to each function in the array, calling
- * `callback` after all functions have completed. If you only provide the first
- * argument, then it will return a function which lets you pass in the
- * arguments as if it were a single function call.
- *
- * @name applyEach
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array|Object} fns - A collection of asynchronous functions to all
- * call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument is provided, it will return
- * a function which lets you pass in the arguments as if it were a single
- * function call.
- * @example
- *
- * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
- *
- * // partial application example:
- * async.each(
- * buckets,
- * async.applyEach([enableSearch, updateSchema]),
- * callback
- * );
- */
- var applyEach = applyEach$1(map);
- /**
- * The same as `map` but runs only a single async operation at a time.
- *
- * @name mapSeries
- * @static
- * @memberOf async
- * @see async.map
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapSeries = doLimit(mapLimit, 1);
- /**
- * The same as `applyEach` but runs only a single async operation at a time.
- *
- * @name applyEachSeries
- * @static
- * @memberOf async
- * @see async.applyEach
- * @category Control Flow
- * @param {Array|Object} fns - A collection of asynchronous functions to all
- * call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument is provided, it will return
- * a function which lets you pass in the arguments as if it were a single
- * function call.
- */
- var applyEachSeries = applyEach$1(mapSeries);
- /**
- * Creates a continuation function with some arguments already applied.
- *
- * Useful as a shorthand when combined with other control flow functions. Any
- * arguments passed to the returned function are added to the arguments
- * originally passed to apply.
- *
- * @name apply
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to. Invokes with (arguments...).
- * @param {...*} arguments... - Any number of arguments to automatically apply
- * when the continuation is called.
- * @example
- *
- * // using apply
- * async.parallel([
- * async.apply(fs.writeFile, 'testfile1', 'test1'),
- * async.apply(fs.writeFile, 'testfile2', 'test2')
- * ]);
- *
- *
- * // the same process without using apply
- * async.parallel([
- * function(callback) {
- * fs.writeFile('testfile1', 'test1', callback);
- * },
- * function(callback) {
- * fs.writeFile('testfile2', 'test2', callback);
- * }
- * ]);
- *
- * // It's possible to pass any number of additional arguments when calling the
- * // continuation:
- *
- * node> var fn = async.apply(sys.puts, 'one');
- * node> fn('two', 'three');
- * one
- * two
- * three
- */
- var apply$1 = rest(function (fn, args) {
- return rest(function (callArgs) {
- return fn.apply(null, args.concat(callArgs));
- });
- });
- /**
- * Take a sync function and make it async, passing its return value to a
- * callback. This is useful for plugging sync functions into a waterfall,
- * series, or other async functions. Any arguments passed to the generated
- * function will be passed to the wrapped function (except for the final
- * callback argument). Errors thrown will be passed to the callback.
- *
- * If the function passed to `asyncify` returns a Promise, that promises's
- * resolved/rejected state will be used to call the callback, rather than simply
- * the synchronous return value.
- *
- * This also means you can asyncify ES2016 `async` functions.
- *
- * @name asyncify
- * @static
- * @memberOf async
- * @alias wrapSync
- * @category Util
- * @param {Function} func - The synchronous function to convert to an
- * asynchronous function.
- * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
- * (callback).
- * @example
- *
- * // passing a regular synchronous function
- * async.waterfall([
- * async.apply(fs.readFile, filename, "utf8"),
- * async.asyncify(JSON.parse),
- * function (data, next) {
- * // data is the result of parsing the text.
- * // If there was a parsing error, it would have been caught.
- * }
- * ], callback);
- *
- * // passing a function returning a promise
- * async.waterfall([
- * async.apply(fs.readFile, filename, "utf8"),
- * async.asyncify(function (contents) {
- * return db.model.create(contents);
- * }),
- * function (model, next) {
- * // `model` is the instantiated model object.
- * // If there was an error, this function would be skipped.
- * }
- * ], callback);
- *
- * // es6 example
- * var q = async.queue(async.asyncify(async function(file) {
- * var intermediateStep = await processFile(file);
- * return await somePromise(intermediateStep)
- * }));
- *
- * q.push(files);
- */
- function asyncify(func) {
- return initialParams(function (args, callback) {
- var result;
- try {
- result = func.apply(this, args);
- } catch (e) {
- return callback(e);
- }
- // if result is Promise object
- if (isObject(result) && typeof result.then === 'function') {
- result.then(function (value) {
- callback(null, value);
- })['catch'](function (err) {
- callback(err.message ? err : new Error(err));
- });
- } else {
- callback(null, result);
- }
- });
- }
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array ? array.length : 0;
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
- /**
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return object && baseFor(object, iteratee, keys);
- }
- /**
- * Removes all key-value entries from the list cache.
- *
- * @private
- * @name clear
- * @memberOf ListCache
- */
- function listCacheClear() {
- this.__data__ = [];
- }
- /**
- * Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * comparison between two values to determine if they are equivalent.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
- *
- * _.eq(object, object);
- * // => true
- *
- * _.eq(object, other);
- * // => false
- *
- * _.eq('a', 'a');
- * // => true
- *
- * _.eq('a', Object('a'));
- * // => false
- *
- * _.eq(NaN, NaN);
- * // => true
- */
- function eq(value, other) {
- return value === other || (value !== value && other !== other);
- }
- /**
- * Gets the index at which the `key` is found in `array` of key-value pairs.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} key The key to search for.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function assocIndexOf(array, key) {
- var length = array.length;
- while (length--) {
- if (eq(array[length][0], key)) {
- return length;
- }
- }
- return -1;
- }
- /** Used for built-in method references. */
- var arrayProto = Array.prototype;
- /** Built-in value references. */
- var splice = arrayProto.splice;
- /**
- * Removes `key` and its value from the list cache.
- *
- * @private
- * @name delete
- * @memberOf ListCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function listCacheDelete(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- return false;
- }
- var lastIndex = data.length - 1;
- if (index == lastIndex) {
- data.pop();
- } else {
- splice.call(data, index, 1);
- }
- return true;
- }
- /**
- * Gets the list cache value for `key`.
- *
- * @private
- * @name get
- * @memberOf ListCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function listCacheGet(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- return index < 0 ? undefined : data[index][1];
- }
- /**
- * Checks if a list cache value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf ListCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function listCacheHas(key) {
- return assocIndexOf(this.__data__, key) > -1;
- }
- /**
- * Sets the list cache `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf ListCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the list cache instance.
- */
- function listCacheSet(key, value) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- data.push([key, value]);
- } else {
- data[index][1] = value;
- }
- return this;
- }
- /**
- * Creates an list cache object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function ListCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `ListCache`.
- ListCache.prototype.clear = listCacheClear;
- ListCache.prototype['delete'] = listCacheDelete;
- ListCache.prototype.get = listCacheGet;
- ListCache.prototype.has = listCacheHas;
- ListCache.prototype.set = listCacheSet;
- /**
- * Removes all key-value entries from the stack.
- *
- * @private
- * @name clear
- * @memberOf Stack
- */
- function stackClear() {
- this.__data__ = new ListCache;
- }
- /**
- * Removes `key` and its value from the stack.
- *
- * @private
- * @name delete
- * @memberOf Stack
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function stackDelete(key) {
- return this.__data__['delete'](key);
- }
- /**
- * Gets the stack value for `key`.
- *
- * @private
- * @name get
- * @memberOf Stack
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function stackGet(key) {
- return this.__data__.get(key);
- }
- /**
- * Checks if a stack value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Stack
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function stackHas(key) {
- return this.__data__.has(key);
- }
- /**
- * Checks if `value` is a host object in IE < 9.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
- */
- function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
- }
- return result;
- }
- /**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(typeof global == 'object' && global);
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(typeof self == 'object' && self);
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(typeof this == 'object' && this);
- /** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
- /** Used to detect overreaching core-js shims. */
- var coreJsData = root['__core-js_shared__'];
- /** Used to detect methods masquerading as native. */
- var maskSrcKey = (function() {
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
- return uid ? ('Symbol(src)_1.' + uid) : '';
- }());
- /**
- * Checks if `func` has its source masked.
- *
- * @private
- * @param {Function} func The function to check.
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
- */
- function isMasked(func) {
- return !!maskSrcKey && (maskSrcKey in func);
- }
- /** Used to resolve the decompiled source of functions. */
- var funcToString$1 = Function.prototype.toString;
- /**
- * Converts `func` to its source code.
- *
- * @private
- * @param {Function} func The function to process.
- * @returns {string} Returns the source code.
- */
- function toSource(func) {
- if (func != null) {
- try {
- return funcToString$1.call(func);
- } catch (e) {}
- try {
- return (func + '');
- } catch (e) {}
- }
- return '';
- }
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
- /** Used to detect host constructors (Safari). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
- /** Used for built-in method references. */
- var objectProto$6 = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString = Function.prototype.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$6.hasOwnProperty;
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /**
- * The base implementation of `_.isNative` without bad shim checks.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function,
- * else `false`.
- */
- function baseIsNative(value) {
- if (!isObject(value) || isMasked(value)) {
- return false;
- }
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
- return pattern.test(toSource(value));
- }
- /**
- * Gets the value at `key` of `object`.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {string} key The key of the property to get.
- * @returns {*} Returns the property value.
- */
- function getValue(object, key) {
- return object == null ? undefined : object[key];
- }
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = getValue(object, key);
- return baseIsNative(value) ? value : undefined;
- }
- /* Built-in method references that are verified to be native. */
- var nativeCreate = getNative(Object, 'create');
- /**
- * Removes all key-value entries from the hash.
- *
- * @private
- * @name clear
- * @memberOf Hash
- */
- function hashClear() {
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
- }
- /**
- * Removes `key` and its value from the hash.
- *
- * @private
- * @name delete
- * @memberOf Hash
- * @param {Object} hash The hash to modify.
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function hashDelete(key) {
- return this.has(key) && delete this.__data__[key];
- }
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
- /** Used for built-in method references. */
- var objectProto$7 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$3 = objectProto$7.hasOwnProperty;
- /**
- * Gets the hash value for `key`.
- *
- * @private
- * @name get
- * @memberOf Hash
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function hashGet(key) {
- var data = this.__data__;
- if (nativeCreate) {
- var result = data[key];
- return result === HASH_UNDEFINED ? undefined : result;
- }
- return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
- }
- /** Used for built-in method references. */
- var objectProto$8 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$4 = objectProto$8.hasOwnProperty;
- /**
- * Checks if a hash value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Hash
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function hashHas(key) {
- var data = this.__data__;
- return nativeCreate ? data[key] !== undefined : hasOwnProperty$4.call(data, key);
- }
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
- /**
- * Sets the hash `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Hash
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the hash instance.
- */
- function hashSet(key, value) {
- var data = this.__data__;
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
- return this;
- }
- /**
- * Creates a hash object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Hash(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `Hash`.
- Hash.prototype.clear = hashClear;
- Hash.prototype['delete'] = hashDelete;
- Hash.prototype.get = hashGet;
- Hash.prototype.has = hashHas;
- Hash.prototype.set = hashSet;
- /* Built-in method references that are verified to be native. */
- var Map = getNative(root, 'Map');
- /**
- * Removes all key-value entries from the map.
- *
- * @private
- * @name clear
- * @memberOf MapCache
- */
- function mapCacheClear() {
- this.__data__ = {
- 'hash': new Hash,
- 'map': new (Map || ListCache),
- 'string': new Hash
- };
- }
- /**
- * Checks if `value` is suitable for use as unique object key.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
- */
- function isKeyable(value) {
- var type = typeof value;
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
- ? (value !== '__proto__')
- : (value === null);
- }
- /**
- * Gets the data for `map`.
- *
- * @private
- * @param {Object} map The map to query.
- * @param {string} key The reference key.
- * @returns {*} Returns the map data.
- */
- function getMapData(map, key) {
- var data = map.__data__;
- return isKeyable(key)
- ? data[typeof key == 'string' ? 'string' : 'hash']
- : data.map;
- }
- /**
- * Removes `key` and its value from the map.
- *
- * @private
- * @name delete
- * @memberOf MapCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function mapCacheDelete(key) {
- return getMapData(this, key)['delete'](key);
- }
- /**
- * Gets the map value for `key`.
- *
- * @private
- * @name get
- * @memberOf MapCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function mapCacheGet(key) {
- return getMapData(this, key).get(key);
- }
- /**
- * Checks if a map value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf MapCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function mapCacheHas(key) {
- return getMapData(this, key).has(key);
- }
- /**
- * Sets the map `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf MapCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the map cache instance.
- */
- function mapCacheSet(key, value) {
- getMapData(this, key).set(key, value);
- return this;
- }
- /**
- * Creates a map cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function MapCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `MapCache`.
- MapCache.prototype.clear = mapCacheClear;
- MapCache.prototype['delete'] = mapCacheDelete;
- MapCache.prototype.get = mapCacheGet;
- MapCache.prototype.has = mapCacheHas;
- MapCache.prototype.set = mapCacheSet;
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
- /**
- * Sets the stack `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Stack
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the stack cache instance.
- */
- function stackSet(key, value) {
- var cache = this.__data__;
- if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
- cache = this.__data__ = new MapCache(cache.__data__);
- }
- cache.set(key, value);
- return this;
- }
- /**
- * Creates a stack cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Stack(entries) {
- this.__data__ = new ListCache(entries);
- }
- // Add methods to `Stack`.
- Stack.prototype.clear = stackClear;
- Stack.prototype['delete'] = stackDelete;
- Stack.prototype.get = stackGet;
- Stack.prototype.has = stackHas;
- Stack.prototype.set = stackSet;
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
- /**
- * Adds `value` to the array cache.
- *
- * @private
- * @name add
- * @memberOf SetCache
- * @alias push
- * @param {*} value The value to cache.
- * @returns {Object} Returns the cache instance.
- */
- function setCacheAdd(value) {
- this.__data__.set(value, HASH_UNDEFINED$2);
- return this;
- }
- /**
- * Checks if `value` is in the array cache.
- *
- * @private
- * @name has
- * @memberOf SetCache
- * @param {*} value The value to search for.
- * @returns {number} Returns `true` if `value` is found, else `false`.
- */
- function setCacheHas(value) {
- return this.__data__.has(value);
- }
- /**
- *
- * Creates an array cache object to store unique values.
- *
- * @private
- * @constructor
- * @param {Array} [values] The values to cache.
- */
- function SetCache(values) {
- var index = -1,
- length = values ? values.length : 0;
- this.__data__ = new MapCache;
- while (++index < length) {
- this.add(values[index]);
- }
- }
- // Add methods to `SetCache`.
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
- SetCache.prototype.has = setCacheHas;
- /**
- * A specialized version of `_.some` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function arraySome(array, predicate) {
- var index = -1,
- length = array ? array.length : 0;
- while (++index < length) {
- if (predicate(array[index], index, array)) {
- return true;
- }
- }
- return false;
- }
- var UNORDERED_COMPARE_FLAG$1 = 1;
- var PARTIAL_COMPARE_FLAG$2 = 2;
- /**
- * A specialized version of `baseIsEqualDeep` for arrays with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Array} array The array to compare.
- * @param {Array} other The other array to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `array` and `other` objects.
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
- */
- function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG$2,
- arrLength = array.length,
- othLength = other.length;
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
- return false;
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(array);
- if (stacked) {
- return stacked == other;
- }
- var index = -1,
- result = true,
- seen = (bitmask & UNORDERED_COMPARE_FLAG$1) ? new SetCache : undefined;
- stack.set(array, other);
- // Ignore non-index properties.
- while (++index < arrLength) {
- var arrValue = array[index],
- othValue = other[index];
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, arrValue, index, other, array, stack)
- : customizer(arrValue, othValue, index, array, other, stack);
- }
- if (compared !== undefined) {
- if (compared) {
- continue;
- }
- result = false;
- break;
- }
- // Recursively compare arrays (susceptible to call stack limits).
- if (seen) {
- if (!arraySome(other, function(othValue, othIndex) {
- if (!seen.has(othIndex) &&
- (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
- return seen.add(othIndex);
- }
- })) {
- result = false;
- break;
- }
- } else if (!(
- arrValue === othValue ||
- equalFunc(arrValue, othValue, customizer, bitmask, stack)
- )) {
- result = false;
- break;
- }
- }
- stack['delete'](array);
- return result;
- }
- /** Built-in value references. */
- var Symbol$1 = root.Symbol;
- /** Built-in value references. */
- var Uint8Array = root.Uint8Array;
- /**
- * Converts `map` to its key-value pairs.
- *
- * @private
- * @param {Object} map The map to convert.
- * @returns {Array} Returns the key-value pairs.
- */
- function mapToArray(map) {
- var index = -1,
- result = Array(map.size);
- map.forEach(function(value, key) {
- result[++index] = [key, value];
- });
- return result;
- }
- /**
- * Converts `set` to an array of its values.
- *
- * @private
- * @param {Object} set The set to convert.
- * @returns {Array} Returns the values.
- */
- function setToArray(set) {
- var index = -1,
- result = Array(set.size);
- set.forEach(function(value) {
- result[++index] = value;
- });
- return result;
- }
- var UNORDERED_COMPARE_FLAG$2 = 1;
- var PARTIAL_COMPARE_FLAG$3 = 2;
- var boolTag = '[object Boolean]';
- var dateTag = '[object Date]';
- var errorTag = '[object Error]';
- var mapTag = '[object Map]';
- var numberTag = '[object Number]';
- var regexpTag = '[object RegExp]';
- var setTag = '[object Set]';
- var stringTag$1 = '[object String]';
- var symbolTag$1 = '[object Symbol]';
- var arrayBufferTag = '[object ArrayBuffer]';
- var dataViewTag = '[object DataView]';
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
- var symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
- /**
- * A specialized version of `baseIsEqualDeep` for comparing objects of
- * the same `toStringTag`.
- *
- * **Note:** This function only supports comparing values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {string} tag The `toStringTag` of the objects to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
- switch (tag) {
- case dataViewTag:
- if ((object.byteLength != other.byteLength) ||
- (object.byteOffset != other.byteOffset)) {
- return false;
- }
- object = object.buffer;
- other = other.buffer;
- case arrayBufferTag:
- if ((object.byteLength != other.byteLength) ||
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
- return false;
- }
- return true;
- case boolTag:
- case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and
- // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
- // not equal.
- return +object == +other;
- case errorTag:
- return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object) ? other != +other : object == +other;
- case regexpTag:
- case stringTag$1:
- // Coerce regexes to strings and treat strings, primitives and objects,
- // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
- // for more details.
- return object == (other + '');
- case mapTag:
- var convert = mapToArray;
- case setTag:
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG$3;
- convert || (convert = setToArray);
- if (object.size != other.size && !isPartial) {
- return false;
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(object);
- if (stacked) {
- return stacked == other;
- }
- bitmask |= UNORDERED_COMPARE_FLAG$2;
- stack.set(object, other);
- // Recursively compare objects (susceptible to call stack limits).
- return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
- case symbolTag$1:
- if (symbolValueOf) {
- return symbolValueOf.call(object) == symbolValueOf.call(other);
- }
- }
- return false;
- }
- /** Used to compose bitmasks for comparison styles. */
- var PARTIAL_COMPARE_FLAG$4 = 2;
- /**
- * A specialized version of `baseIsEqualDeep` for objects with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG$4,
- objProps = keys(object),
- objLength = objProps.length,
- othProps = keys(other),
- othLength = othProps.length;
- if (objLength != othLength && !isPartial) {
- return false;
- }
- var index = objLength;
- while (index--) {
- var key = objProps[index];
- if (!(isPartial ? key in other : baseHas(other, key))) {
- return false;
- }
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(object);
- if (stacked) {
- return stacked == other;
- }
- var result = true;
- stack.set(object, other);
- var skipCtor = isPartial;
- while (++index < objLength) {
- key = objProps[index];
- var objValue = object[key],
- othValue = other[key];
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, objValue, key, other, object, stack)
- : customizer(objValue, othValue, key, object, other, stack);
- }
- // Recursively compare objects (susceptible to call stack limits).
- if (!(compared === undefined
- ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
- : compared
- )) {
- result = false;
- break;
- }
- skipCtor || (skipCtor = key == 'constructor');
- }
- if (result && !skipCtor) {
- var objCtor = object.constructor,
- othCtor = other.constructor;
- // Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor &&
- ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
- result = false;
- }
- }
- stack['delete'](object);
- return result;
- }
- /* Built-in method references that are verified to be native. */
- var DataView = getNative(root, 'DataView');
- /* Built-in method references that are verified to be native. */
- var Promise = getNative(root, 'Promise');
- /* Built-in method references that are verified to be native. */
- var Set = getNative(root, 'Set');
- /* Built-in method references that are verified to be native. */
- var WeakMap = getNative(root, 'WeakMap');
- var mapTag$1 = '[object Map]';
- var objectTag$1 = '[object Object]';
- var promiseTag = '[object Promise]';
- var setTag$1 = '[object Set]';
- var weakMapTag = '[object WeakMap]';
- var dataViewTag$1 = '[object DataView]';
- /** Used for built-in method references. */
- var objectProto$10 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$4 = objectProto$10.toString;
- /** Used to detect maps, sets, and weakmaps. */
- var dataViewCtorString = toSource(DataView);
- var mapCtorString = toSource(Map);
- var promiseCtorString = toSource(Promise);
- var setCtorString = toSource(Set);
- var weakMapCtorString = toSource(WeakMap);
- /**
- * Gets the `toStringTag` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function getTag(value) {
- return objectToString$4.call(value);
- }
- // Fallback for data views, maps, sets, and weak maps in IE 11,
- // for data views in Edge, and promises in Node.js.
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
- (Map && getTag(new Map) != mapTag$1) ||
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
- (Set && getTag(new Set) != setTag$1) ||
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
- getTag = function(value) {
- var result = objectToString$4.call(value),
- Ctor = result == objectTag$1 ? value.constructor : undefined,
- ctorString = Ctor ? toSource(Ctor) : undefined;
- if (ctorString) {
- switch (ctorString) {
- case dataViewCtorString: return dataViewTag$1;
- case mapCtorString: return mapTag$1;
- case promiseCtorString: return promiseTag;
- case setCtorString: return setTag$1;
- case weakMapCtorString: return weakMapTag;
- }
- }
- return result;
- };
- }
- var getTag$1 = getTag;
- var argsTag$2 = '[object Arguments]';
- var arrayTag$1 = '[object Array]';
- var boolTag$1 = '[object Boolean]';
- var dateTag$1 = '[object Date]';
- var errorTag$1 = '[object Error]';
- var funcTag$1 = '[object Function]';
- var mapTag$2 = '[object Map]';
- var numberTag$1 = '[object Number]';
- var objectTag$2 = '[object Object]';
- var regexpTag$1 = '[object RegExp]';
- var setTag$2 = '[object Set]';
- var stringTag$2 = '[object String]';
- var weakMapTag$1 = '[object WeakMap]';
- var arrayBufferTag$1 = '[object ArrayBuffer]';
- var dataViewTag$2 = '[object DataView]';
- var float32Tag = '[object Float32Array]';
- var float64Tag = '[object Float64Array]';
- var int8Tag = '[object Int8Array]';
- var int16Tag = '[object Int16Array]';
- var int32Tag = '[object Int32Array]';
- var uint8Tag = '[object Uint8Array]';
- var uint8ClampedTag = '[object Uint8ClampedArray]';
- var uint16Tag = '[object Uint16Array]';
- var uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$1] =
- typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
- typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
- typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
- typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
- typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
- typedArrayTags[setTag$2] = typedArrayTags[stringTag$2] =
- typedArrayTags[weakMapTag$1] = false;
- /** Used for built-in method references. */
- var objectProto$11 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString$5 = objectProto$11.toString;
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- function isTypedArray(value) {
- return isObjectLike(value) &&
- isLength(value.length) && !!typedArrayTags[objectToString$5.call(value)];
- }
- /** Used to compose bitmasks for comparison styles. */
- var PARTIAL_COMPARE_FLAG$1 = 2;
- /** `Object#toString` result references. */
- var argsTag$1 = '[object Arguments]';
- var arrayTag = '[object Array]';
- var objectTag = '[object Object]';
- /** Used for built-in method references. */
- var objectProto$9 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$5 = objectProto$9.hasOwnProperty;
- /**
- * A specialized version of `baseIsEqual` for arrays and objects which performs
- * deep comparisons and tracks traversed objects enabling objects with circular
- * references to be compared.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
- var objIsArr = isArray(object),
- othIsArr = isArray(other),
- objTag = arrayTag,
- othTag = arrayTag;
- if (!objIsArr) {
- objTag = getTag$1(object);
- objTag = objTag == argsTag$1 ? objectTag : objTag;
- }
- if (!othIsArr) {
- othTag = getTag$1(other);
- othTag = othTag == argsTag$1 ? objectTag : othTag;
- }
- var objIsObj = objTag == objectTag && !isHostObject(object),
- othIsObj = othTag == objectTag && !isHostObject(other),
- isSameTag = objTag == othTag;
- if (isSameTag && !objIsObj) {
- stack || (stack = new Stack);
- return (objIsArr || isTypedArray(object))
- ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
- : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
- }
- if (!(bitmask & PARTIAL_COMPARE_FLAG$1)) {
- var objIsWrapped = objIsObj && hasOwnProperty$5.call(object, '__wrapped__'),
- othIsWrapped = othIsObj && hasOwnProperty$5.call(other, '__wrapped__');
- if (objIsWrapped || othIsWrapped) {
- var objUnwrapped = objIsWrapped ? object.value() : object,
- othUnwrapped = othIsWrapped ? other.value() : other;
- stack || (stack = new Stack);
- return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
- }
- }
- if (!isSameTag) {
- return false;
- }
- stack || (stack = new Stack);
- return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
- }
- /**
- * The base implementation of `_.isEqual` which supports partial comparisons
- * and tracks traversed objects.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {boolean} [bitmask] The bitmask of comparison flags.
- * The bitmask may be composed of the following flags:
- * 1 - Unordered comparison
- * 2 - Partial comparison
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- */
- function baseIsEqual(value, other, customizer, bitmask, stack) {
- if (value === other) {
- return true;
- }
- if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
- return value !== value && other !== other;
- }
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
- }
- var UNORDERED_COMPARE_FLAG = 1;
- var PARTIAL_COMPARE_FLAG = 2;
- /**
- * The base implementation of `_.isMatch` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @param {Object} source The object of property values to match.
- * @param {Array} matchData The property names, values, and compare flags to match.
- * @param {Function} [customizer] The function to customize comparisons.
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
- */
- function baseIsMatch(object, source, matchData, customizer) {
- var index = matchData.length,
- length = index,
- noCustomizer = !customizer;
- if (object == null) {
- return !length;
- }
- object = Object(object);
- while (index--) {
- var data = matchData[index];
- if ((noCustomizer && data[2])
- ? data[1] !== object[data[0]]
- : !(data[0] in object)
- ) {
- return false;
- }
- }
- while (++index < length) {
- data = matchData[index];
- var key = data[0],
- objValue = object[key],
- srcValue = data[1];
- if (noCustomizer && data[2]) {
- if (objValue === undefined && !(key in object)) {
- return false;
- }
- } else {
- var stack = new Stack;
- if (customizer) {
- var result = customizer(objValue, srcValue, key, object, source, stack);
- }
- if (!(result === undefined
- ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
- : result
- )) {
- return false;
- }
- }
- }
- return true;
- }
- /**
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` if suitable for strict
- * equality comparisons, else `false`.
- */
- function isStrictComparable(value) {
- return value === value && !isObject(value);
- }
- /**
- * Gets the property names, values, and compare flags of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the match data of `object`.
- */
- function getMatchData(object) {
- var result = keys(object),
- length = result.length;
- while (length--) {
- var key = result[length],
- value = object[key];
- result[length] = [key, value, isStrictComparable(value)];
- }
- return result;
- }
- /**
- * A specialized version of `matchesProperty` for source values suitable
- * for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function matchesStrictComparable(key, srcValue) {
- return function(object) {
- if (object == null) {
- return false;
- }
- return object[key] === srcValue &&
- (srcValue !== undefined || (key in Object(object)));
- };
- }
- /**
- * The base implementation of `_.matches` which doesn't clone `source`.
- *
- * @private
- * @param {Object} source The object of property values to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatches(source) {
- var matchData = getMatchData(source);
- if (matchData.length == 1 && matchData[0][2]) {
- return matchesStrictComparable(matchData[0][0], matchData[0][1]);
- }
- return function(object) {
- return object === source || baseIsMatch(object, source, matchData);
- };
- }
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
- /**
- * Creates a function that memoizes the result of `func`. If `resolver` is
- * provided, it determines the cache key for storing the result based on the
- * arguments provided to the memoized function. By default, the first argument
- * provided to the memoized function is used as the map cache key. The `func`
- * is invoked with the `this` binding of the memoized function.
- *
- * **Note:** The cache is exposed as the `cache` property on the memoized
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
- * constructor with one whose instances implement the
- * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
- * method interface of `delete`, `get`, `has`, and `set`.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to have its output memoized.
- * @param {Function} [resolver] The function to resolve the cache key.
- * @returns {Function} Returns the new memoized function.
- * @example
- *
- * var object = { 'a': 1, 'b': 2 };
- * var other = { 'c': 3, 'd': 4 };
- *
- * var values = _.memoize(_.values);
- * values(object);
- * // => [1, 2]
- *
- * values(other);
- * // => [3, 4]
- *
- * object.a = 2;
- * values(object);
- * // => [1, 2]
- *
- * // Modify the result cache.
- * values.cache.set(object, ['a', 'b']);
- * values(object);
- * // => ['a', 'b']
- *
- * // Replace `_.memoize.Cache`.
- * _.memoize.Cache = WeakMap;
- */
- function memoize(func, resolver) {
- if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
- throw new TypeError(FUNC_ERROR_TEXT$1);
- }
- var memoized = function() {
- var args = arguments,
- key = resolver ? resolver.apply(this, args) : args[0],
- cache = memoized.cache;
- if (cache.has(key)) {
- return cache.get(key);
- }
- var result = func.apply(this, args);
- memoized.cache = cache.set(key, result);
- return result;
- };
- memoized.cache = new (memoize.Cache || MapCache);
- return memoized;
- }
- // Assign cache to `_.memoize`.
- memoize.Cache = MapCache;
- /** Used as references for various `Number` constants. */
- var INFINITY$1 = 1 / 0;
- /** Used to convert symbols to primitives and strings. */
- var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined;
- var symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isSymbol(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
- }
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : baseToString(value);
- }
- /** Used to match property names within property paths. */
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;
- /** Used to match backslashes in property paths. */
- var reEscapeChar = /\\(\\)?/g;
- /**
- * Converts `string` to a property path array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the property path array.
- */
- var stringToPath = memoize(function(string) {
- var result = [];
- toString(string).replace(rePropName, function(match, number, quote, string) {
- result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
- });
- return result;
- });
- /**
- * Casts `value` to a path array if it's not one.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Array} Returns the cast property path array.
- */
- function castPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
- var reIsPlainProp = /^\w*$/;
- /**
- * Checks if `value` is a property name and not a property path.
- *
- * @private
- * @param {*} value The value to check.
- * @param {Object} [object] The object to query keys on.
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
- */
- function isKey(value, object) {
- if (isArray(value)) {
- return false;
- }
- var type = typeof value;
- if (type == 'number' || type == 'symbol' || type == 'boolean' ||
- value == null || isSymbol(value)) {
- return true;
- }
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
- (object != null && value in Object(object));
- }
- /** Used as references for various `Number` constants. */
- var INFINITY$2 = 1 / 0;
- /**
- * Converts `value` to a string key if it's not a string or symbol.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {string|symbol} Returns the key.
- */
- function toKey(value) {
- if (typeof value == 'string' || isSymbol(value)) {
- return value;
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result;
- }
- /**
- * The base implementation of `_.get` without support for default values.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @returns {*} Returns the resolved value.
- */
- function baseGet(object, path) {
- path = isKey(path, object) ? [path] : castPath(path);
- var index = 0,
- length = path.length;
- while (object != null && index < length) {
- object = object[toKey(path[index++])];
- }
- return (index && index == length) ? object : undefined;
- }
- /**
- * Gets the value at `path` of `object`. If the resolved value is
- * `undefined`, the `defaultValue` is used in its place.
- *
- * @static
- * @memberOf _
- * @since 3.7.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @param {*} [defaultValue] The value returned for `undefined` resolved values.
- * @returns {*} Returns the resolved value.
- * @example
- *
- * var object = { 'a': [{ 'b': { 'c': 3 } }] };
- *
- * _.get(object, 'a[0].b.c');
- * // => 3
- *
- * _.get(object, ['a', '0', 'b', 'c']);
- * // => 3
- *
- * _.get(object, 'a.b.c', 'default');
- * // => 'default'
- */
- function get(object, path, defaultValue) {
- var result = object == null ? undefined : baseGet(object, path);
- return result === undefined ? defaultValue : result;
- }
- /**
- * The base implementation of `_.hasIn` without support for deep paths.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHasIn(object, key) {
- return object != null && key in Object(object);
- }
- /**
- * Checks if `path` exists on `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @param {Function} hasFunc The function to check properties.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- */
- function hasPath(object, path, hasFunc) {
- path = isKey(path, object) ? [path] : castPath(path);
- var result,
- index = -1,
- length = path.length;
- while (++index < length) {
- var key = toKey(path[index]);
- if (!(result = object != null && hasFunc(object, key))) {
- break;
- }
- object = object[key];
- }
- if (result) {
- return result;
- }
- var length = object ? object.length : 0;
- return !!length && isLength(length) && isIndex(key, length) &&
- (isArray(object) || isString(object) || isArguments(object));
- }
- /**
- * Checks if `path` is a direct or inherited property of `object`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- * @example
- *
- * var object = _.create({ 'a': _.create({ 'b': 2 }) });
- *
- * _.hasIn(object, 'a');
- * // => true
- *
- * _.hasIn(object, 'a.b');
- * // => true
- *
- * _.hasIn(object, ['a', 'b']);
- * // => true
- *
- * _.hasIn(object, 'b');
- * // => false
- */
- function hasIn(object, path) {
- return object != null && hasPath(object, path, baseHasIn);
- }
- var UNORDERED_COMPARE_FLAG$3 = 1;
- var PARTIAL_COMPARE_FLAG$5 = 2;
- /**
- * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
- *
- * @private
- * @param {string} path The path of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatchesProperty(path, srcValue) {
- if (isKey(path) && isStrictComparable(srcValue)) {
- return matchesStrictComparable(toKey(path), srcValue);
- }
- return function(object) {
- var objValue = get(object, path);
- return (objValue === undefined && objValue === srcValue)
- ? hasIn(object, path)
- : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG$3 | PARTIAL_COMPARE_FLAG$5);
- };
- }
- /**
- * This method returns the first argument given to it.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
- return value;
- }
- /**
- * A specialized version of `baseProperty` which supports deep paths.
- *
- * @private
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function basePropertyDeep(path) {
- return function(object) {
- return baseGet(object, path);
- };
- }
- /**
- * Creates a function that returns the value at `path` of a given object.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- * @example
- *
- * var objects = [
- * { 'a': { 'b': 2 } },
- * { 'a': { 'b': 1 } }
- * ];
- *
- * _.map(objects, _.property('a.b'));
- * // => [2, 1]
- *
- * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
- * // => [1, 2]
- */
- function property(path) {
- return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
- }
- /**
- * The base implementation of `_.iteratee`.
- *
- * @private
- * @param {*} [value=_.identity] The value to convert to an iteratee.
- * @returns {Function} Returns the iteratee.
- */
- function baseIteratee(value) {
- // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
- // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
- if (typeof value == 'function') {
- return value;
- }
- if (value == null) {
- return identity;
- }
- if (typeof value == 'object') {
- return isArray(value)
- ? baseMatchesProperty(value[0], value[1])
- : baseMatches(value);
- }
- return property(value);
- }
- /**
- * Iterates over own enumerable string keyed properties of an object and
- * invokes `iteratee` for each property. The iteratee is invoked with three
- * arguments: (value, key, object). Iteratee functions may exit iteration
- * early by explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @since 0.3.0
- * @category Object
- * @param {Object} object The object to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Object} Returns `object`.
- * @see _.forOwnRight
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.forOwn(new Foo, function(value, key) {
- * console.log(key);
- * });
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
- */
- function forOwn(object, iteratee) {
- return object && baseForOwn(object, baseIteratee(iteratee, 3));
- }
- /**
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched `NaN`, else `-1`.
- */
- function indexOfNaN(array, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 1 : -1);
- while ((fromRight ? index-- : ++index < length)) {
- var other = array[index];
- if (other !== other) {
- return index;
- }
- }
- return -1;
- }
- /**
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- if (value !== value) {
- return indexOfNaN(array, fromIndex);
- }
- var index = fromIndex - 1,
- length = array.length;
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
- /**
- * Determines the best order for running the functions in `tasks`, based on
- * their requirements. Each function can optionally depend on other functions
- * being completed first, and each function is run as soon as its requirements
- * are satisfied.
- *
- * If any of the functions pass an error to their callback, the `auto` sequence
- * will stop. Further tasks will not execute (so any other functions depending
- * on it will not run), and the main `callback` is immediately called with the
- * error.
- *
- * Functions also receive an object containing the results of functions which
- * have completed so far as the first argument, if they have dependencies. If a
- * task function has no dependencies, it will only be passed a callback.
- *
- * @name auto
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Object} tasks - An object. Each of its properties is either a
- * function or an array of requirements, with the function itself the last item
- * in the array. The object's key of a property serves as the name of the task
- * defined by that property, i.e. can be used when specifying requirements for
- * other tasks. The function receives one or two arguments:
- * * a `results` object, containing the results of the previously executed
- * functions, only passed if the task has any dependencies,
- * * a `callback(err, result)` function, which must be called when finished,
- * passing an `error` (which can be `null`) and the result of the function's
- * execution.
- * @param {number} [concurrency=Infinity] - An optional `integer` for
- * determining the maximum number of tasks that can be run in parallel. By
- * default, as many as possible.
- * @param {Function} [callback] - An optional callback which is called when all
- * the tasks have been completed. It receives the `err` argument if any `tasks`
- * pass an error to their callback. Results are always returned; however, if an
- * error occurs, no further `tasks` will be performed, and the results object
- * will only contain partial results. Invoked with (err, results).
- * @example
- *
- * async.auto({
- * // this function will just be passed a callback
- * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
- * showData: ['readData', function(results, cb) {
- * // results.readData is the file's contents
- * // ...
- * }]
- * }, callback);
- *
- * async.auto({
- * get_data: function(callback) {
- * console.log('in get_data');
- * // async code to get some data
- * callback(null, 'data', 'converted to array');
- * },
- * make_folder: function(callback) {
- * console.log('in make_folder');
- * // async code to create a directory to store a file in
- * // this is run at the same time as getting the data
- * callback(null, 'folder');
- * },
- * write_file: ['get_data', 'make_folder', function(results, callback) {
- * console.log('in write_file', JSON.stringify(results));
- * // once there is some data and the directory exists,
- * // write the data to a file in the directory
- * callback(null, 'filename');
- * }],
- * email_link: ['write_file', function(results, callback) {
- * console.log('in email_link', JSON.stringify(results));
- * // once the file is written let's email a link to it...
- * // results.write_file contains the filename returned by write_file.
- * callback(null, {'file':results.write_file, 'email':'[email protected]'});
- * }]
- * }, function(err, results) {
- * console.log('err = ', err);
- * console.log('results = ', results);
- * });
- */
- function auto (tasks, concurrency, callback) {
- if (typeof concurrency === 'function') {
- // concurrency is optional, shift the args.
- callback = concurrency;
- concurrency = null;
- }
- callback = once(callback || noop);
- var keys$$ = keys(tasks);
- var numTasks = keys$$.length;
- if (!numTasks) {
- return callback(null);
- }
- if (!concurrency) {
- concurrency = numTasks;
- }
- var results = {};
- var runningTasks = 0;
- var hasError = false;
- var listeners = {};
- var readyTasks = [];
- // for cycle detection:
- var readyToCheck = []; // tasks that have been identified as reachable
- // without the possibility of returning to an ancestor task
- var uncheckedDependencies = {};
- forOwn(tasks, function (task, key) {
- if (!isArray(task)) {
- // no dependencies
- enqueueTask(key, [task]);
- readyToCheck.push(key);
- return;
- }
- var dependencies = task.slice(0, task.length - 1);
- var remainingDependencies = dependencies.length;
- if (remainingDependencies === 0) {
- enqueueTask(key, task);
- readyToCheck.push(key);
- return;
- }
- uncheckedDependencies[key] = remainingDependencies;
- arrayEach(dependencies, function (dependencyName) {
- if (!tasks[dependencyName]) {
- throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
- }
- addListener(dependencyName, function () {
- remainingDependencies--;
- if (remainingDependencies === 0) {
- enqueueTask(key, task);
- }
- });
- });
- });
- checkForDeadlocks();
- processQueue();
- function enqueueTask(key, task) {
- readyTasks.push(function () {
- runTask(key, task);
- });
- }
- function processQueue() {
- if (readyTasks.length === 0 && runningTasks === 0) {
- return callback(null, results);
- }
- while (readyTasks.length && runningTasks < concurrency) {
- var run = readyTasks.shift();
- run();
- }
- }
- function addListener(taskName, fn) {
- var taskListeners = listeners[taskName];
- if (!taskListeners) {
- taskListeners = listeners[taskName] = [];
- }
- taskListeners.push(fn);
- }
- function taskComplete(taskName) {
- var taskListeners = listeners[taskName] || [];
- arrayEach(taskListeners, function (fn) {
- fn();
- });
- processQueue();
- }
- function runTask(key, task) {
- if (hasError) return;
- var taskCallback = onlyOnce(rest(function (err, args) {
- runningTasks--;
- if (args.length <= 1) {
- args = args[0];
- }
- if (err) {
- var safeResults = {};
- forOwn(results, function (val, rkey) {
- safeResults[rkey] = val;
- });
- safeResults[key] = args;
- hasError = true;
- listeners = [];
- callback(err, safeResults);
- } else {
- results[key] = args;
- taskComplete(key);
- }
- }));
- runningTasks++;
- var taskFn = task[task.length - 1];
- if (task.length > 1) {
- taskFn(results, taskCallback);
- } else {
- taskFn(taskCallback);
- }
- }
- function checkForDeadlocks() {
- // Kahn's algorithm
- // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
- // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
- var currentTask;
- var counter = 0;
- while (readyToCheck.length) {
- currentTask = readyToCheck.pop();
- counter++;
- arrayEach(getDependents(currentTask), function (dependent) {
- if (! --uncheckedDependencies[dependent]) {
- readyToCheck.push(dependent);
- }
- });
- }
- if (counter !== numTasks) {
- throw new Error('async.auto cannot execute tasks due to a recursive dependency');
- }
- }
- function getDependents(taskName) {
- var result = [];
- forOwn(tasks, function (task, key) {
- if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
- result.push(key);
- }
- });
- return result;
- }
- }
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array ? array.length : 0,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function copyArray(source, array) {
- var index = -1,
- length = source.length;
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
- }
- return array;
- }
- /**
- * The base implementation of `_.slice` without an iteratee call guard.
- *
- * @private
- * @param {Array} array The array to slice.
- * @param {number} [start=0] The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the slice of `array`.
- */
- function baseSlice(array, start, end) {
- var index = -1,
- length = array.length;
- if (start < 0) {
- start = -start > length ? 0 : (length + start);
- }
- end = end > length ? length : end;
- if (end < 0) {
- end += length;
- }
- length = start > end ? 0 : ((end - start) >>> 0);
- start >>>= 0;
- var result = Array(length);
- while (++index < length) {
- result[index] = array[index + start];
- }
- return result;
- }
- /**
- * Casts `array` to a slice if it's needed.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {number} start The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the cast slice.
- */
- function castSlice(array, start, end) {
- var length = array.length;
- end = end === undefined ? length : end;
- return (!start && end >= length) ? array : baseSlice(array, start, end);
- }
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
- * that is not found in the character symbols.
- *
- * @private
- * @param {Array} strSymbols The string symbols to inspect.
- * @param {Array} chrSymbols The character symbols to find.
- * @returns {number} Returns the index of the last unmatched string symbol.
- */
- function charsEndIndex(strSymbols, chrSymbols) {
- var index = strSymbols.length;
- while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
- return index;
- }
- /**
- * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
- * that is not found in the character symbols.
- *
- * @private
- * @param {Array} strSymbols The string symbols to inspect.
- * @param {Array} chrSymbols The character symbols to find.
- * @returns {number} Returns the index of the first unmatched string symbol.
- */
- function charsStartIndex(strSymbols, chrSymbols) {
- var index = -1,
- length = strSymbols.length;
- while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
- return index;
- }
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff';
- var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
- var rsComboSymbolsRange = '\\u20d0-\\u20f0';
- var rsVarRange = '\\ufe0e\\ufe0f';
- var rsAstral = '[' + rsAstralRange + ']';
- var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
- var rsFitz = '\\ud83c[\\udffb-\\udfff]';
- var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
- var rsNonAstral = '[^' + rsAstralRange + ']';
- var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
- var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
- var rsZWJ = '\\u200d';
- var reOptMod = rsModifier + '?';
- var rsOptVar = '[' + rsVarRange + ']?';
- var rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
- var rsSeq = rsOptVar + reOptMod + rsOptJoin;
- var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
- /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
- var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
- /**
- * Converts `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
- function stringToArray(string) {
- return string.match(reComplexSymbol);
- }
- /** Used to match leading and trailing whitespace. */
- var reTrim$1 = /^\s+|\s+$/g;
- /**
- * Removes leading and trailing whitespace or specified characters from `string`.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to trim.
- * @param {string} [chars=whitespace] The characters to trim.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {string} Returns the trimmed string.
- * @example
- *
- * _.trim(' abc ');
- * // => 'abc'
- *
- * _.trim('-_-abc-_-', '_-');
- * // => 'abc'
- *
- * _.map([' foo ', ' bar '], _.trim);
- * // => ['foo', 'bar']
- */
- function trim(string, chars, guard) {
- string = toString(string);
- if (string && (guard || chars === undefined)) {
- return string.replace(reTrim$1, '');
- }
- if (!string || !(chars = baseToString(chars))) {
- return string;
- }
- var strSymbols = stringToArray(string),
- chrSymbols = stringToArray(chars),
- start = charsStartIndex(strSymbols, chrSymbols),
- end = charsEndIndex(strSymbols, chrSymbols) + 1;
- return castSlice(strSymbols, start, end).join('');
- }
- var argsRegex = /^(function[^\(]*)?\(?\s*([^\)=]*)/m;
- function parseParams(func) {
- return trim(func.toString().match(argsRegex)[2]).split(/\s*\,\s*/);
- }
- /**
- * A dependency-injected version of the {@link async.auto} function. Dependent
- * tasks are specified as parameters to the function, after the usual callback
- * parameter, with the parameter names matching the names of the tasks it
- * depends on. This can provide even more readable task graphs which can be
- * easier to maintain.
- *
- * If a final callback is specified, the task results are similarly injected,
- * specified as named parameters after the initial error parameter.
- *
- * The autoInject function is purely syntactic sugar and its semantics are
- * otherwise equivalent to {@link async.auto}.
- *
- * @name autoInject
- * @static
- * @memberOf async
- * @see async.auto
- * @category Control Flow
- * @param {Object} tasks - An object, each of whose properties is a function of
- * the form 'func([dependencies...], callback). The object's key of a property
- * serves as the name of the task defined by that property, i.e. can be used
- * when specifying requirements for other tasks.
- * * The `callback` parameter is a `callback(err, result)` which must be called
- * when finished, passing an `error` (which can be `null`) and the result of
- * the function's execution. The remaining parameters name other tasks on
- * which the task is dependent, and the results from those tasks are the
- * arguments of those parameters.
- * @param {Function} [callback] - An optional callback which is called when all
- * the tasks have been completed. It receives the `err` argument if any `tasks`
- * pass an error to their callback. The remaining parameters are task names
- * whose results you are interested in. This callback will only be called when
- * all tasks have finished or an error has occurred, and so do not specify
- * dependencies in the same way as `tasks` do. If an error occurs, no further
- * `tasks` will be performed, and `results` will only be valid for those tasks
- * which managed to complete. Invoked with (err, [results...]).
- * @example
- *
- * // The example from `auto` can be rewritten as follows:
- * async.autoInject({
- * get_data: function(callback) {
- * // async code to get some data
- * callback(null, 'data', 'converted to array');
- * },
- * make_folder: function(callback) {
- * // async code to create a directory to store a file in
- * // this is run at the same time as getting the data
- * callback(null, 'folder');
- * },
- * write_file: function(get_data, make_folder, callback) {
- * // once there is some data and the directory exists,
- * // write the data to a file in the directory
- * callback(null, 'filename');
- * },
- * email_link: function(write_file, callback) {
- * // once the file is written let's email a link to it...
- * // write_file contains the filename returned by write_file.
- * callback(null, {'file':write_file, 'email':'[email protected]'});
- * }
- * }, function(err, email_link) {
- * console.log('err = ', err);
- * console.log('email_link = ', email_link);
- * });
- *
- * // If you are using a JS minifier that mangles parameter names, `autoInject`
- * // will not work with plain functions, since the parameter names will be
- * // collapsed to a single letter identifier. To work around this, you can
- * // explicitly specify the names of the parameters your task function needs
- * // in an array, similar to Angular.js dependency injection. The final
- * // results callback can be provided as an array in the same way.
- *
- * // This still has an advantage over plain `auto`, since the results a task
- * // depends on are still spread into arguments.
- * async.autoInject({
- * //...
- * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
- * callback(null, 'filename');
- * }],
- * email_link: ['write_file', function(write_file, callback) {
- * callback(null, {'file':write_file, 'email':'[email protected]'});
- * }]
- * //...
- * }, ['email_link', function(err, email_link) {
- * console.log('err = ', err);
- * console.log('email_link = ', email_link);
- * }]);
- */
- function autoInject(tasks, callback) {
- var newTasks = {};
- forOwn(tasks, function (taskFn, key) {
- var params;
- if (isArray(taskFn)) {
- params = copyArray(taskFn);
- taskFn = params.pop();
- newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
- } else if (taskFn.length === 0) {
- throw new Error("autoInject task functions require explicit parameters.");
- } else if (taskFn.length === 1) {
- // no dependencies, use the function as-is
- newTasks[key] = taskFn;
- } else {
- params = parseParams(taskFn);
- params.pop();
- newTasks[key] = params.concat(newTask);
- }
- function newTask(results, taskCb) {
- var newArgs = arrayMap(params, function (name) {
- return results[name];
- });
- newArgs.push(taskCb);
- taskFn.apply(null, newArgs);
- }
- });
- auto(newTasks, callback);
- }
- var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
- var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
- function fallback(fn) {
- setTimeout(fn, 0);
- }
- function wrap(defer) {
- return rest(function (fn, args) {
- defer(function () {
- fn.apply(null, args);
- });
- });
- }
- var _defer;
- if (hasSetImmediate) {
- _defer = setImmediate;
- } else if (hasNextTick) {
- _defer = process.nextTick;
- } else {
- _defer = fallback;
- }
- var setImmediate$1 = wrap(_defer);
- function queue(worker, concurrency, payload) {
- if (concurrency == null) {
- concurrency = 1;
- } else if (concurrency === 0) {
- throw new Error('Concurrency must not be zero');
- }
- function _insert(q, data, pos, callback) {
- if (callback != null && typeof callback !== 'function') {
- throw new Error('task callback must be a function');
- }
- q.started = true;
- if (!isArray(data)) {
- data = [data];
- }
- if (data.length === 0 && q.idle()) {
- // call drain immediately if there are no tasks
- return setImmediate$1(function () {
- q.drain();
- });
- }
- arrayEach(data, function (task) {
- var item = {
- data: task,
- callback: callback || noop
- };
- if (pos) {
- q.tasks.unshift(item);
- } else {
- q.tasks.push(item);
- }
- });
- setImmediate$1(q.process);
- }
- function _next(q, tasks) {
- return function () {
- workers -= 1;
- var removed = false;
- var args = arguments;
- arrayEach(tasks, function (task) {
- arrayEach(workersList, function (worker, index) {
- if (worker === task && !removed) {
- workersList.splice(index, 1);
- removed = true;
- }
- });
- task.callback.apply(task, args);
- if (args[0] != null) {
- q.error(args[0], task.data);
- }
- });
- if (workers <= q.concurrency - q.buffer) {
- q.unsaturated();
- }
- if (q.tasks.length + workers === 0) {
- q.drain();
- }
- q.process();
- };
- }
- var workers = 0;
- var workersList = [];
- var q = {
- tasks: [],
- concurrency: concurrency,
- payload: payload,
- saturated: noop,
- unsaturated: noop,
- buffer: concurrency / 4,
- empty: noop,
- drain: noop,
- error: noop,
- started: false,
- paused: false,
- push: function (data, callback) {
- _insert(q, data, false, callback);
- },
- kill: function () {
- q.drain = noop;
- q.tasks = [];
- },
- unshift: function (data, callback) {
- _insert(q, data, true, callback);
- },
- process: function () {
- while (!q.paused && workers < q.concurrency && q.tasks.length) {
- var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
- var data = arrayMap(tasks, baseProperty('data'));
- if (q.tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- workersList.push(tasks[0]);
- if (workers === q.concurrency) {
- q.saturated();
- }
- var cb = onlyOnce(_next(q, tasks));
- worker(data, cb);
- }
- },
- length: function () {
- return q.tasks.length;
- },
- running: function () {
- return workers;
- },
- workersList: function () {
- return workersList;
- },
- idle: function () {
- return q.tasks.length + workers === 0;
- },
- pause: function () {
- q.paused = true;
- },
- resume: function () {
- if (q.paused === false) {
- return;
- }
- q.paused = false;
- var resumeCount = Math.min(q.concurrency, q.tasks.length);
- // Need to call q.process once per concurrent
- // worker to preserve full concurrency after pause
- for (var w = 1; w <= resumeCount; w++) {
- setImmediate$1(q.process);
- }
- }
- };
- return q;
- }
- /**
- * A cargo of tasks for the worker function to complete. Cargo inherits all of
- * the same methods and event callbacks as {@link async.queue}.
- * @typedef {Object} cargo
- * @property {Function} length - A function returning the number of items
- * waiting to be processed. Invoke with ().
- * @property {number} payload - An `integer` for determining how many tasks
- * should be process per round. This property can be changed after a `cargo` is
- * created to alter the payload on-the-fly.
- * @property {Function} push - Adds `task` to the `queue`. The callback is
- * called once the `worker` has finished processing the task. Instead of a
- * single task, an array of `tasks` can be submitted. The respective callback is
- * used for every task in the list. Invoke with (task, [callback]).
- * @property {Function} saturated - A callback that is called when the
- * `queue.length()` hits the concurrency and further tasks will be queued.
- * @property {Function} empty - A callback that is called when the last item
- * from the `queue` is given to a `worker`.
- * @property {Function} drain - A callback that is called when the last item
- * from the `queue` has returned from the `worker`.
- * @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with ().
- * @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with ().
- * @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with ().
- * @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
- */
- /**
- * Creates a `cargo` object with the specified payload. Tasks added to the
- * cargo will be processed altogether (up to the `payload` limit). If the
- * `worker` is in progress, the task is queued until it becomes available. Once
- * the `worker` has completed some tasks, each callback of those tasks is
- * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
- * for how `cargo` and `queue` work.
- *
- * While [queue](#queue) passes only one task to one of a group of workers
- * at a time, cargo passes an array of tasks to a single worker, repeating
- * when the worker is finished.
- *
- * @name cargo
- * @static
- * @memberOf async
- * @see async.queue
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing an array
- * of queued tasks, which must call its `callback(err)` argument when finished,
- * with an optional `err` argument. Invoked with (tasks, callback).
- * @param {number} [payload=Infinity] - An optional `integer` for determining
- * how many tasks should be processed per round; if omitted, the default is
- * unlimited.
- * @returns {cargo} A cargo object to manage the tasks. Callbacks can
- * attached as certain properties to listen for specific events during the
- * lifecycle of the cargo and inner queue.
- * @example
- *
- * // create a cargo object with payload 2
- * var cargo = async.cargo(function(tasks, callback) {
- * for (var i=0; i<tasks.length; i++) {
- * console.log('hello ' + tasks[i].name);
- * }
- * callback();
- * }, 2);
- *
- * // add some items
- * cargo.push({name: 'foo'}, function(err) {
- * console.log('finished processing foo');
- * });
- * cargo.push({name: 'bar'}, function(err) {
- * console.log('finished processing bar');
- * });
- * cargo.push({name: 'baz'}, function(err) {
- * console.log('finished processing baz');
- * });
- */
- function cargo(worker, payload) {
- return queue(worker, 1, payload);
- }
- /**
- * The same as `eachOf` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name eachOfLimit
- * @static
- * @memberOf async
- * @see async.eachOf
- * @alias forEachOfLimit
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- function eachOfLimit(obj, limit, iteratee, cb) {
- _eachOfLimit(limit)(obj, iteratee, cb);
- }
- /**
- * The same as `eachOf` but runs only a single async operation at a time.
- *
- * @name eachOfSeries
- * @static
- * @memberOf async
- * @see async.eachOf
- * @alias forEachOfSeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`. The
- * `key` is the item's key, or index in the case of an array. The iteratee is
- * passed a `callback(err)` which must be called once it has completed. If no
- * error has occurred, the callback should be run without arguments or with an
- * explicit `null` argument. Invoked with (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Invoked with (err).
- */
- var eachOfSeries = doLimit(eachOfLimit, 1);
- /**
- * Reduces `coll` into a single value using an async `iteratee` to return each
- * successive step. `memo` is the initial state of the reduction. This function
- * only operates in series.
- *
- * For performance reasons, it may make sense to split a call to this function
- * into a parallel map, and then use the normal `Array.prototype.reduce` on the
- * results. This function is for situations where each step in the reduction
- * needs to be async; if you can get the data before reducing it, then it's
- * probably a good idea to do so.
- *
- * @name reduce
- * @static
- * @memberOf async
- * @alias inject, foldl
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {*} memo - The initial state of the reduction.
- * @param {Function} iteratee - A function applied to each item in the
- * array to produce the next step in the reduction. The `iteratee` is passed a
- * `callback(err, reduction)` which accepts an optional error as its first
- * argument, and the state of the reduction as the second. If an error is
- * passed to the callback, the reduction is stopped and the main `callback` is
- * immediately called with the error. Invoked with (memo, item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the reduced value. Invoked with
- * (err, result).
- * @example
- *
- * async.reduce([1,2,3], 0, function(memo, item, callback) {
- * // pointless async:
- * process.nextTick(function() {
- * callback(null, memo + item)
- * });
- * }, function(err, result) {
- * // result is now equal to the last value of memo, which is 6
- * });
- */
- function reduce(arr, memo, iteratee, cb) {
- eachOfSeries(arr, function (x, i, cb) {
- iteratee(memo, x, function (err, v) {
- memo = v;
- cb(err);
- });
- }, function (err) {
- cb(err, memo);
- });
- }
- /**
- * Version of the compose function that is more natural to read. Each function
- * consumes the return value of the previous function. It is the equivalent of
- * {@link async.compose} with the arguments reversed.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name seq
- * @static
- * @memberOf async
- * @see async.compose
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @example
- *
- * // Requires lodash (or underscore), express3 and dresende's orm2.
- * // Part of an app, that fetches cats of the logged user.
- * // This example uses `seq` function to avoid overnesting and error
- * // handling clutter.
- * app.get('/cats', function(request, response) {
- * var User = request.models.User;
- * async.seq(
- * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
- * function(user, fn) {
- * user.getCats(fn); // 'getCats' has signature (callback(err, data))
- * }
- * )(req.session.user_id, function (err, cats) {
- * if (err) {
- * console.error(err);
- * response.json({ status: 'error', message: err.message });
- * } else {
- * response.json({ status: 'ok', message: 'Cats found', data: cats });
- * }
- * });
- * });
- */
- function seq() /* functions... */{
- var fns = arguments;
- return rest(function (args) {
- var that = this;
- var cb = args[args.length - 1];
- if (typeof cb == 'function') {
- args.pop();
- } else {
- cb = noop;
- }
- reduce(fns, args, function (newargs, fn, cb) {
- fn.apply(that, newargs.concat([rest(function (err, nextargs) {
- cb(err, nextargs);
- })]));
- }, function (err, results) {
- cb.apply(that, [err].concat(results));
- });
- });
- }
- var reverse = Array.prototype.reverse;
- /**
- * Creates a function which is a composition of the passed asynchronous
- * functions. Each function consumes the return value of the function that
- * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
- * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name compose
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @example
- *
- * function add1(n, callback) {
- * setTimeout(function () {
- * callback(null, n + 1);
- * }, 10);
- * }
- *
- * function mul3(n, callback) {
- * setTimeout(function () {
- * callback(null, n * 3);
- * }, 10);
- * }
- *
- * var add1mul3 = async.compose(mul3, add1);
- * add1mul3(4, function (err, result) {
- * // result now equals 15
- * });
- */
- function compose() /* functions... */{
- return seq.apply(null, reverse.call(arguments));
- }
- function concat$1(eachfn, arr, fn, callback) {
- var result = [];
- eachfn(arr, function (x, index, cb) {
- fn(x, function (err, y) {
- result = result.concat(y || []);
- cb(err);
- });
- }, function (err) {
- callback(err, result);
- });
- }
- /**
- * Like `each`, except that it passes the key (or index) as the second argument
- * to the iteratee.
- *
- * @name eachOf
- * @static
- * @memberOf async
- * @alias forEachOf
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
- * var configs = {};
- *
- * async.forEachOf(obj, function (value, key, callback) {
- * fs.readFile(__dirname + value, "utf8", function (err, data) {
- * if (err) return callback(err);
- * try {
- * configs[key] = JSON.parse(data);
- * } catch (e) {
- * return callback(e);
- * }
- * callback();
- * });
- * }, function (err) {
- * if (err) console.error(err.message);
- * // configs is now a map of JSON data
- * doSomethingWith(configs);
- * });
- */
- var eachOf = doLimit(eachOfLimit, Infinity);
- function doParallel(fn) {
- return function (obj, iteratee, callback) {
- return fn(eachOf, obj, iteratee, callback);
- };
- }
- /**
- * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
- * the concatenated list. The `iteratee`s are called in parallel, and the
- * results are concatenated as they return. There is no guarantee that the
- * results array will be returned in the original order of `coll` passed to the
- * `iteratee` function.
- *
- * @name concat
- * @static
- * @memberOf async
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- * @example
- *
- * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
- * // files is now a list of filenames that exist in the 3 directories
- * });
- */
- var concat = doParallel(concat$1);
- function doSeries(fn) {
- return function (obj, iteratee, callback) {
- return fn(eachOfSeries, obj, iteratee, callback);
- };
- }
- /**
- * The same as `concat` but runs only a single async operation at a time.
- *
- * @name concatSeries
- * @static
- * @memberOf async
- * @see async.concat
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- */
- var concatSeries = doSeries(concat$1);
- /**
- * Returns a function that when called, calls-back with the values provided.
- * Useful as the first function in a `waterfall`, or for plugging values in to
- * `auto`.
- *
- * @name constant
- * @static
- * @memberOf async
- * @category Util
- * @param {...*} arguments... - Any number of arguments to automatically invoke
- * callback with.
- * @returns {Function} Returns a function that when invoked, automatically
- * invokes the callback with the previous given arguments.
- * @example
- *
- * async.waterfall([
- * async.constant(42),
- * function (value, next) {
- * // value === 42
- * },
- * //...
- * ], callback);
- *
- * async.waterfall([
- * async.constant(filename, "utf8"),
- * fs.readFile,
- * function (fileData, next) {
- * //...
- * }
- * //...
- * ], callback);
- *
- * async.auto({
- * hostname: async.constant("https://server.net/"),
- * port: findFreePort,
- * launchServer: ["hostname", "port", function (options, cb) {
- * startServer(options, cb);
- * }],
- * //...
- * }, callback);
- */
- var constant = rest(function (values) {
- var args = [null].concat(values);
- return initialParams(function (ignoredArgs, callback) {
- return callback.apply(this, args);
- });
- });
- function _createTester(eachfn, check, getResult) {
- return function (arr, limit, iteratee, cb) {
- function done(err) {
- if (cb) {
- if (err) {
- cb(err);
- } else {
- cb(null, getResult(false));
- }
- }
- }
- function wrappedIteratee(x, _, callback) {
- if (!cb) return callback();
- iteratee(x, function (err, v) {
- if (cb) {
- if (err) {
- cb(err);
- cb = iteratee = false;
- } else if (check(v)) {
- cb(null, getResult(true, x));
- cb = iteratee = false;
- }
- }
- callback();
- });
- }
- if (arguments.length > 3) {
- cb = cb || noop;
- eachfn(arr, limit, wrappedIteratee, done);
- } else {
- cb = iteratee;
- cb = cb || noop;
- iteratee = limit;
- eachfn(arr, wrappedIteratee, done);
- }
- };
- }
- function _findGetResult(v, x) {
- return x;
- }
- /**
- * Returns the first value in `coll` that passes an async truth test. The
- * `iteratee` is applied in parallel, meaning the first iteratee to return
- * `true` will fire the detect `callback` with that result. That means the
- * result might not be the first item in the original `coll` (in terms of order)
- * that passes the test.
- * If order within the original `coll` is important, then look at
- * `detectSeries`.
- *
- * @name detect
- * @static
- * @memberOf async
- * @alias find
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- * @example
- *
- * async.detect(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // result now equals the first file in the list that exists
- * });
- */
- var detect = _createTester(eachOf, identity, _findGetResult);
- /**
- * The same as `detect` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name detectLimit
- * @static
- * @memberOf async
- * @see async.detect
- * @alias findLimit
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
- var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
- /**
- * The same as `detect` but runs only a single async operation at a time.
- *
- * @name detectSeries
- * @static
- * @memberOf async
- * @see async.detect
- * @alias findSeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
- var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
- function consoleFunc(name) {
- return rest(function (fn, args) {
- fn.apply(null, args.concat([rest(function (err, args) {
- if (typeof console === 'object') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- } else if (console[name]) {
- arrayEach(args, function (x) {
- console[name](x);
- });
- }
- }
- })]));
- });
- }
- /**
- * Logs the result of an `async` function to the `console` using `console.dir`
- * to display the properties of the resulting object. Only works in Node.js or
- * in browsers that support `console.dir` and `console.error` (such as FF and
- * Chrome). If multiple arguments are returned from the async function,
- * `console.dir` is called on each argument in order.
- *
- * @name log
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, {hello: name});
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.dir(hello, 'world');
- * {hello: 'world'}
- */
- var dir = consoleFunc('dir');
- /**
- * Like {@link async.whilst}, except the `test` is an asynchronous function that
- * is passed a callback in the form of `function (err, truth)`. If error is
- * passed to `test` or `fn`, the main callback is immediately called with the
- * value of the error.
- *
- * @name during
- * @static
- * @memberOf async
- * @see async.whilst
- * @category Control Flow
- * @param {Function} test - asynchronous truth test to perform before each
- * execution of `fn`. Invoked with (callback).
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- * @example
- *
- * var count = 0;
- *
- * async.during(
- * function (callback) {
- * return callback(null, count < 5);
- * },
- * function (callback) {
- * count++;
- * setTimeout(callback, 1000);
- * },
- * function (err) {
- * // 5 seconds have passed
- * }
- * );
- */
- function during(test, iteratee, cb) {
- cb = cb || noop;
- var next = rest(function (err, args) {
- if (err) {
- cb(err);
- } else {
- args.push(check);
- test.apply(this, args);
- }
- });
- var check = function (err, truth) {
- if (err) return cb(err);
- if (!truth) return cb(null);
- iteratee(next);
- };
- test(check);
- }
- /**
- * The post-check version of {@link async.during}. To reflect the difference in
- * the order of operations, the arguments `test` and `fn` are switched.
- *
- * Also a version of {@link async.doWhilst} with asynchronous `test` function.
- * @name doDuring
- * @static
- * @memberOf async
- * @see async.during
- * @category Control Flow
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - asynchronous truth test to perform before each
- * execution of `fn`. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function doDuring(iteratee, test, cb) {
- var calls = 0;
- during(function (next) {
- if (calls++ < 1) return next(null, true);
- test.apply(this, arguments);
- }, iteratee, cb);
- }
- /**
- * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when
- * stopped, or an error occurs.
- *
- * @name whilst
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Function} test - synchronous truth test to perform before each
- * execution of `fn`. Invoked with ().
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- * @example
- *
- * var count = 0;
- * async.whilst(
- * function() { return count < 5; },
- * function(callback) {
- * count++;
- * setTimeout(function() {
- * callback(null, count);
- * }, 1000);
- * },
- * function (err, n) {
- * // 5 seconds have passed, n = 5
- * }
- * );
- */
- function whilst(test, iteratee, cb) {
- cb = cb || noop;
- if (!test()) return cb(null);
- var next = rest(function (err, args) {
- if (err) return cb(err);
- if (test.apply(this, args)) return iteratee(next);
- cb.apply(null, [null].concat(args));
- });
- iteratee(next);
- }
- /**
- * The post-check version of {@link async.whilst}. To reflect the difference in
- * the order of operations, the arguments `test` and `fn` are switched.
- *
- * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
- *
- * @name doWhilst
- * @static
- * @memberOf async
- * @see async.whilst
- * @category Control Flow
- * @param {Function} fn - A function which is called each time `test` passes.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - synchronous truth test to perform after each
- * execution of `fn`. Invoked with Invoked with the non-error callback results
- * of `fn`.
- * @param {Function} [callback] - A callback which is called after the test
- * function has failed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function doWhilst(iteratee, test, cb) {
- var calls = 0;
- return whilst(function () {
- return ++calls <= 1 || test.apply(this, arguments);
- }, iteratee, cb);
- }
- /**
- * Like {@link async.doWhilst}, except the `test` is inverted. Note the
- * argument ordering differs from `until`.
- *
- * @name doUntil
- * @static
- * @memberOf async
- * @see async.doWhilst
- * @category Control Flow
- * @param {Function} fn - A function which is called each time `test` fails.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} test - synchronous truth test to perform after each
- * execution of `fn`. Invoked with the non-error callback results of `fn`.
- * @param {Function} [callback] - A callback which is called after the test
- * function has passed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function doUntil(iteratee, test, cb) {
- return doWhilst(iteratee, function () {
- return !test.apply(this, arguments);
- }, cb);
- }
- function _withoutIndex(iteratee) {
- return function (value, index, callback) {
- return iteratee(value, callback);
- };
- }
- /**
- * The same as `each` but runs a maximum of `limit` async operations at a time.
- *
- * @name eachLimit
- * @static
- * @memberOf async
- * @see async.each
- * @alias forEachLimit
- * @category Collection
- * @param {Array|Object} coll - A colleciton to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each item in `coll`. The
- * iteratee is passed a `callback(err)` which must be called once it has
- * completed. If no error has occurred, the `callback` should be run without
- * arguments or with an explicit `null` argument. The array index is not passed
- * to the iteratee. Invoked with (item, callback). If you need the index, use
- * `eachOfLimit`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- function eachLimit(arr, limit, iteratee, cb) {
- return _eachOfLimit(limit)(arr, _withoutIndex(iteratee), cb);
- }
- /**
- * Applies the function `iteratee` to each item in `coll`, in parallel.
- * The `iteratee` is called with an item from the list, and a callback for when
- * it has finished. If the `iteratee` passes an error to its `callback`, the
- * main `callback` (for the `each` function) is immediately called with the
- * error.
- *
- * Note, that since this function applies `iteratee` to each item in parallel,
- * there is no guarantee that the iteratee functions will complete in order.
- *
- * @name each
- * @static
- * @memberOf async
- * @alias forEach
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item
- * in `coll`. The iteratee is passed a `callback(err)` which must be called once
- * it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is not
- * passed to the iteratee. Invoked with (item, callback). If you need the index,
- * use `eachOf`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * // assuming openFiles is an array of file names and saveFile is a function
- * // to save the modified contents of that file:
- *
- * async.each(openFiles, saveFile, function(err){
- * // if any of the saves produced an error, err would equal that error
- * });
- *
- * // assuming openFiles is an array of file names
- * async.each(openFiles, function(file, callback) {
- *
- * // Perform operation on file here.
- * console.log('Processing file ' + file);
- *
- * if( file.length > 32 ) {
- * console.log('This file name is too long');
- * callback('File name too long');
- * } else {
- * // Do work to process file here
- * console.log('File processed');
- * callback();
- * }
- * }, function(err) {
- * // if any of the file processing produced an error, err would equal that error
- * if( err ) {
- * // One of the iterations produced an error.
- * // All processing will now stop.
- * console.log('A file failed to process');
- * } else {
- * console.log('All files have been processed successfully');
- * }
- * });
- */
- var each = doLimit(eachLimit, Infinity);
- /**
- * The same as `each` but runs only a single async operation at a time.
- *
- * @name eachSeries
- * @static
- * @memberOf async
- * @see async.each
- * @alias forEachSeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The iteratee is passed a `callback(err)` which must be called
- * once it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is
- * not passed to the iteratee. Invoked with (item, callback). If you need the
- * index, use `eachOfSeries`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- var eachSeries = doLimit(eachLimit, 1);
- /**
- * Wrap an async function and ensure it calls its callback on a later tick of
- * the event loop. If the function already calls its callback on a next tick,
- * no extra deferral is added. This is useful for preventing stack overflows
- * (`RangeError: Maximum call stack size exceeded`) and generally keeping
- * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
- * contained.
- *
- * @name ensureAsync
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} fn - an async function, one that expects a node-style
- * callback as its last argument.
- * @returns {Function} Returns a wrapped function with the exact same call
- * signature as the function passed in.
- * @example
- *
- * function sometimesAsync(arg, callback) {
- * if (cache[arg]) {
- * return callback(null, cache[arg]); // this would be synchronous!!
- * } else {
- * doSomeIO(arg, callback); // this IO would be asynchronous
- * }
- * }
- *
- * // this has a risk of stack overflows if many results are cached in a row
- * async.mapSeries(args, sometimesAsync, done);
- *
- * // this will defer sometimesAsync's callback if necessary,
- * // preventing stack overflows
- * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
- */
- function ensureAsync(fn) {
- return initialParams(function (args, callback) {
- var sync = true;
- args.push(function () {
- var innerArgs = arguments;
- if (sync) {
- setImmediate$1(function () {
- callback.apply(null, innerArgs);
- });
- } else {
- callback.apply(null, innerArgs);
- }
- });
- fn.apply(this, args);
- sync = false;
- });
- }
- function notId(v) {
- return !v;
- }
- /**
- * The same as `every` but runs a maximum of `limit` async operations at a time.
- *
- * @name everyLimit
- * @static
- * @memberOf async
- * @see async.every
- * @alias allLimit
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
- var everyLimit = _createTester(eachOfLimit, notId, notId);
- /**
- * Returns `true` if every element in `coll` satisfies an async test. If any
- * iteratee call returns `false`, the main `callback` is immediately called.
- *
- * @name every
- * @static
- * @memberOf async
- * @alias all
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- * @example
- *
- * async.every(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then every file exists
- * });
- */
- var every = doLimit(everyLimit, Infinity);
- /**
- * The same as `every` but runs only a single async operation at a time.
- *
- * @name everySeries
- * @static
- * @memberOf async
- * @see async.every
- * @alias allSeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
- var everySeries = doLimit(everyLimit, 1);
- function _filter(eachfn, arr, iteratee, callback) {
- var results = [];
- eachfn(arr, function (x, index, callback) {
- iteratee(x, function (err, v) {
- if (err) {
- callback(err);
- } else {
- if (v) {
- results.push({ index: index, value: x });
- }
- callback();
- }
- });
- }, function (err) {
- if (err) {
- callback(err);
- } else {
- callback(null, arrayMap(results.sort(function (a, b) {
- return a.index - b.index;
- }), baseProperty('value')));
- }
- });
- }
- /**
- * The same as `filter` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name filterLimit
- * @static
- * @memberOf async
- * @see async.filter
- * @alias selectLimit
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var filterLimit = doParallelLimit(_filter);
- /**
- * Returns a new array of all the values in `coll` which pass an async truth
- * test. This operation is performed in parallel, but the results array will be
- * in the same order as the original.
- *
- * @name filter
- * @static
- * @memberOf async
- * @alias select
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.filter(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of the existing files
- * });
- */
- var filter = doLimit(filterLimit, Infinity);
- /**
- * The same as `filter` but runs only a single async operation at a time.
- *
- * @name filterSeries
- * @static
- * @memberOf async
- * @see async.filter
- * @alias selectSeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results)
- */
- var filterSeries = doLimit(filterLimit, 1);
- /**
- * Calls the asynchronous function `fn` with a callback parameter that allows it
- * to call itself again, in series, indefinitely.
- * If an error is passed to the
- * callback then `errback` is called with the error, and execution stops,
- * otherwise it will never be called.
- *
- * @name forever
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Function} fn - a function to call repeatedly. Invoked with (next).
- * @param {Function} [errback] - when `fn` passes an error to it's callback,
- * this function will be called, and execution stops. Invoked with (err).
- * @example
- *
- * async.forever(
- * function(next) {
- * // next is suitable for passing to things that need a callback(err [, whatever]);
- * // it will result in this function being called again.
- * },
- * function(err) {
- * // if next is called with a value in its first parameter, it will appear
- * // in here as 'err', and execution will stop.
- * }
- * );
- */
- function forever(fn, cb) {
- var done = onlyOnce(cb || noop);
- var task = ensureAsync(fn);
- function next(err) {
- if (err) return done(err);
- task(next);
- }
- next();
- }
- /**
- * Creates an iterator function which calls the next function in the `tasks`
- * array, returning a continuation to call the next one after that. It's also
- * possible to “peek” at the next iterator with `iterator.next()`.
- *
- * This function is used internally by the `async` module, but can be useful
- * when you want to manually control the flow of functions in series.
- *
- * @name iterator
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array} tasks - An array of functions to run.
- * @returns The next function to run in the series.
- * @example
- *
- * var iterator = async.iterator([
- * function() { sys.p('one'); },
- * function() { sys.p('two'); },
- * function() { sys.p('three'); }
- * ]);
- *
- * node> var iterator2 = iterator();
- * 'one'
- * node> var iterator3 = iterator2();
- * 'two'
- * node> iterator3();
- * 'three'
- * node> var nextfn = iterator2.next();
- * node> nextfn();
- * 'three'
- */
- function iterator$1 (tasks) {
- function makeCallback(index) {
- function fn() {
- if (tasks.length) {
- tasks[index].apply(null, arguments);
- }
- return fn.next();
- }
- fn.next = function () {
- return index < tasks.length - 1 ? makeCallback(index + 1) : null;
- };
- return fn;
- }
- return makeCallback(0);
- }
- /**
- * Logs the result of an `async` function to the `console`. Only works in
- * Node.js or in browsers that support `console.log` and `console.error` (such
- * as FF and Chrome). If multiple arguments are returned from the async
- * function, `console.log` is called on each argument in order.
- *
- * @name log
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, 'hello ' + name);
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.log(hello, 'world');
- * 'hello world'
- */
- var log = consoleFunc('log');
- /**
- * The same as `mapValues` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name mapValuesLimit
- * @static
- * @memberOf async
- * @see async.mapValues
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
- */
- function mapValuesLimit(obj, limit, iteratee, callback) {
- var newObj = {};
- eachOfLimit(obj, limit, function (val, key, next) {
- iteratee(val, key, function (err, result) {
- if (err) return next(err);
- newObj[key] = result;
- next();
- });
- }, function (err) {
- callback(err, newObj);
- });
- }
- /**
- * A relative of `map`, designed for use with objects.
- *
- * Produces a new Object by mapping each value of `obj` through the `iteratee`
- * function. The `iteratee` is called each `value` and `key` from `obj` and a
- * callback for when it has finished processing. Each of these callbacks takes
- * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
- * passes an error to its callback, the main `callback` (for the `mapValues`
- * function) is immediately called with the error.
- *
- * Note, the order of the keys in the result is not guaranteed. The keys will
- * be roughly in the order they complete, (but this is very engine-specific)
- *
- * @name mapValues
- * @static
- * @memberOf async
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value and key in
- * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
- * called once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `obj`. Invoked with (err, result).
- * @example
- *
- * async.mapValues({
- * f1: 'file1',
- * f2: 'file2',
- * f3: 'file3'
- * }, fs.stat, function(err, result) {
- * // results is now a map of stats for each file, e.g.
- * // {
- * // f1: [stats for file1],
- * // f2: [stats for file2],
- * // f3: [stats for file3]
- * // }
- * });
- */
- var mapValues = doLimit(mapValuesLimit, Infinity);
- /**
- * The same as `mapValues` but runs only a single async operation at a time.
- *
- * @name mapValuesSeries
- * @static
- * @memberOf async
- * @see async.mapValues
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Result is an object of the
- * transformed values from the `obj`. Invoked with (err, result).
- */
- var mapValuesSeries = doLimit(mapValuesLimit, 1);
- function has(obj, key) {
- return key in obj;
- }
- /**
- * Caches the results of an `async` function. When creating a hash to store
- * function results against, the callback is omitted from the hash and an
- * optional hash function can be used.
- *
- * If no hash function is specified, the first argument is used as a hash key,
- * which may work reasonably if it is a string or a data type that converts to a
- * distinct string. Note that objects and arrays will not behave reasonably.
- * Neither will cases where the other arguments are significant. In such cases,
- * specify your own hash function.
- *
- * The cache of results is exposed as the `memo` property of the function
- * returned by `memoize`.
- *
- * @name memoize
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} fn - The function to proxy and cache results from.
- * @param {Function} hasher - An optional function for generating a custom hash
- * for storing results. It has all the arguments applied to it apart from the
- * callback, and must be synchronous.
- * @example
- *
- * var slow_fn = function(name, callback) {
- * // do something
- * callback(null, result);
- * };
- * var fn = async.memoize(slow_fn);
- *
- * // fn can now be used as if it were slow_fn
- * fn('some name', function() {
- * // callback
- * });
- */
- function memoize$1(fn, hasher) {
- var memo = Object.create(null);
- var queues = Object.create(null);
- hasher = hasher || identity;
- var memoized = initialParams(function memoized(args, callback) {
- var key = hasher.apply(null, args);
- if (has(memo, key)) {
- setImmediate$1(function () {
- callback.apply(null, memo[key]);
- });
- } else if (has(queues, key)) {
- queues[key].push(callback);
- } else {
- queues[key] = [callback];
- fn.apply(null, args.concat([rest(function (args) {
- memo[key] = args;
- var q = queues[key];
- delete queues[key];
- for (var i = 0, l = q.length; i < l; i++) {
- q[i].apply(null, args);
- }
- })]));
- }
- });
- memoized.memo = memo;
- memoized.unmemoized = fn;
- return memoized;
- }
- /**
- * Calls `callback` on a later loop around the event loop. In Node.js this just
- * calls `setImmediate`. In the browser it will use `setImmediate` if
- * available, otherwise `setTimeout(callback, 0)`, which means other higher
- * priority events may precede the execution of `callback`.
- *
- * This is used internally for browser-compatibility purposes.
- *
- * @name nextTick
- * @static
- * @memberOf async
- * @alias setImmediate
- * @category Util
- * @param {Function} callback - The function to call on a later loop around
- * the event loop. Invoked with (args...).
- * @param {...*} args... - any number of additional arguments to pass to the
- * callback on the next tick.
- * @example
- *
- * var call_order = [];
- * async.nextTick(function() {
- * call_order.push('two');
- * // call_order now equals ['one','two']
- * });
- * call_order.push('one');
- *
- * async.setImmediate(function (a, b, c) {
- * // a, b, and c equal 1, 2, and 3
- * }, 1, 2, 3);
- */
- var _defer$1;
- if (hasNextTick) {
- _defer$1 = process.nextTick;
- } else if (hasSetImmediate) {
- _defer$1 = setImmediate;
- } else {
- _defer$1 = fallback;
- }
- var nextTick = wrap(_defer$1);
- function _parallel(eachfn, tasks, callback) {
- callback = callback || noop;
- var results = isArrayLike(tasks) ? [] : {};
- eachfn(tasks, function (task, key, callback) {
- task(rest(function (err, args) {
- if (args.length <= 1) {
- args = args[0];
- }
- results[key] = args;
- callback(err);
- }));
- }, function (err) {
- callback(err, results);
- });
- }
- /**
- * The same as `parallel` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name parallel
- * @static
- * @memberOf async
- * @see async.parallel
- * @category Control Flow
- * @param {Array|Collection} tasks - A collection containing functions to run.
- * Each function is passed a `callback(err, result)` which it must call on
- * completion with an error `err` (which can be `null`) and an optional `result`
- * value.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed successfully. This function gets a results array
- * (or object) containing all the result arguments passed to the task callbacks.
- * Invoked with (err, results).
- */
- function parallelLimit(tasks, limit, cb) {
- return _parallel(_eachOfLimit(limit), tasks, cb);
- }
- /**
- * Run the `tasks` collection of functions in parallel, without waiting until
- * the previous function has completed. If any of the functions pass an error to
- * its callback, the main `callback` is immediately called with the value of the
- * error. Once the `tasks` have completed, the results are passed to the final
- * `callback` as an array.
- *
- * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
- * parallel execution of code. If your tasks do not use any timers or perform
- * any I/O, they will actually be executed in series. Any synchronous setup
- * sections for each task will happen one after the other. JavaScript remains
- * single-threaded.
- *
- * It is also possible to use an object instead of an array. Each property will
- * be run as a function and the results will be passed to the final `callback`
- * as an object instead of an array. This can be a more readable way of handling
- * results from {@link async.parallel}.
- *
- * @name parallel
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array|Object} tasks - A collection containing functions to run.
- * Each function is passed a `callback(err, result)` which it must call on
- * completion with an error `err` (which can be `null`) and an optional `result`
- * value.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed successfully. This function gets a results array
- * (or object) containing all the result arguments passed to the task callbacks.
- * Invoked with (err, results).
- * @example
- * async.parallel([
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ],
- * // optional callback
- * function(err, results) {
- * // the results array will equal ['one','two'] even though
- * // the second function had a shorter timeout.
- * });
- *
- * // an example using an object instead of an array
- * async.parallel({
- * one: function(callback) {
- * setTimeout(function() {
- * callback(null, 1);
- * }, 200);
- * },
- * two: function(callback) {
- * setTimeout(function() {
- * callback(null, 2);
- * }, 100);
- * }
- * }, function(err, results) {
- * // results is now equals to: {one: 1, two: 2}
- * });
- */
- var parallel = doLimit(parallelLimit, Infinity);
- /**
- * A queue of tasks for the worker function to complete.
- * @typedef {Object} queue
- * @property {Function} length - a function returning the number of items
- * waiting to be processed. Invoke with ().
- * @property {Function} started - a function returning whether or not any
- * items have been pushed and processed by the queue. Invoke with ().
- * @property {Function} running - a function returning the number of items
- * currently being processed. Invoke with ().
- * @property {Function} workersList - a function returning the array of items
- * currently being processed. Invoke with ().
- * @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with ().
- * @property {number} concurrency - an integer for determining how many `worker`
- * functions should be run in parallel. This property can be changed after a
- * `queue` is created to alter the concurrency on-the-fly.
- * @property {Function} push - add a new task to the `queue`. Calls `callback`
- * once the `worker` has finished processing the task. Instead of a single task,
- * a `tasks` array can be submitted. The respective callback is used for every
- * task in the list. Invoke with (task, [callback]),
- * @property {Function} unshift - add a new task to the front of the `queue`.
- * Invoke with (task, [callback]).
- * @property {Function} saturated - a callback that is called when the number of
- * running workers hits the `concurrency` limit, and further tasks will be
- * queued.
- * @property {Function} unsaturated - a callback that is called when the number
- * of running workers is less than the `concurrency` & `buffer` limits, and
- * further tasks will not be queued.
- * @property {number} buffer - A minimum threshold buffer in order to say that
- * the `queue` is `unsaturated`.
- * @property {Function} empty - a callback that is called when the last item
- * from the `queue` is given to a `worker`.
- * @property {Function} drain - a callback that is called when the last item
- * from the `queue` has returned from the `worker`.
- * @property {Function} error - a callback that is called when a task errors.
- * Has the signature `function(error, task)`.
- * @property {boolean} paused - a boolean for determining whether the queue is
- * in a paused state.
- * @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with ().
- * @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with ().
- * @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
- */
- /**
- * Creates a `queue` object with the specified `concurrency`. Tasks added to the
- * `queue` are processed in parallel (up to the `concurrency` limit). If all
- * `worker`s are in progress, the task is queued until one becomes available.
- * Once a `worker` completes a `task`, that `task`'s callback is called.
- *
- * @name queue
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} [concurrency=1] - An `integer` for determining how many
- * `worker` functions should be run in parallel. If omitted, the concurrency
- * defaults to `1`. If the concurrency is `0`, an error is thrown.
- * @returns {queue} A queue object to manage the tasks. Callbacks can
- * attached as certain properties to listen for specific events during the
- * lifecycle of the queue.
- * @example
- *
- * // create a queue object with concurrency 2
- * var q = async.queue(function(task, callback) {
- * console.log('hello ' + task.name);
- * callback();
- * }, 2);
- *
- * // assign a callback
- * q.drain = function() {
- * console.log('all items have been processed');
- * };
- *
- * // add some items to the queue
- * q.push({name: 'foo'}, function(err) {
- * console.log('finished processing foo');
- * });
- * q.push({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- *
- * // add some items to the queue (batch-wise)
- * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
- * console.log('finished processing item');
- * });
- *
- * // add some items to the front of the queue
- * q.unshift({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- */
- function queue$1 (worker, concurrency) {
- return queue(function (items, cb) {
- worker(items[0], cb);
- }, concurrency, 1);
- }
- /**
- * The same as {@link async.queue} only tasks are assigned a priority and
- * completed in ascending priority order.
- *
- * @name priorityQueue
- * @static
- * @memberOf async
- * @see async.queue
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} concurrency - An `integer` for determining how many `worker`
- * functions should be run in parallel. If omitted, the concurrency defaults to
- * `1`. If the concurrency is `0`, an error is thrown.
- * @returns {queue} A priorityQueue object to manage the tasks. There are two
- * differences between `queue` and `priorityQueue` objects:
- * * `push(task, priority, [callback])` - `priority` should be a number. If an
- * array of `tasks` is given, all tasks will be assigned the same priority.
- * * The `unshift` method was removed.
- */
- function priorityQueue (worker, concurrency) {
- function _compareTasks(a, b) {
- return a.priority - b.priority;
- }
- function _binarySearch(sequence, item, compare) {
- var beg = -1,
- end = sequence.length - 1;
- while (beg < end) {
- var mid = beg + (end - beg + 1 >>> 1);
- if (compare(item, sequence[mid]) >= 0) {
- beg = mid;
- } else {
- end = mid - 1;
- }
- }
- return beg;
- }
- function _insert(q, data, priority, callback) {
- if (callback != null && typeof callback !== 'function') {
- throw new Error('task callback must be a function');
- }
- q.started = true;
- if (!isArray(data)) {
- data = [data];
- }
- if (data.length === 0) {
- // call drain immediately if there are no tasks
- return setImmediate$1(function () {
- q.drain();
- });
- }
- arrayEach(data, function (task) {
- var item = {
- data: task,
- priority: priority,
- callback: typeof callback === 'function' ? callback : noop
- };
- q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);
- setImmediate$1(q.process);
- });
- }
- // Start with a normal queue
- var q = queue$1(worker, concurrency);
- // Override push to accept second parameter representing priority
- q.push = function (data, priority, callback) {
- _insert(q, data, priority, callback);
- };
- // Remove unshift function
- delete q.unshift;
- return q;
- }
- /**
- * Creates a `baseEach` or `baseEachRight` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseEach(eachFunc, fromRight) {
- return function(collection, iteratee) {
- if (collection == null) {
- return collection;
- }
- if (!isArrayLike(collection)) {
- return eachFunc(collection, iteratee);
- }
- var length = collection.length,
- index = fromRight ? length : -1,
- iterable = Object(collection);
- while ((fromRight ? index-- : ++index < length)) {
- if (iteratee(iterable[index], index, iterable) === false) {
- break;
- }
- }
- return collection;
- };
- }
- /**
- * The base implementation of `_.forEach` without support for iteratee shorthands.
- *
- * @private
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object} Returns `collection`.
- */
- var baseEach = createBaseEach(baseForOwn);
- /**
- * Iterates over elements of `collection` and invokes `iteratee` for each element.
- * The iteratee is invoked with three arguments: (value, index|key, collection).
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * **Note:** As with other "Collections" methods, objects with a "length"
- * property are iterated like arrays. To avoid this behavior use `_.forIn`
- * or `_.forOwn` for object iteration.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @alias each
- * @category Collection
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Array|Object} Returns `collection`.
- * @see _.forEachRight
- * @example
- *
- * _([1, 2]).forEach(function(value) {
- * console.log(value);
- * });
- * // => Logs `1` then `2`.
- *
- * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
- * console.log(key);
- * });
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
- */
- function forEach(collection, iteratee) {
- var func = isArray(collection) ? arrayEach : baseEach;
- return func(collection, baseIteratee(iteratee, 3));
- }
- /**
- * Runs the `tasks` array of functions in parallel, without waiting until the
- * previous function has completed. Once any the `tasks` completed or pass an
- * error to its callback, the main `callback` is immediately called. It's
- * equivalent to `Promise.race()`.
- *
- * @name race
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array} tasks - An array containing functions to run. Each function
- * is passed a `callback(err, result)` which it must call on completion with an
- * error `err` (which can be `null`) and an optional `result` value.
- * @param {Function} callback - A callback to run once any of the functions have
- * completed. This function gets an error or result from the first function that
- * completed. Invoked with (err, result).
- * @example
- *
- * async.race([
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ],
- * // main callback
- * function(err, result) {
- * // the result will be equal to 'two' as it finishes earlier
- * });
- */
- function race(tasks, cb) {
- cb = once(cb || noop);
- if (!isArray(tasks)) return cb(new TypeError('First argument to race must be an array of functions'));
- if (!tasks.length) return cb();
- forEach(tasks, function (task) {
- task(cb);
- });
- }
- var slice = Array.prototype.slice;
- /**
- * Same as `reduce`, only operates on `coll` in reverse order.
- *
- * @name reduceRight
- * @static
- * @memberOf async
- * @see async.reduce
- * @alias foldr
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {*} memo - The initial state of the reduction.
- * @param {Function} iteratee - A function applied to each item in the
- * array to produce the next step in the reduction. The `iteratee` is passed a
- * `callback(err, reduction)` which accepts an optional error as its first
- * argument, and the state of the reduction as the second. If an error is
- * passed to the callback, the reduction is stopped and the main `callback` is
- * immediately called with the error. Invoked with (memo, item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the reduced value. Invoked with
- * (err, result).
- */
- function reduceRight(arr, memo, iteratee, cb) {
- var reversed = slice.call(arr).reverse();
- reduce(reversed, memo, iteratee, cb);
- }
- /**
- * Wraps the function in another function that always returns data even when it
- * errors.
- *
- * The object returned has either the property `error` or `value`.
- *
- * @name reflect
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} function - The function you want to wrap
- * @returns {Function} - A function that always passes null to it's callback as
- * the error. The second argument to the callback will be an `object` with
- * either an `error` or a `value` property.
- * @example
- *
- * async.parallel([
- * async.reflect(function(callback) {
- * // do some stuff ...
- * callback(null, 'one');
- * }),
- * async.reflect(function(callback) {
- * // do some more stuff but error ...
- * callback('bad stuff happened');
- * }),
- * async.reflect(function(callback) {
- * // do some more stuff ...
- * callback(null, 'two');
- * })
- * ],
- * // optional callback
- * function(err, results) {
- * // values
- * // results[0].value = 'one'
- * // results[1].error = 'bad stuff happened'
- * // results[2].value = 'two'
- * });
- */
- function reflect(fn) {
- return initialParams(function reflectOn(args, reflectCallback) {
- args.push(rest(function callback(err, cbArgs) {
- if (err) {
- reflectCallback(null, {
- error: err
- });
- } else {
- var value = null;
- if (cbArgs.length === 1) {
- value = cbArgs[0];
- } else if (cbArgs.length > 1) {
- value = cbArgs;
- }
- reflectCallback(null, {
- value: value
- });
- }
- }));
- return fn.apply(this, args);
- });
- }
- function reject$1(eachfn, arr, iteratee, callback) {
- _filter(eachfn, arr, function (value, cb) {
- iteratee(value, function (err, v) {
- if (err) {
- cb(err);
- } else {
- cb(null, !v);
- }
- });
- }, callback);
- }
- /**
- * The same as `reject` but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name rejectLimit
- * @static
- * @memberOf async
- * @see async.reject
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var rejectLimit = doParallelLimit(reject$1);
- /**
- * The opposite of `filter`. Removes values that pass an `async` truth test.
- *
- * @name reject
- * @static
- * @memberOf async
- * @see async.filter
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of missing files
- * createFiles(results);
- * });
- */
- var reject = doLimit(rejectLimit, Infinity);
- /**
- * A helper function that wraps an array of functions with reflect.
- *
- * @name reflectAll
- * @static
- * @memberOf async
- * @see async.reflect
- * @category Util
- * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
- * @returns {Array} Returns an array of functions, each function wrapped in
- * `async.reflect`
- * @example
- *
- * let tasks = [
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'one');
- * }, 200);
- * },
- * function(callback) {
- * // do some more stuff but error ...
- * callback(new Error('bad stuff happened'));
- * },
- * function(callback) {
- * setTimeout(function() {
- * callback(null, 'two');
- * }, 100);
- * }
- * ];
- *
- * async.parallel(async.reflectAll(tasks),
- * // optional callback
- * function(err, results) {
- * // values
- * // results[0].value = 'one'
- * // results[1].error = Error('bad stuff happened')
- * // results[2].value = 'two'
- * });
- */
- function reflectAll(tasks) {
- return tasks.map(reflect);
- }
- /**
- * The same as `reject` but runs only a single async operation at a time.
- *
- * @name rejectSeries
- * @static
- * @memberOf async
- * @see async.reject
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
- var rejectSeries = doLimit(rejectLimit, 1);
- /**
- * Run the functions in the `tasks` collection in series, each one running once
- * the previous function has completed. If any functions in the series pass an
- * error to its callback, no more functions are run, and `callback` is
- * immediately called with the value of the error. Otherwise, `callback`
- * receives an array of results when `tasks` have completed.
- *
- * It is also possible to use an object instead of an array. Each property will
- * be run as a function, and the results will be passed to the final `callback`
- * as an object instead of an array. This can be a more readable way of handling
- * results from {@link async.series}.
- *
- * **Note** that while many implementations preserve the order of object
- * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
- * explicitly states that
- *
- * > The mechanics and order of enumerating the properties is not specified.
- *
- * So if you rely on the order in which your series of functions are executed,
- * and want this to work on all platforms, consider using an array.
- *
- * @name series
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array|Object} tasks - A collection containing functions to run, each
- * function is passed a `callback(err, result)` it must call on completion with
- * an error `err` (which can be `null`) and an optional `result` value.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed. This function gets a results array (or object)
- * containing all the result arguments passed to the `task` callbacks. Invoked
- * with (err, result).
- * @example
- * async.series([
- * function(callback) {
- * // do some stuff ...
- * callback(null, 'one');
- * },
- * function(callback) {
- * // do some more stuff ...
- * callback(null, 'two');
- * }
- * ],
- * // optional callback
- * function(err, results) {
- * // results is now equal to ['one', 'two']
- * });
- *
- * async.series({
- * one: function(callback) {
- * setTimeout(function() {
- * callback(null, 1);
- * }, 200);
- * },
- * two: function(callback){
- * setTimeout(function() {
- * callback(null, 2);
- * }, 100);
- * }
- * }, function(err, results) {
- * // results is now equal to: {one: 1, two: 2}
- * });
- */
- function series(tasks, cb) {
- return _parallel(eachOfSeries, tasks, cb);
- }
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new constant function.
- * @example
- *
- * var objects = _.times(2, _.constant({ 'a': 1 }));
- *
- * console.log(objects);
- * // => [{ 'a': 1 }, { 'a': 1 }]
- *
- * console.log(objects[0] === objects[1]);
- * // => true
- */
- function constant$1(value) {
- return function() {
- return value;
- };
- }
- /**
- * Attempts to get a successful response from `task` no more than `times` times
- * before returning an error. If the task is successful, the `callback` will be
- * passed the result of the successful task. If all attempts fail, the callback
- * will be passed the error and result (if any) of the final attempt.
- *
- * @name retry
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
- * object with `times` and `interval` or a number.
- * * `times` - The number of attempts to make before giving up. The default
- * is `5`.
- * * `interval` - The time to wait between retries, in milliseconds. The
- * default is `0`. The interval may also be specified as a function of the
- * retry count (see example).
- * * If `opts` is a number, the number specifies the number of times to retry,
- * with the default interval of `0`.
- * @param {Function} task - A function which receives two arguments: (1) a
- * `callback(err, result)` which must be called when finished, passing `err`
- * (which can be `null`) and the `result` of the function's execution, and (2)
- * a `results` object, containing the results of the previously executed
- * functions (if nested inside another control flow). Invoked with
- * (callback, results).
- * @param {Function} [callback] - An optional callback which is called when the
- * task has succeeded, or after the final failed attempt. It receives the `err`
- * and `result` arguments of the last attempt at completing the `task`. Invoked
- * with (err, results).
- * @example
- *
- * // The `retry` function can be used as a stand-alone control flow by passing
- * // a callback, as shown below:
- *
- * // try calling apiMethod 3 times
- * async.retry(3, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod 3 times, waiting 200 ms between each retry
- * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod 10 times with exponential backoff
- * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
- * async.retry({
- * times: 10,
- * interval: function(retryCount) {
- * return 50 * Math.pow(2, retryCount);
- * }
- * }, apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // try calling apiMethod the default 5 times no delay between each retry
- * async.retry(apiMethod, function(err, result) {
- * // do something with the result
- * });
- *
- * // It can also be embedded within other control flow functions to retry
- * // individual methods that are not as reliable, like this:
- * async.auto({
- * users: api.getUsers.bind(api),
- * payments: async.retry(3, api.getPayments.bind(api))
- * }, function(err, results) {
- * // do something with the results
- * });
- */
- function retry(times, task, callback) {
- var DEFAULT_TIMES = 5;
- var DEFAULT_INTERVAL = 0;
- var opts = {
- times: DEFAULT_TIMES,
- intervalFunc: constant$1(DEFAULT_INTERVAL)
- };
- function parseTimes(acc, t) {
- if (typeof t === 'object') {
- acc.times = +t.times || DEFAULT_TIMES;
- acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL);
- } else if (typeof t === 'number' || typeof t === 'string') {
- acc.times = +t || DEFAULT_TIMES;
- } else {
- throw new Error("Invalid arguments for async.retry");
- }
- }
- if (arguments.length < 3 && typeof times === 'function') {
- callback = task || noop;
- task = times;
- } else {
- parseTimes(opts, times);
- callback = callback || noop;
- }
- if (typeof task !== 'function') {
- throw new Error("Invalid arguments for async.retry");
- }
- var attempts = [];
- for (var i = 1; i < opts.times + 1; i++) {
- var isFinalAttempt = i == opts.times;
- attempts.push(retryAttempt(isFinalAttempt));
- var interval = opts.intervalFunc(i);
- if (!isFinalAttempt && interval > 0) {
- attempts.push(retryInterval(interval));
- }
- }
- series(attempts, function (done, data) {
- data = data[data.length - 1];
- callback(data.err, data.result);
- });
- function retryAttempt(isFinalAttempt) {
- return function (seriesCallback) {
- task(function (err, result) {
- seriesCallback(!err || isFinalAttempt, {
- err: err,
- result: result
- });
- });
- };
- }
- function retryInterval(interval) {
- return function (seriesCallback) {
- setTimeout(function () {
- seriesCallback(null);
- }, interval);
- };
- }
- }
- /**
- * A close relative of `retry`. This method wraps a task and makes it
- * retryable, rather than immediately calling it with retries.
- *
- * @name retryable
- * @static
- * @memberOf async
- * @see async.retry
- * @category Control Flow
- * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
- * options, exactly the same as from `retry`
- * @param {Function} task - the asynchronous function to wrap
- * @returns {Functions} The wrapped function, which when invoked, will retry on
- * an error, based on the parameters specified in `opts`.
- * @example
- *
- * async.auto({
- * dep1: async.retryable(3, getFromFlakyService),
- * process: ["dep1", async.retryable(3, function (results, cb) {
- * maybeProcessData(results.dep1, cb);
- * })]
- * }, callback);
- */
- function retryable (opts, task) {
- if (!task) {
- task = opts;
- opts = null;
- }
- return initialParams(function (args, callback) {
- function taskFn(cb) {
- task.apply(null, args.concat([cb]));
- }
- if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
- });
- }
- /**
- * The same as `some` but runs a maximum of `limit` async operations at a time.
- *
- * @name someLimit
- * @static
- * @memberOf async
- * @see async.some
- * @alias anyLimit
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
- var someLimit = _createTester(eachOfLimit, Boolean, identity);
- /**
- * Returns `true` if at least one element in the `coll` satisfies an async test.
- * If any iteratee call returns `true`, the main `callback` is immediately
- * called.
- *
- * @name some
- * @static
- * @memberOf async
- * @alias any
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- * @example
- *
- * async.some(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then at least one of the files exists
- * });
- */
- var some = doLimit(someLimit, Infinity);
- /**
- * The same as `some` but runs only a single async operation at a time.
- *
- * @name someSeries
- * @static
- * @memberOf async
- * @see async.some
- * @alias anySeries
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
- var someSeries = doLimit(someLimit, 1);
- /**
- * Sorts a list by the results of running each `coll` value through an async
- * `iteratee`.
- *
- * @name sortBy
- * @static
- * @memberOf async
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, sortValue)` which must be called once
- * it has completed with an error (which can be `null`) and a value to use as
- * the sort criteria. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is the items
- * from the original `coll` sorted by the values returned by the `iteratee`
- * calls. Invoked with (err, results).
- * @example
- *
- * async.sortBy(['file1','file2','file3'], function(file, callback) {
- * fs.stat(file, function(err, stats) {
- * callback(err, stats.mtime);
- * });
- * }, function(err, results) {
- * // results is now the original array of files sorted by
- * // modified date
- * });
- *
- * // By modifying the callback parameter the
- * // sorting order can be influenced:
- *
- * // ascending order
- * async.sortBy([1,9,3,5], function(x, callback) {
- * callback(null, x);
- * }, function(err,result) {
- * // result callback
- * });
- *
- * // descending order
- * async.sortBy([1,9,3,5], function(x, callback) {
- * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
- * }, function(err,result) {
- * // result callback
- * });
- */
- function sortBy(arr, iteratee, cb) {
- map(arr, function (x, cb) {
- iteratee(x, function (err, criteria) {
- if (err) return cb(err);
- cb(null, { value: x, criteria: criteria });
- });
- }, function (err, results) {
- if (err) return cb(err);
- cb(null, arrayMap(results.sort(comparator), baseProperty('value')));
- });
- function comparator(left, right) {
- var a = left.criteria,
- b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }
- }
- /**
- * Sets a time limit on an asynchronous function. If the function does not call
- * its callback within the specified miliseconds, it will be called with a
- * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
- *
- * @name timeout
- * @static
- * @memberOf async
- * @category Util
- * @param {Function} function - The asynchronous function you want to set the
- * time limit.
- * @param {number} miliseconds - The specified time limit.
- * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
- * to timeout Error for more information..
- * @returns {Function} Returns a wrapped function that can be used with any of
- * the control flow functions.
- * @example
- *
- * async.timeout(function(callback) {
- * doAsyncTask(callback);
- * }, 1000);
- */
- function timeout(asyncFn, miliseconds, info) {
- var originalCallback, timer;
- var timedOut = false;
- function injectedCallback() {
- if (!timedOut) {
- originalCallback.apply(null, arguments);
- clearTimeout(timer);
- }
- }
- function timeoutCallback() {
- var name = asyncFn.name || 'anonymous';
- var error = new Error('Callback function "' + name + '" timed out.');
- error.code = 'ETIMEDOUT';
- if (info) {
- error.info = info;
- }
- timedOut = true;
- originalCallback(error);
- }
- return initialParams(function (args, origCallback) {
- originalCallback = origCallback;
- // setup timer and call original function
- timer = setTimeout(timeoutCallback, miliseconds);
- asyncFn.apply(null, args.concat(injectedCallback));
- });
- }
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeCeil = Math.ceil;
- var nativeMax$1 = Math.max;
- /**
- * The base implementation of `_.range` and `_.rangeRight` which doesn't
- * coerce arguments to numbers.
- *
- * @private
- * @param {number} start The start of the range.
- * @param {number} end The end of the range.
- * @param {number} step The value to increment or decrement by.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Array} Returns the range of numbers.
- */
- function baseRange(start, end, step, fromRight) {
- var index = -1,
- length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
- result = Array(length);
- while (length--) {
- result[fromRight ? length : ++index] = start;
- start += step;
- }
- return result;
- }
- /**
- * The same as {@link times} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name timesLimit
- * @static
- * @memberOf async
- * @see async.times
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
- */
- function timeLimit(count, limit, iteratee, cb) {
- return mapLimit(baseRange(0, count, 1), limit, iteratee, cb);
- }
- /**
- * Calls the `iteratee` function `n` times, and accumulates results in the same
- * manner you would use with {@link async.map}.
- *
- * @name times
- * @static
- * @memberOf async
- * @see async.map
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
- * @example
- *
- * // Pretend this is some complicated async factory
- * var createUser = function(id, callback) {
- * callback(null, {
- * id: 'user' + id
- * });
- * };
- *
- * // generate 5 users
- * async.times(5, function(n, next) {
- * createUser(n, function(err, user) {
- * next(err, user);
- * });
- * }, function(err, users) {
- * // we should now have 5 users
- * });
- */
- var times = doLimit(timeLimit, Infinity);
- /**
- * The same as {@link async.times} but runs only a single async operation at a time.
- *
- * @name timesSeries
- * @static
- * @memberOf async
- * @see async.times
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
- */
- var timesSeries = doLimit(timeLimit, 1);
- /**
- * A relative of `reduce`. Takes an Object or Array, and iterates over each
- * element in series, each step potentially mutating an `accumulator` value.
- * The type of the accumulator defaults to the type of collection passed in.
- *
- * @name transform
- * @static
- * @memberOf async
- * @category Collection
- * @param {Array|Object} coll - A collection to iterate over.
- * @param {*} [accumulator] - The initial state of the transform. If omitted,
- * it will default to an empty Object or Array, depending on the type of `coll`
- * @param {Function} iteratee - A function applied to each item in the
- * collection that potentially modifies the accumulator. The `iteratee` is
- * passed a `callback(err)` which accepts an optional error as its first
- * argument. If an error is passed to the callback, the transform is stopped
- * and the main `callback` is immediately called with the error.
- * Invoked with (accumulator, item, key, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the transformed accumulator.
- * Invoked with (err, result).
- * @example
- *
- * async.transform([1,2,3], function(acc, item, index, callback) {
- * // pointless async:
- * process.nextTick(function() {
- * acc.push(item * 2)
- * callback(null)
- * });
- * }, function(err, result) {
- * // result is now equal to [2, 4, 6]
- * });
- *
- * @example
- *
- * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
- * setImmediate(function () {
- * obj[key] = val * 2;
- * callback();
- * })
- * }, function (err, result) {
- * // result is equal to {a: 2, b: 4, c: 6}
- * })
- */
- function transform(arr, acc, iteratee, callback) {
- if (arguments.length === 3) {
- callback = iteratee;
- iteratee = acc;
- acc = isArray(arr) ? [] : {};
- }
- eachOf(arr, function (v, k, cb) {
- iteratee(acc, v, k, cb);
- }, function (err) {
- callback(err, acc);
- });
- }
- /**
- * Undoes a {@link async.memoize}d function, reverting it to the original,
- * unmemoized form. Handy for testing.
- *
- * @name unmemoize
- * @static
- * @memberOf async
- * @see async.memoize
- * @category Util
- * @param {Function} fn - the memoized function
- */
- function unmemoize(fn) {
- return function () {
- return (fn.unmemoized || fn).apply(null, arguments);
- };
- }
- /**
- * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
- * stopped, or an error occurs. `callback` will be passed an error and any
- * arguments passed to the final `fn`'s callback.
- *
- * The inverse of {@link async.whilst}.
- *
- * @name until
- * @static
- * @memberOf async
- * @see async.whilst
- * @category Control Flow
- * @param {Function} test - synchronous truth test to perform before each
- * execution of `fn`. Invoked with ().
- * @param {Function} fn - A function which is called each time `test` fails.
- * The function is passed a `callback(err)`, which must be called once it has
- * completed with an optional `err` argument. Invoked with (callback).
- * @param {Function} [callback] - A callback which is called after the test
- * function has passed and repeated execution of `fn` has stopped. `callback`
- * will be passed an error and any arguments passed to the final `fn`'s
- * callback. Invoked with (err, [results]);
- */
- function until(test, iteratee, cb) {
- return whilst(function () {
- return !test.apply(this, arguments);
- }, iteratee, cb);
- }
- /**
- * Runs the `tasks` array of functions in series, each passing their results to
- * the next in the array. However, if any of the `tasks` pass an error to their
- * own callback, the next function is not executed, and the main `callback` is
- * immediately called with the error.
- *
- * @name waterfall
- * @static
- * @memberOf async
- * @category Control Flow
- * @param {Array} tasks - An array of functions to run, each function is passed
- * a `callback(err, result1, result2, ...)` it must call on completion. The
- * first argument is an error (which can be `null`) and any further arguments
- * will be passed as arguments in order to the next task.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed. This will be passed the results of the last task's
- * callback. Invoked with (err, [results]).
- * @example
- *
- * async.waterfall([
- * function(callback) {
- * callback(null, 'one', 'two');
- * },
- * function(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * },
- * function(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- *
- * // Or, with named functions:
- * async.waterfall([
- * myFirstFunction,
- * mySecondFunction,
- * myLastFunction,
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- * function myFirstFunction(callback) {
- * callback(null, 'one', 'two');
- * }
- * function mySecondFunction(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * }
- * function myLastFunction(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- */
- function waterfall (tasks, cb) {
- cb = once(cb || noop);
- if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
- if (!tasks.length) return cb();
- var taskIndex = 0;
- function nextTask(args) {
- if (taskIndex === tasks.length) {
- return cb.apply(null, [null].concat(args));
- }
- var taskCallback = onlyOnce(rest(function (err, args) {
- if (err) {
- return cb.apply(null, [err].concat(args));
- }
- nextTask(args);
- }));
- args.push(taskCallback);
- var task = tasks[taskIndex++];
- task.apply(null, args);
- }
- nextTask([]);
- }
- var index = {
- applyEach: applyEach,
- applyEachSeries: applyEachSeries,
- apply: apply$1,
- asyncify: asyncify,
- auto: auto,
- autoInject: autoInject,
- cargo: cargo,
- compose: compose,
- concat: concat,
- concatSeries: concatSeries,
- constant: constant,
- detect: detect,
- detectLimit: detectLimit,
- detectSeries: detectSeries,
- dir: dir,
- doDuring: doDuring,
- doUntil: doUntil,
- doWhilst: doWhilst,
- during: during,
- each: each,
- eachLimit: eachLimit,
- eachOf: eachOf,
- eachOfLimit: eachOfLimit,
- eachOfSeries: eachOfSeries,
- eachSeries: eachSeries,
- ensureAsync: ensureAsync,
- every: every,
- everyLimit: everyLimit,
- everySeries: everySeries,
- filter: filter,
- filterLimit: filterLimit,
- filterSeries: filterSeries,
- forever: forever,
- iterator: iterator$1,
- log: log,
- map: map,
- mapLimit: mapLimit,
- mapSeries: mapSeries,
- mapValues: mapValues,
- mapValuesLimit: mapValuesLimit,
- mapValuesSeries: mapValuesSeries,
- memoize: memoize$1,
- nextTick: nextTick,
- parallel: parallel,
- parallelLimit: parallelLimit,
- priorityQueue: priorityQueue,
- queue: queue$1,
- race: race,
- reduce: reduce,
- reduceRight: reduceRight,
- reflect: reflect,
- reflectAll: reflectAll,
- reject: reject,
- rejectLimit: rejectLimit,
- rejectSeries: rejectSeries,
- retry: retry,
- retryable: retryable,
- seq: seq,
- series: series,
- setImmediate: setImmediate$1,
- some: some,
- someLimit: someLimit,
- someSeries: someSeries,
- sortBy: sortBy,
- timeout: timeout,
- times: times,
- timesLimit: timeLimit,
- timesSeries: timesSeries,
- transform: transform,
- unmemoize: unmemoize,
- until: until,
- waterfall: waterfall,
- whilst: whilst,
- // aliases
- all: every,
- any: some,
- forEach: each,
- forEachSeries: eachSeries,
- forEachLimit: eachLimit,
- forEachOf: eachOf,
- forEachOfSeries: eachOfSeries,
- forEachOfLimit: eachOfLimit,
- inject: reduce,
- foldl: reduce,
- foldr: reduceRight,
- select: filter,
- selectLimit: filterLimit,
- selectSeries: filterSeries,
- wrapSync: asyncify
- };
- exports['default'] = index;
- exports.applyEach = applyEach;
- exports.applyEachSeries = applyEachSeries;
- exports.apply = apply$1;
- exports.asyncify = asyncify;
- exports.auto = auto;
- exports.autoInject = autoInject;
- exports.cargo = cargo;
- exports.compose = compose;
- exports.concat = concat;
- exports.concatSeries = concatSeries;
- exports.constant = constant;
- exports.detect = detect;
- exports.detectLimit = detectLimit;
- exports.detectSeries = detectSeries;
- exports.dir = dir;
- exports.doDuring = doDuring;
- exports.doUntil = doUntil;
- exports.doWhilst = doWhilst;
- exports.during = during;
- exports.each = each;
- exports.eachLimit = eachLimit;
- exports.eachOf = eachOf;
- exports.eachOfLimit = eachOfLimit;
- exports.eachOfSeries = eachOfSeries;
- exports.eachSeries = eachSeries;
- exports.ensureAsync = ensureAsync;
- exports.every = every;
- exports.everyLimit = everyLimit;
- exports.everySeries = everySeries;
- exports.filter = filter;
- exports.filterLimit = filterLimit;
- exports.filterSeries = filterSeries;
- exports.forever = forever;
- exports.iterator = iterator$1;
- exports.log = log;
- exports.map = map;
- exports.mapLimit = mapLimit;
- exports.mapSeries = mapSeries;
- exports.mapValues = mapValues;
- exports.mapValuesLimit = mapValuesLimit;
- exports.mapValuesSeries = mapValuesSeries;
- exports.memoize = memoize$1;
- exports.nextTick = nextTick;
- exports.parallel = parallel;
- exports.parallelLimit = parallelLimit;
- exports.priorityQueue = priorityQueue;
- exports.queue = queue$1;
- exports.race = race;
- exports.reduce = reduce;
- exports.reduceRight = reduceRight;
- exports.reflect = reflect;
- exports.reflectAll = reflectAll;
- exports.reject = reject;
- exports.rejectLimit = rejectLimit;
- exports.rejectSeries = rejectSeries;
- exports.retry = retry;
- exports.retryable = retryable;
- exports.seq = seq;
- exports.series = series;
- exports.setImmediate = setImmediate$1;
- exports.some = some;
- exports.someLimit = someLimit;
- exports.someSeries = someSeries;
- exports.sortBy = sortBy;
- exports.timeout = timeout;
- exports.times = times;
- exports.timesLimit = timeLimit;
- exports.timesSeries = timesSeries;
- exports.transform = transform;
- exports.unmemoize = unmemoize;
- exports.until = until;
- exports.waterfall = waterfall;
- exports.whilst = whilst;
- exports.all = every;
- exports.allLimit = everyLimit;
- exports.allSeries = everySeries;
- exports.any = some;
- exports.anyLimit = someLimit;
- exports.anySeries = someSeries;
- exports.find = detect;
- exports.findLimit = detectLimit;
- exports.findSeries = detectSeries;
- exports.forEach = each;
- exports.forEachSeries = eachSeries;
- exports.forEachLimit = eachLimit;
- exports.forEachOf = eachOf;
- exports.forEachOfSeries = eachOfSeries;
- exports.forEachOfLimit = eachOfLimit;
- exports.inject = reduce;
- exports.foldl = reduce;
- exports.foldr = reduceRight;
- exports.select = filter;
- exports.selectLimit = filterLimit;
- exports.selectSeries = filterSeries;
- exports.wrapSync = asyncify;
- }));
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(74).setImmediate, __webpack_require__(4)))
- /***/ },
- /* 146 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // Load modules
- var Hoek = __webpack_require__(68);
- // Declare internals
- var internals = {
- STATUS_CODES: Object.setPrototypeOf({
- '100': 'Continue',
- '101': 'Switching Protocols',
- '102': 'Processing',
- '200': 'OK',
- '201': 'Created',
- '202': 'Accepted',
- '203': 'Non-Authoritative Information',
- '204': 'No Content',
- '205': 'Reset Content',
- '206': 'Partial Content',
- '207': 'Multi-Status',
- '300': 'Multiple Choices',
- '301': 'Moved Permanently',
- '302': 'Moved Temporarily',
- '303': 'See Other',
- '304': 'Not Modified',
- '305': 'Use Proxy',
- '307': 'Temporary Redirect',
- '400': 'Bad Request',
- '401': 'Unauthorized',
- '402': 'Payment Required',
- '403': 'Forbidden',
- '404': 'Not Found',
- '405': 'Method Not Allowed',
- '406': 'Not Acceptable',
- '407': 'Proxy Authentication Required',
- '408': 'Request Time-out',
- '409': 'Conflict',
- '410': 'Gone',
- '411': 'Length Required',
- '412': 'Precondition Failed',
- '413': 'Request Entity Too Large',
- '414': 'Request-URI Too Large',
- '415': 'Unsupported Media Type',
- '416': 'Requested Range Not Satisfiable',
- '417': 'Expectation Failed',
- '418': 'I\'m a teapot',
- '422': 'Unprocessable Entity',
- '423': 'Locked',
- '424': 'Failed Dependency',
- '425': 'Unordered Collection',
- '426': 'Upgrade Required',
- '428': 'Precondition Required',
- '429': 'Too Many Requests',
- '431': 'Request Header Fields Too Large',
- '451': 'Unavailable For Legal Reasons',
- '500': 'Internal Server Error',
- '501': 'Not Implemented',
- '502': 'Bad Gateway',
- '503': 'Service Unavailable',
- '504': 'Gateway Time-out',
- '505': 'HTTP Version Not Supported',
- '506': 'Variant Also Negotiates',
- '507': 'Insufficient Storage',
- '509': 'Bandwidth Limit Exceeded',
- '510': 'Not Extended',
- '511': 'Network Authentication Required'
- }, null)
- };
- exports.wrap = function (error, statusCode, message) {
- Hoek.assert(error instanceof Error, 'Cannot wrap non-Error object');
- return error.isBoom ? error : internals.initialize(error, statusCode || 500, message);
- };
- exports.create = function (statusCode, message, data) {
- return internals.create(statusCode, message, data, exports.create);
- };
- internals.create = function (statusCode, message, data, ctor) {
- var error = new Error(message ? message : undefined); // Avoids settings null message
- Error.captureStackTrace(error, ctor); // Filter the stack to our external API
- error.data = data || null;
- internals.initialize(error, statusCode);
- return error;
- };
- internals.initialize = function (error, statusCode, message) {
- var numberCode = parseInt(statusCode, 10);
- Hoek.assert(!isNaN(numberCode) && numberCode >= 400, 'First argument must be a number (400+):', statusCode);
- error.isBoom = true;
- error.isServer = numberCode >= 500;
- if (!error.hasOwnProperty('data')) {
- error.data = null;
- }
- error.output = {
- statusCode: numberCode,
- payload: {},
- headers: {}
- };
- error.reformat = internals.reformat;
- error.reformat();
- if (!message && !error.message) {
- message = error.output.payload.error;
- }
- if (message) {
- error.message = message + (error.message ? ': ' + error.message : '');
- }
- return error;
- };
- internals.reformat = function () {
- this.output.payload.statusCode = this.output.statusCode;
- this.output.payload.error = internals.STATUS_CODES[this.output.statusCode] || 'Unknown';
- if (this.output.statusCode === 500) {
- this.output.payload.message = 'An internal server error occurred'; // Hide actual error from user
- } else if (this.message) {
- this.output.payload.message = this.message;
- }
- };
- // 4xx Client Errors
- exports.badRequest = function (message, data) {
- return internals.create(400, message, data, exports.badRequest);
- };
- exports.unauthorized = function (message, scheme, attributes) {
- // Or function (message, wwwAuthenticate[])
- var err = internals.create(401, message, undefined, exports.unauthorized);
- if (!scheme) {
- return err;
- }
- var wwwAuthenticate = '';
- if (typeof scheme === 'string') {
- // function (message, scheme, attributes)
- wwwAuthenticate = scheme;
- if (attributes || message) {
- err.output.payload.attributes = {};
- }
- if (attributes) {
- var names = Object.keys(attributes);
- for (var i = 0; i < names.length; ++i) {
- var name = names[i];
- if (i) {
- wwwAuthenticate = wwwAuthenticate + ',';
- }
- var value = attributes[name];
- if (value === null || value === undefined) {
- // Value can be zero
- value = '';
- }
- wwwAuthenticate = wwwAuthenticate + ' ' + name + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"';
- err.output.payload.attributes[name] = value;
- }
- }
- if (message) {
- if (attributes) {
- wwwAuthenticate = wwwAuthenticate + ',';
- }
- wwwAuthenticate = wwwAuthenticate + ' error="' + Hoek.escapeHeaderAttribute(message) + '"';
- err.output.payload.attributes.error = message;
- } else {
- err.isMissing = true;
- }
- } else {
- // function (message, wwwAuthenticate[])
- var wwwArray = scheme;
- for (var _i = 0; _i < wwwArray.length; ++_i) {
- if (_i) {
- wwwAuthenticate = wwwAuthenticate + ', ';
- }
- wwwAuthenticate = wwwAuthenticate + wwwArray[_i];
- }
- }
- err.output.headers['WWW-Authenticate'] = wwwAuthenticate;
- return err;
- };
- exports.forbidden = function (message, data) {
- return internals.create(403, message, data, exports.forbidden);
- };
- exports.notFound = function (message, data) {
- return internals.create(404, message, data, exports.notFound);
- };
- exports.methodNotAllowed = function (message, data) {
- return internals.create(405, message, data, exports.methodNotAllowed);
- };
- exports.notAcceptable = function (message, data) {
- return internals.create(406, message, data, exports.notAcceptable);
- };
- exports.proxyAuthRequired = function (message, data) {
- return internals.create(407, message, data, exports.proxyAuthRequired);
- };
- exports.clientTimeout = function (message, data) {
- return internals.create(408, message, data, exports.clientTimeout);
- };
- exports.conflict = function (message, data) {
- return internals.create(409, message, data, exports.conflict);
- };
- exports.resourceGone = function (message, data) {
- return internals.create(410, message, data, exports.resourceGone);
- };
- exports.lengthRequired = function (message, data) {
- return internals.create(411, message, data, exports.lengthRequired);
- };
- exports.preconditionFailed = function (message, data) {
- return internals.create(412, message, data, exports.preconditionFailed);
- };
- exports.entityTooLarge = function (message, data) {
- return internals.create(413, message, data, exports.entityTooLarge);
- };
- exports.uriTooLong = function (message, data) {
- return internals.create(414, message, data, exports.uriTooLong);
- };
- exports.unsupportedMediaType = function (message, data) {
- return internals.create(415, message, data, exports.unsupportedMediaType);
- };
- exports.rangeNotSatisfiable = function (message, data) {
- return internals.create(416, message, data, exports.rangeNotSatisfiable);
- };
- exports.expectationFailed = function (message, data) {
- return internals.create(417, message, data, exports.expectationFailed);
- };
- exports.badData = function (message, data) {
- return internals.create(422, message, data, exports.badData);
- };
- exports.locked = function (message, data) {
- return internals.create(423, message, data, exports.locked);
- };
- exports.preconditionRequired = function (message, data) {
- return internals.create(428, message, data, exports.preconditionRequired);
- };
- exports.tooManyRequests = function (message, data) {
- return internals.create(429, message, data, exports.tooManyRequests);
- };
- exports.illegal = function (message, data) {
- return internals.create(451, message, data, exports.illegal);
- };
- // 5xx Server Errors
- exports.internal = function (message, data, statusCode) {
- return internals.serverError(message, data, statusCode, exports.internal);
- };
- internals.serverError = function (message, data, statusCode, ctor) {
- var error = void 0;
- if (data instanceof Error) {
- error = exports.wrap(data, statusCode, message);
- } else {
- error = internals.create(statusCode || 500, message, undefined, ctor);
- error.data = data;
- }
- return error;
- };
- exports.notImplemented = function (message, data) {
- return internals.serverError(message, data, 501, exports.notImplemented);
- };
- exports.badGateway = function (message, data) {
- return internals.serverError(message, data, 502, exports.badGateway);
- };
- exports.serverUnavailable = function (message, data) {
- return internals.serverError(message, data, 503, exports.serverUnavailable);
- };
- // Deprecated
- exports.serverTimeout = exports.serverUnavailable;
- exports.gatewayTimeout = function (message, data) {
- return internals.serverError(message, data, 504, exports.gatewayTimeout);
- };
- exports.badImplementation = function (message, data) {
- var err = internals.serverError(message, data, 500, exports.badImplementation);
- err.isDeveloperError = true;
- return err;
- };
- /***/ },
- /* 147 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var util = __webpack_require__(244);
- // Immutable block of data
- function Block(data, type) {
- if (!data) {
- throw new Error('Block must be constructed with data');
- }
- if (!(this instanceof Block)) {
- return new Block(data);
- }
- if (data instanceof Buffer) {
- this.data = data;
- } else {
- this.data = new Buffer(data);
- }
- this.key = util.hash(this.data);
- this.type = type || 'protobuf';
- }
- Object.defineProperty(Block.prototype, 'extension', {
- get: function get() {
- switch (this.type) {
- case 'protobuf':
- return 'data';
- case 'ipld':
- return 'ipld';
- default:
- return this.type;
- }
- }
- });
- module.exports = Block;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 148 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var _createClass = function () {
- function defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
- }
- }return function (Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- var mh = __webpack_require__(96);
- // Link represents an IPFS Merkle DAG Link between Nodes.
- module.exports = function () {
- function DAGLink(name, size, hash) {
- _classCallCheck(this, DAGLink);
- this.name = name;
- this.size = size;
- if (typeof hash === 'string') {
- this.hash = mh.fromB58String(hash);
- } else if (Buffer.isBuffer(hash)) {
- this.hash = hash;
- }
- }
- _createClass(DAGLink, [{
- key: 'toJSON',
- value: function toJSON() {
- return {
- Name: this.name,
- Size: this.size,
- Hash: mh.toB58String(this.hash)
- };
- }
- }, {
- key: 'toString',
- value: function toString() {
- var hash = mh.toB58String(this.hash);
- return 'DAGLink <' + hash + ' - name: "' + this.name + '", size: ' + this.size + '>';
- }
- }]);
- return DAGLink;
- }();
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 149 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var _createClass = function () {
- function defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
- }
- }return function (Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- var protobuf = __webpack_require__(541);
- var stable = __webpack_require__(573);
- var path = __webpack_require__(43);
- var mh = __webpack_require__(96);
- var util = __webpack_require__(150);
- var DAGLink = __webpack_require__(148);
- var proto = protobuf(Buffer("Ly8gQW4gSVBGUyBNZXJrbGVEQUcgTGluawptZXNzYWdlIFBCTGluayB7CgogIC8vIG11bHRpaGFzaCBvZiB0aGUgdGFyZ2V0IG9iamVjdAogIG9wdGlvbmFsIGJ5dGVzIEhhc2ggPSAxOwoKICAvLyB1dGYgc3RyaW5nIG5hbWUuIHNob3VsZCBiZSB1bmlxdWUgcGVyIG9iamVjdAogIG9wdGlvbmFsIHN0cmluZyBOYW1lID0gMjsKCiAgLy8gY3VtdWxhdGl2ZSBzaXplIG9mIHRhcmdldCBvYmplY3QKICBvcHRpb25hbCB1aW50NjQgVHNpemUgPSAzOwp9CgovLyBBbiBJUEZTIE1lcmtsZURBRyBOb2RlCm1lc3NhZ2UgUEJOb2RlIHsKCiAgLy8gcmVmcyB0byBvdGhlciBvYmplY3RzCiAgcmVwZWF0ZWQgUEJMaW5rIExpbmtzID0gMjsKCiAgLy8gb3BhcXVlIHVzZXIgZGF0YQogIG9wdGlvbmFsIGJ5dGVzIERhdGEgPSAxOwp9Cg==","base64"));
- function linkSort(a, b) {
- return new Buffer(a.name, 'ascii').compare(new Buffer(b.name, 'ascii'));
- }
- // Helper method to get a protobuf object equivalent
- function toProtoBuf(node) {
- var pbn = {};
- if (node.data && node.data.length > 0) {
- pbn.Data = node.data;
- } else {
- pbn.Data = null; // new Buffer(0)
- }
- if (node.links.length > 0) {
- pbn.Links = node.links.map(function (link) {
- return {
- Hash: link.hash,
- Name: link.name,
- Tsize: link.size
- };
- });
- } else {
- pbn.Links = null;
- }
- return pbn;
- }
- module.exports = function () {
- function DAGNode(data, links) {
- var _this = this;
- _classCallCheck(this, DAGNode);
- this._cached = null;
- this._encoded = null;
- this.data = data;
- this.links = [];
- // ensure links are instances of DAGLink
- if (links) {
- links.forEach(function (l) {
- if (l.name && typeof l.toJSON === 'function') {
- _this.links.push(l);
- } else {
- _this.links.push(new DAGLink(l.Name, l.Size, l.Hash));
- }
- });
- stable.inplace(this.links, linkSort);
- }
- }
- // copy - returns a clone of the DAGNode
- _createClass(DAGNode, [{
- key: 'copy',
- value: function copy() {
- var clone = new DAGNode();
- if (this.data && this.data.length > 0) {
- var buf = new Buffer(this.data.length);
- this.data.copy(buf);
- clone.data = buf;
- }
- if (this.links.length > 0) {
- clone.links = this.links.slice();
- }
- return clone;
- }
- // addNodeLink - adds a DAGLink to this node that points to node by a name
- }, {
- key: 'addNodeLink',
- value: function addNodeLink(name, node) {
- if (typeof name !== 'string') {
- return;
- }
- var link = this.makeLink(node);
- link.name = name;
- this.addRawLink(link);
- }
- // addRawLink adds a Link to this node from a DAGLink
- }, {
- key: 'addRawLink',
- value: function addRawLink(link) {
- this._encoded = null;
- this.links.push(new DAGLink(link.name, link.size, link.hash));
- stable.inplace(this.links, linkSort);
- }
- // UpdateNodeLink return a copy of the node with the link name set to point to
- // that. If a link of the same name existed, it is replaced.
- // TODO this would make more sense as an utility
- }, {
- key: 'updateNodeLink',
- value: function updateNodeLink(name, node) {
- var newnode = this.copy();
- newnode.removeNodeLink(name);
- newnode.addNodeLink(name, node);
- return newnode;
- }
- // removeNodeLink removes a Link from this node based on name
- }, {
- key: 'removeNodeLink',
- value: function removeNodeLink(name) {
- this._encoded = null; // uncache
- this.links = this.links.filter(function (link) {
- if (link.name === name) {
- return false;
- } else {
- return true;
- }
- });
- }
- // removeNodeLink removes a Link from this node based on a multihash
- }, {
- key: 'removeNodeLinkByHash',
- value: function removeNodeLinkByHash(multihash) {
- this._encoded = null; // uncache
- this.links = this.links.filter(function (link) {
- if (link.hash.equals(multihash)) {
- return false;
- } else {
- return true;
- }
- });
- }
- // makeLink returns a DAGLink node from a DAGNode
- // TODO: this would make more sense as an utility
- }, {
- key: 'makeLink',
- value: function makeLink(node) {
- return new DAGLink(null, node.size(), node.multihash());
- }
- // multihash - returns the multihash value of this DAGNode
- }, {
- key: 'multihash',
- value: function multihash() {
- this.encoded();
- return this._cached;
- }
- // Size returns the total size of the data addressed by node,
- // including the total sizes of references.
- }, {
- key: 'size',
- value: function size() {
- var buf = this.encoded();
- if (!buf) {
- return 0;
- }
- return this.links.reduce(function (sum, l) {
- return sum + l.size;
- }, buf.length);
- }
- // Encoded returns the encoded raw data version of a Node instance.
- // It may use a cached encoded version, unless the force flag is given.
- }, {
- key: 'encoded',
- value: function encoded(force) {
- if (force || !this._encoded) {
- this._encoded = this.marshal();
- if (this._encoded) {
- this._cached = util.hash(this._encoded);
- }
- }
- return this._encoded;
- }
- // marshal - encodes the DAGNode into a probuf
- }, {
- key: 'marshal',
- value: function marshal() {
- return proto.PBNode.encode(toProtoBuf(this));
- }
- // unMarshal - decodes a protobuf into a DAGNode
- // TODO: this would make more sense as an utility
- }, {
- key: 'unMarshal',
- value: function unMarshal(data) {
- var pbn = proto.PBNode.decode(data);
- this.links = pbn.Links.map(function (link) {
- return new DAGLink(link.Name, link.Tsize, link.Hash);
- });
- stable.inplace(this.links, linkSort);
- this.data = pbn.Data || new Buffer(0);
- return this;
- }
- }, {
- key: 'toJSON',
- value: function toJSON() {
- return {
- Data: this.data,
- Links: this.links.map(function (l) {
- return l.toJSON();
- }),
- Hash: mh.toB58String(this.multihash()),
- Size: this.size()
- };
- }
- }, {
- key: 'toString',
- value: function toString() {
- var hash = mh.toB58String(this.multihash());
- return 'DAGNode <' + hash + ' - data: "' + this.data.toString() + '", links: ' + this.links.length + ', size: ' + this.size() + '>';
- }
- }]);
- return DAGNode;
- }();
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 150 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var multihashing = __webpack_require__(205);
- exports = module.exports;
- // Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits
- exports.hash = function (data) {
- return multihashing(data, 'sha2-256');
- };
- /***/ },
- /* 151 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- 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; };
- var hexTable = function () {
- var array = new Array(256);
- for (var i = 0; i < 256; ++i) {
- array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
- }
- return array;
- }();
- exports.arrayToObject = function (source, options) {
- var obj = options.plainObjects ? Object.create(null) : {};
- for (var i = 0; i < source.length; ++i) {
- if (typeof source[i] !== 'undefined') {
- obj[i] = source[i];
- }
- }
- return obj;
- };
- exports.merge = function (target, source, options) {
- if (!source) {
- return target;
- }
- if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') {
- if (Array.isArray(target)) {
- target.push(source);
- } else if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object') {
- target[source] = true;
- } else {
- return [target, source];
- }
- return target;
- }
- if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object') {
- return [target].concat(source);
- }
- var mergeTarget = target;
- if (Array.isArray(target) && !Array.isArray(source)) {
- mergeTarget = exports.arrayToObject(target, options);
- }
- return Object.keys(source).reduce(function (acc, key) {
- var value = source[key];
- if (Object.prototype.hasOwnProperty.call(acc, key)) {
- acc[key] = exports.merge(acc[key], value, options);
- } else {
- acc[key] = value;
- }
- return acc;
- }, mergeTarget);
- };
- exports.decode = function (str) {
- try {
- return decodeURIComponent(str.replace(/\+/g, ' '));
- } catch (e) {
- return str;
- }
- };
- exports.encode = function (str) {
- // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
- // It has been adapted here for stricter adherence to RFC 3986
- if (str.length === 0) {
- return str;
- }
- var string = typeof str === 'string' ? str : String(str);
- var out = '';
- for (var i = 0; i < string.length; ++i) {
- var c = string.charCodeAt(i);
- if (c === 0x2D || // -
- c === 0x2E || // .
- c === 0x5F || // _
- c === 0x7E || // ~
- c >= 0x30 && c <= 0x39 || // 0-9
- c >= 0x41 && c <= 0x5A || // a-z
- c >= 0x61 && c <= 0x7A // A-Z
- ) {
- out += string.charAt(i);
- continue;
- }
- if (c < 0x80) {
- out = out + hexTable[c];
- continue;
- }
- if (c < 0x800) {
- out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
- continue;
- }
- if (c < 0xD800 || c >= 0xE000) {
- out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
- continue;
- }
- i += 1;
- c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
- out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
- }
- return out;
- };
- exports.compact = function (obj, references) {
- if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
- return obj;
- }
- var refs = references || [];
- var lookup = refs.indexOf(obj);
- if (lookup !== -1) {
- return refs[lookup];
- }
- refs.push(obj);
- if (Array.isArray(obj)) {
- var compacted = [];
- for (var i = 0; i < obj.length; ++i) {
- if (obj[i] && _typeof(obj[i]) === 'object') {
- compacted.push(exports.compact(obj[i], refs));
- } else if (typeof obj[i] !== 'undefined') {
- compacted.push(obj[i]);
- }
- }
- return compacted;
- }
- var keys = Object.keys(obj);
- for (var j = 0; j < keys.length; ++j) {
- var key = keys[j];
- obj[key] = exports.compact(obj[key], refs);
- }
- return obj;
- };
- exports.isRegExp = function (obj) {
- return Object.prototype.toString.call(obj) === '[object RegExp]';
- };
- exports.isBuffer = function (obj) {
- if (obj === null || typeof obj === 'undefined') {
- return false;
- }
- return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
- };
- /***/ },
- /* 152 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process, Buffer) {'use strict';
- // Load modules
- var Events = __webpack_require__(30);
- var Url = __webpack_require__(226);
- var Http = __webpack_require__(220);
- var Https = __webpack_require__(510);
- var Stream = __webpack_require__(9);
- var Hoek = __webpack_require__(68);
- var Boom = __webpack_require__(146);
- var Payload = __webpack_require__(153);
- var Recorder = __webpack_require__(250);
- var Tap = __webpack_require__(251);
- // Declare internals
- var internals = {
- jsonRegex: /^application\/[a-z.+-]*json$/,
- shallowOptions: ['agent', 'payload', 'downstreamRes', 'beforeRedirect', 'redirected'],
- emitSymbol: Symbol.for('wreck')
- };
- process[internals.emitSymbol] = process[internals.emitSymbol] || new Events.EventEmitter();
- // new instance is exported as module.exports
- internals.Client = function (defaults) {
- // Use a single emitter instance for events
- Object.assign(this, process[internals.emitSymbol]);
- this.agents = {
- https: new Https.Agent({ maxSockets: Infinity }),
- http: new Http.Agent({ maxSockets: Infinity }),
- httpsAllowUnauthorized: new Https.Agent({ maxSockets: Infinity, rejectUnauthorized: false })
- };
- this._defaults = defaults || {};
- };
- Hoek.inherits(internals.Client, Events.EventEmitter);
- internals.Client.prototype.defaults = function (options) {
- options = Hoek.applyToDefaultsWithShallow(options, this._defaults, internals.shallowOptions);
- return new internals.Client(options);
- };
- internals.resolveUrl = function (baseUrl, path) {
- if (!path) {
- return baseUrl;
- }
- var parsedBase = Url.parse(baseUrl);
- var parsedPath = Url.parse(path);
- parsedBase.pathname = parsedBase.pathname + parsedPath.pathname;
- parsedBase.pathname = parsedBase.pathname.replace(/[/]{2,}/g, '/');
- parsedBase.search = parsedPath.search; // Always use the querystring from the path argument
- return Url.format(parsedBase);
- };
- internals.Client.prototype.request = function (method, url, options, callback, _trace) {
- var _this = this;
- options = Hoek.applyToDefaultsWithShallow(this._defaults, options || {}, internals.shallowOptions);
- 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');
- 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');
- Hoek.assert(options.beforeRedirect === undefined || options.beforeRedirect === null || typeof options.beforeRedirect === 'function', 'options.beforeRedirect must be a function');
- Hoek.assert(options.redirected === undefined || options.redirected === null || typeof options.redirected === 'function', 'options.redirected must be a function');
- if (options.baseUrl) {
- url = internals.resolveUrl(options.baseUrl, url);
- delete options.baseUrl;
- }
- var uri = Url.parse(url);
- if (options.socketPath) {
- uri.socketPath = options.socketPath;
- delete options.socketPath;
- }
- uri.method = method.toUpperCase();
- uri.headers = options.headers || {};
- var hasContentLength = Object.keys(uri.headers).some(function (key) {
- return key.toLowerCase() === 'content-length';
- });
- var payloadSupported = uri.method !== 'GET' && uri.method !== 'HEAD' && options.payload !== null && options.payload !== undefined;
- if (payloadSupported && (typeof options.payload === 'string' || Buffer.isBuffer(options.payload)) && !hasContentLength) {
- uri.headers = Hoek.clone(uri.headers);
- uri.headers['content-length'] = Buffer.isBuffer(options.payload) ? options.payload.length : Buffer.byteLength(options.payload);
- }
- var redirects = options.hasOwnProperty('redirects') ? options.redirects : false; // Needed to allow 0 as valid value when passed recursively
- _trace = _trace || [];
- _trace.push({ method: uri.method, url: url });
- var client = uri.protocol === 'https:' ? Https : Http;
- if (options.rejectUnauthorized !== undefined && uri.protocol === 'https:') {
- uri.agent = options.rejectUnauthorized ? this.agents.https : this.agents.httpsAllowUnauthorized;
- } else if (options.agent || options.agent === false) {
- uri.agent = options.agent;
- } else {
- uri.agent = uri.protocol === 'https:' ? this.agents.https : this.agents.http;
- }
- if (options.secureProtocol !== undefined) {
- uri.secureProtocol = options.secureProtocol;
- }
- this.emit('request', uri, options);
- var start = Date.now();
- var req = client.request(uri);
- var shadow = null; // A copy of the streamed request payload when redirects are enabled
- var timeoutId = void 0;
- var onError = function onError(err) {
- err.trace = _trace;
- return finishOnce(Boom.badGateway('Client request error', err));
- };
- req.once('error', onError);
- var onResponse = function onResponse(res) {
- // Pass-through response
- var statusCode = res.statusCode;
- if (redirects === false || [301, 302, 307, 308].indexOf(statusCode) === -1) {
- return finishOnce(null, res);
- }
- // Redirection
- var redirectMethod = statusCode === 301 || statusCode === 302 ? 'GET' : uri.method;
- var location = res.headers.location;
- res.destroy();
- if (redirects === 0) {
- return finishOnce(Boom.badGateway('Maximum redirections reached', _trace));
- }
- if (!location) {
- return finishOnce(Boom.badGateway('Received redirection without location', _trace));
- }
- if (!/^https?:/i.test(location)) {
- location = Url.resolve(uri.href, location);
- }
- var redirectOptions = Hoek.cloneWithShallow(options, internals.shallowOptions);
- redirectOptions.payload = shadow || options.payload; // shadow must be ready at this point if set
- redirectOptions.redirects = --redirects;
- if (options.beforeRedirect) {
- options.beforeRedirect(redirectMethod, statusCode, location, redirectOptions);
- }
- var redirectReq = _this.request(redirectMethod, location, redirectOptions, finishOnce, _trace);
- if (options.redirected) {
- options.redirected(statusCode, location, redirectReq);
- }
- };
- // Register handlers
- var finish = function finish(err, res) {
- if (err) {
- req.abort();
- }
- req.removeListener('response', onResponse);
- req.removeListener('error', onError);
- req.on('error', Hoek.ignore);
- clearTimeout(timeoutId);
- _this.emit('response', err, req, res, start, uri);
- if (callback) {
- return callback(err, res);
- }
- };
- var finishOnce = Hoek.once(finish);
- req.once('response', onResponse);
- if (options.timeout) {
- timeoutId = setTimeout(function () {
- return finishOnce(Boom.gatewayTimeout('Client request timeout'));
- }, options.timeout);
- delete options.timeout;
- }
- // Custom abort method to detect early aborts
- var _abort = req.abort;
- var aborted = false;
- req.abort = function () {
- if (!aborted && !req.res && !req.socket) {
- process.nextTick(function () {
- // Fake an ECONNRESET error
- var error = new Error('socket hang up');
- error.code = 'ECONNRESET';
- finishOnce(error);
- });
- }
- aborted = true;
- return _abort.call(req);
- };
- // Write payload
- if (payloadSupported) {
- if (options.payload instanceof Stream) {
- var stream = options.payload;
- if (redirects) {
- (function () {
- var collector = new Tap();
- collector.once('finish', function () {
- shadow = collector.collect();
- });
- stream = options.payload.pipe(collector);
- })();
- }
- stream.pipe(req);
- return req;
- }
- req.write(options.payload);
- }
- // Finalize request
- req.end();
- return req;
- };
- // read()
- internals.Client.prototype.read = function (res, options, callback) {
- options = Hoek.applyToDefaultsWithShallow(options || {}, this._defaults, internals.shallowOptions);
- // Set stream timeout
- var clientTimeout = options.timeout;
- var clientTimeoutId = null;
- // Finish once
- var finish = function finish(err, buffer) {
- clearTimeout(clientTimeoutId);
- reader.removeListener('error', onReaderError);
- reader.removeListener('finish', onReaderFinish);
- res.removeListener('error', onResError);
- res.removeListener('close', onResClose);
- res.on('error', Hoek.ignore);
- if (err || !options.json) {
- return callback(err, buffer);
- }
- // Parse JSON
- var result = void 0;
- if (buffer.length === 0) {
- return callback(null, null);
- }
- if (options.json === 'force') {
- result = internals.tryParseBuffer(buffer);
- return callback(result.err, result.json);
- }
- // mode is "smart" or true
- var contentType = res.headers && res.headers['content-type'] || '';
- var mime = contentType.split(';')[0].trim().toLowerCase();
- if (!internals.jsonRegex.test(mime)) {
- return callback(null, buffer);
- }
- result = internals.tryParseBuffer(buffer);
- return callback(result.err, result.json);
- };
- var finishOnce = Hoek.once(finish);
- if (clientTimeout && clientTimeout > 0) {
- clientTimeoutId = setTimeout(function () {
- finishOnce(Boom.clientTimeout());
- }, clientTimeout);
- }
- // Hander errors
- var onResError = function onResError(err) {
- return finishOnce(Boom.internal('Payload stream error', err));
- };
- var onResClose = function onResClose() {
- return finishOnce(Boom.internal('Payload stream closed prematurely'));
- };
- res.once('error', onResError);
- res.once('close', onResClose);
- // Read payload
- var reader = new Recorder({ maxBytes: options.maxBytes });
- var onReaderError = function onReaderError(err) {
- if (res.destroy) {
- // GZip stream has no destroy() method
- res.destroy();
- }
- return finishOnce(err);
- };
- reader.once('error', onReaderError);
- var onReaderFinish = function onReaderFinish() {
- return finishOnce(null, reader.collect());
- };
- reader.once('finish', onReaderFinish);
- res.pipe(reader);
- };
- // toReadableStream()
- internals.Client.prototype.toReadableStream = function (payload, encoding) {
- return new Payload(payload, encoding);
- };
- // parseCacheControl()
- internals.Client.prototype.parseCacheControl = function (field) {
- /*
- Cache-Control = 1#cache-directive
- cache-directive = token [ "=" ( token / quoted-string ) ]
- token = [^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+
- quoted-string = "(?:[^"\\]|\\.)*"
- */
- // 1: directive = 2: token 3: quoted-string
- var regex = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g;
- var header = {};
- var error = field.replace(regex, function ($0, $1, $2, $3) {
- var value = $2 || $3;
- header[$1] = value ? value.toLowerCase() : true;
- return '';
- });
- if (header['max-age']) {
- try {
- var maxAge = parseInt(header['max-age'], 10);
- if (isNaN(maxAge)) {
- return null;
- }
- header['max-age'] = maxAge;
- } catch (err) {}
- }
- return error ? null : header;
- };
- // Shortcuts
- internals.Client.prototype.get = function (uri, options, callback) {
- return this._shortcutWrap('GET', uri, options, callback);
- };
- internals.Client.prototype.post = function (uri, options, callback) {
- return this._shortcutWrap('POST', uri, options, callback);
- };
- internals.Client.prototype.patch = function (uri, options, callback) {
- return this._shortcutWrap('PATCH', uri, options, callback);
- };
- internals.Client.prototype.put = function (uri, options, callback) {
- return this._shortcutWrap('PUT', uri, options, callback);
- };
- internals.Client.prototype.delete = function (uri, options, callback) {
- return this._shortcutWrap('DELETE', uri, options, callback);
- };
- // Wrapper so that shortcut can be optimized with required params
- internals.Client.prototype._shortcutWrap = function (method, uri /* [options], callback */) {
- var options = typeof arguments[2] === 'function' ? {} : arguments[2];
- var callback = typeof arguments[2] === 'function' ? arguments[2] : arguments[3];
- return this._shortcut(method, uri, options, callback);
- };
- internals.Client.prototype._shortcut = function (method, uri, options, callback) {
- var _this2 = this;
- return this.request(method, uri, options, function (err, res) {
- if (err) {
- return callback(err);
- }
- _this2.read(res, options, function (err, payload) {
- return callback(err, res, payload);
- });
- });
- };
- internals.tryParseBuffer = function (buffer) {
- var result = {
- json: null,
- err: null
- };
- try {
- var json = JSON.parse(buffer.toString());
- result.json = json;
- } catch (err) {
- result.err = err;
- }
- return result;
- };
- module.exports = new internals.Client();
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(1).Buffer))
- /***/ },
- /* 153 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- // Load modules
- var Hoek = __webpack_require__(68);
- var Stream = __webpack_require__(9);
- // Declare internals
- var internals = {};
- module.exports = internals.Payload = function (payload, encoding) {
- Stream.Readable.call(this);
- var data = [].concat(payload || '');
- var size = 0;
- for (var i = 0; i < data.length; ++i) {
- var chunk = data[i];
- size = size + chunk.length;
- data[i] = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk);
- }
- this._data = Buffer.concat(data, size);
- this._position = 0;
- this._encoding = encoding || 'utf8';
- };
- Hoek.inherits(internals.Payload, Stream.Readable);
- internals.Payload.prototype._read = function (size) {
- var chunk = this._data.slice(this._position, this._position + size);
- this.push(chunk, this._encoding);
- this._position = this._position + chunk.length;
- if (this._position >= this._data.length) {
- this.push(null);
- }
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 154 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var addCmd = __webpack_require__(101);
- var Duplex = __webpack_require__(9).Duplex;
- var promisify = __webpack_require__(78);
- module.exports = function (send) {
- var add = addCmd(send);
- return promisify(function createAddStream(callback) {
- var tuples = [];
- var ds = new Duplex({ objectMode: true });
- ds._read = function (n) {};
- ds._write = function (file, enc, next) {
- tuples.push(file);
- next();
- };
- ds.end = function () {
- add(tuples, function (err, res) {
- if (err) {
- return ds.emit('error', err);
- }
- res.forEach(function (tuple) {
- ds.push(tuple);
- });
- ds.push(null);
- });
- };
- callback(null, ds);
- });
- };
- /***/ },
- /* 155 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var DuplexStream = __webpack_require__(214)
- , util = __webpack_require__(44)
- function BufferList (callback) {
- if (!(this instanceof BufferList))
- return new BufferList(callback)
- this._bufs = []
- this.length = 0
- if (typeof callback == 'function') {
- this._callback = callback
- var piper = function piper (err) {
- if (this._callback) {
- this._callback(err)
- this._callback = null
- }
- }.bind(this)
- this.on('pipe', function onPipe (src) {
- src.on('error', piper)
- })
- this.on('unpipe', function onUnpipe (src) {
- src.removeListener('error', piper)
- })
- } else {
- this.append(callback)
- }
- DuplexStream.call(this)
- }
- util.inherits(BufferList, DuplexStream)
- BufferList.prototype._offset = function _offset (offset) {
- var tot = 0, i = 0, _t
- for (; i < this._bufs.length; i++) {
- _t = tot + this._bufs[i].length
- if (offset < _t)
- return [ i, offset - tot ]
- tot = _t
- }
- }
- BufferList.prototype.append = function append (buf) {
- var i = 0
- , newBuf
- if (Array.isArray(buf)) {
- for (; i < buf.length; i++)
- this.append(buf[i])
- } else if (buf instanceof BufferList) {
- // unwrap argument into individual BufferLists
- for (; i < buf._bufs.length; i++)
- this.append(buf._bufs[i])
- } else if (buf != null) {
- // coerce number arguments to strings, since Buffer(number) does
- // uninitialized memory allocation
- if (typeof buf == 'number')
- buf = buf.toString()
- newBuf = Buffer.isBuffer(buf) ? buf : new Buffer(buf)
- this._bufs.push(newBuf)
- this.length += newBuf.length
- }
- return this
- }
- BufferList.prototype._write = function _write (buf, encoding, callback) {
- this.append(buf)
- if (typeof callback == 'function')
- callback()
- }
- BufferList.prototype._read = function _read (size) {
- if (!this.length)
- return this.push(null)
- size = Math.min(size, this.length)
- this.push(this.slice(0, size))
- this.consume(size)
- }
- BufferList.prototype.end = function end (chunk) {
- DuplexStream.prototype.end.call(this, chunk)
- if (this._callback) {
- this._callback(null, this.slice())
- this._callback = null
- }
- }
- BufferList.prototype.get = function get (index) {
- return this.slice(index, index + 1)[0]
- }
- BufferList.prototype.slice = function slice (start, end) {
- return this.copy(null, 0, start, end)
- }
- BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
- if (typeof srcStart != 'number' || srcStart < 0)
- srcStart = 0
- if (typeof srcEnd != 'number' || srcEnd > this.length)
- srcEnd = this.length
- if (srcStart >= this.length)
- return dst || new Buffer(0)
- if (srcEnd <= 0)
- return dst || new Buffer(0)
- var copy = !!dst
- , off = this._offset(srcStart)
- , len = srcEnd - srcStart
- , bytes = len
- , bufoff = (copy && dstStart) || 0
- , start = off[1]
- , l
- , i
- // copy/slice everything
- if (srcStart === 0 && srcEnd == this.length) {
- if (!copy) // slice, just return a full concat
- return Buffer.concat(this._bufs)
- // copy, need to copy individual buffers
- for (i = 0; i < this._bufs.length; i++) {
- this._bufs[i].copy(dst, bufoff)
- bufoff += this._bufs[i].length
- }
- return dst
- }
- // easy, cheap case where it's a subset of one of the buffers
- if (bytes <= this._bufs[off[0]].length - start) {
- return copy
- ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
- : this._bufs[off[0]].slice(start, start + bytes)
- }
- if (!copy) // a slice, we need something to copy in to
- dst = new Buffer(len)
- for (i = off[0]; i < this._bufs.length; i++) {
- l = this._bufs[i].length - start
- if (bytes > l) {
- this._bufs[i].copy(dst, bufoff, start)
- } else {
- this._bufs[i].copy(dst, bufoff, start, start + bytes)
- break
- }
- bufoff += l
- bytes -= l
- if (start)
- start = 0
- }
- return dst
- }
- BufferList.prototype.toString = function toString (encoding, start, end) {
- return this.slice(start, end).toString(encoding)
- }
- BufferList.prototype.consume = function consume (bytes) {
- while (this._bufs.length) {
- if (bytes >= this._bufs[0].length) {
- bytes -= this._bufs[0].length
- this.length -= this._bufs[0].length
- this._bufs.shift()
- } else {
- this._bufs[0] = this._bufs[0].slice(bytes)
- this.length -= bytes
- break
- }
- }
- return this
- }
- BufferList.prototype.duplicate = function duplicate () {
- var i = 0
- , copy = new BufferList()
- for (; i < this._bufs.length; i++)
- copy.append(this._bufs[i])
- return copy
- }
- BufferList.prototype.destroy = function destroy () {
- this._bufs.length = 0
- this.length = 0
- this.push(null)
- }
- ;(function () {
- var methods = {
- 'readDoubleBE' : 8
- , 'readDoubleLE' : 8
- , 'readFloatBE' : 4
- , 'readFloatLE' : 4
- , 'readInt32BE' : 4
- , 'readInt32LE' : 4
- , 'readUInt32BE' : 4
- , 'readUInt32LE' : 4
- , 'readInt16BE' : 2
- , 'readInt16LE' : 2
- , 'readUInt16BE' : 2
- , 'readUInt16LE' : 2
- , 'readInt8' : 1
- , 'readUInt8' : 1
- }
- for (var m in methods) {
- (function (m) {
- BufferList.prototype[m] = function (offset) {
- return this.slice(offset, offset + methods[m])[m](0)
- }
- }(m))
- }
- }())
- module.exports = BufferList
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 156 */
- /***/ function(module, exports, __webpack_require__) {
- var r;
- module.exports = function rand(len) {
- if (!r)
- r = new Rand(null);
- return r.generate(len);
- };
- function Rand(rand) {
- this.rand = rand;
- }
- module.exports.Rand = Rand;
- Rand.prototype.generate = function generate(len) {
- return this._rand(len);
- };
- if (typeof window === 'object') {
- if (window.crypto && window.crypto.getRandomValues) {
- // Modern browsers
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- window.crypto.getRandomValues(arr);
- return arr;
- };
- } else if (window.msCrypto && window.msCrypto.getRandomValues) {
- // IE
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- window.msCrypto.getRandomValues(arr);
- return arr;
- };
- } else {
- // Old junk
- Rand.prototype._rand = function() {
- throw new Error('Not implemented yet');
- };
- }
- } else {
- // Node.js or Web worker
- try {
- var crypto = __webpack_require__(131);
- Rand.prototype._rand = function _rand(n) {
- return crypto.randomBytes(n);
- };
- } catch (e) {
- // Emulate crypto API using randy
- Rand.prototype._rand = function _rand(n) {
- var res = new Uint8Array(n);
- for (var i = 0; i < res.length; i++)
- res[i] = this.rand.getByte();
- return res;
- };
- }
- }
- /***/ },
- /* 157 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
- var Transform = __webpack_require__(57)
- var inherits = __webpack_require__(2)
- var GHASH = __webpack_require__(286)
- var xor = __webpack_require__(69)
- inherits(StreamCipher, Transform)
- module.exports = StreamCipher
- function StreamCipher (mode, key, iv, decrypt) {
- if (!(this instanceof StreamCipher)) {
- return new StreamCipher(mode, key, iv)
- }
- Transform.call(this)
- this._finID = Buffer.concat([iv, new Buffer([0, 0, 0, 1])])
- iv = Buffer.concat([iv, new Buffer([0, 0, 0, 2])])
- this._cipher = new aes.AES(key)
- this._prev = new Buffer(iv.length)
- this._cache = new Buffer('')
- this._secCache = new Buffer('')
- this._decrypt = decrypt
- this._alen = 0
- this._len = 0
- iv.copy(this._prev)
- this._mode = mode
- var h = new Buffer(4)
- h.fill(0)
- this._ghash = new GHASH(this._cipher.encryptBlock(h))
- this._authTag = null
- this._called = false
- }
- StreamCipher.prototype._update = function (chunk) {
- if (!this._called && this._alen) {
- var rump = 16 - (this._alen % 16)
- if (rump < 16) {
- rump = new Buffer(rump)
- rump.fill(0)
- this._ghash.update(rump)
- }
- }
- this._called = true
- var out = this._mode.encrypt(this, chunk)
- if (this._decrypt) {
- this._ghash.update(chunk)
- } else {
- this._ghash.update(out)
- }
- this._len += chunk.length
- return out
- }
- StreamCipher.prototype._final = function () {
- if (this._decrypt && !this._authTag) {
- throw new Error('Unsupported state or unable to authenticate data')
- }
- var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
- if (this._decrypt) {
- if (xorTest(tag, this._authTag)) {
- throw new Error('Unsupported state or unable to authenticate data')
- }
- } else {
- this._authTag = tag
- }
- this._cipher.scrub()
- }
- StreamCipher.prototype.getAuthTag = function getAuthTag () {
- if (!this._decrypt && Buffer.isBuffer(this._authTag)) {
- return this._authTag
- } else {
- throw new Error('Attempting to get auth tag in unsupported state')
- }
- }
- StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
- if (this._decrypt) {
- this._authTag = tag
- } else {
- throw new Error('Attempting to set auth tag in unsupported state')
- }
- }
- StreamCipher.prototype.setAAD = function setAAD (buf) {
- if (!this._called) {
- this._ghash.update(buf)
- this._alen += buf.length
- } else {
- throw new Error('Attempting to set AAD in unsupported state')
- }
- }
- function xorTest (a, b) {
- var out = 0
- if (a.length !== b.length) {
- out++
- }
- var len = Math.min(a.length, b.length)
- var i = -1
- while (++i < len) {
- out += (a[i] ^ b[i])
- }
- return out
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 158 */
- /***/ function(module, exports, __webpack_require__) {
- var xor = __webpack_require__(69)
- exports.encrypt = function (self, block) {
- var data = xor(block, self._prev)
- self._prev = self._cipher.encryptBlock(data)
- return self._prev
- }
- exports.decrypt = function (self, block) {
- var pad = self._prev
- self._prev = block
- var out = self._cipher.decryptBlock(block)
- return xor(out, pad)
- }
- /***/ },
- /* 159 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
- exports.encrypt = function (self, data, decrypt) {
- var out = new Buffer('')
- var len
- while (data.length) {
- if (self._cache.length === 0) {
- self._cache = self._cipher.encryptBlock(self._prev)
- self._prev = new Buffer('')
- }
- if (self._cache.length <= data.length) {
- len = self._cache.length
- out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
- data = data.slice(len)
- } else {
- out = Buffer.concat([out, encryptStart(self, data, decrypt)])
- break
- }
- }
- return out
- }
- function encryptStart (self, data, decrypt) {
- var len = data.length
- var out = xor(data, self._cache)
- self._cache = self._cache.slice(len)
- self._prev = Buffer.concat([self._prev, decrypt ? data : out])
- return out
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 160 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {function encryptByte (self, byteParam, decrypt) {
- var pad
- var i = -1
- var len = 8
- var out = 0
- var bit, value
- while (++i < len) {
- pad = self._cipher.encryptBlock(self._prev)
- bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
- value = pad[0] ^ bit
- out += ((value & 0x80) >> (i % 8))
- self._prev = shiftIn(self._prev, decrypt ? bit : value)
- }
- return out
- }
- exports.encrypt = function (self, chunk, decrypt) {
- var len = chunk.length
- var out = new Buffer(len)
- var i = -1
- while (++i < len) {
- out[i] = encryptByte(self, chunk[i], decrypt)
- }
- return out
- }
- function shiftIn (buffer, value) {
- var len = buffer.length
- var i = -1
- var out = new Buffer(buffer.length)
- buffer = Buffer.concat([buffer, new Buffer([value])])
- while (++i < len) {
- out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
- }
- return out
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 161 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {function encryptByte (self, byteParam, decrypt) {
- var pad = self._cipher.encryptBlock(self._prev)
- var out = pad[0] ^ byteParam
- self._prev = Buffer.concat([self._prev.slice(1), new Buffer([decrypt ? byteParam : out])])
- return out
- }
- exports.encrypt = function (self, chunk, decrypt) {
- var len = chunk.length
- var out = new Buffer(len)
- var i = -1
- while (++i < len) {
- out[i] = encryptByte(self, chunk[i], decrypt)
- }
- return out
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 162 */
- /***/ function(module, exports) {
- exports.encrypt = function (self, block) {
- return self._cipher.encryptBlock(block)
- }
- exports.decrypt = function (self, block) {
- return self._cipher.decryptBlock(block)
- }
- /***/ },
- /* 163 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
- function getBlock (self) {
- self._prev = self._cipher.encryptBlock(self._prev)
- return self._prev
- }
- exports.encrypt = function (self, chunk) {
- while (self._cache.length < chunk.length) {
- self._cache = Buffer.concat([self._cache, getBlock(self)])
- }
- var pad = self._cache.slice(0, chunk.length)
- self._cache = self._cache.slice(chunk.length)
- return xor(chunk, pad)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 164 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
- var Transform = __webpack_require__(57)
- var inherits = __webpack_require__(2)
- inherits(StreamCipher, Transform)
- module.exports = StreamCipher
- function StreamCipher (mode, key, iv, decrypt) {
- if (!(this instanceof StreamCipher)) {
- return new StreamCipher(mode, key, iv)
- }
- Transform.call(this)
- this._cipher = new aes.AES(key)
- this._prev = new Buffer(iv.length)
- this._cache = new Buffer('')
- this._secCache = new Buffer('')
- this._decrypt = decrypt
- iv.copy(this._prev)
- this._mode = mode
- }
- StreamCipher.prototype._update = function (chunk) {
- return this._mode.encrypt(this, chunk, this._decrypt)
- }
- StreamCipher.prototype._final = function () {
- this._cipher.scrub()
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 165 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'
- exports['RSA-SHA224'] = exports.sha224WithRSAEncryption = {
- sign: 'rsa',
- hash: 'sha224',
- id: new Buffer('302d300d06096086480165030402040500041c', 'hex')
- }
- exports['RSA-SHA256'] = exports.sha256WithRSAEncryption = {
- sign: 'rsa',
- hash: 'sha256',
- id: new Buffer('3031300d060960864801650304020105000420', 'hex')
- }
- exports['RSA-SHA384'] = exports.sha384WithRSAEncryption = {
- sign: 'rsa',
- hash: 'sha384',
- id: new Buffer('3041300d060960864801650304020205000430', 'hex')
- }
- exports['RSA-SHA512'] = exports.sha512WithRSAEncryption = {
- sign: 'rsa',
- hash: 'sha512',
- id: new Buffer('3051300d060960864801650304020305000440', 'hex')
- }
- exports['RSA-SHA1'] = {
- sign: 'rsa',
- hash: 'sha1',
- id: new Buffer('3021300906052b0e03021a05000414', 'hex')
- }
- exports['ecdsa-with-SHA1'] = {
- sign: 'ecdsa',
- hash: 'sha1',
- id: new Buffer('', 'hex')
- }
- exports.DSA = exports['DSA-SHA1'] = exports['DSA-SHA'] = {
- sign: 'dsa',
- hash: 'sha1',
- id: new Buffer('', 'hex')
- }
- exports['DSA-SHA224'] = exports['DSA-WITH-SHA224'] = {
- sign: 'dsa',
- hash: 'sha224',
- id: new Buffer('', 'hex')
- }
- exports['DSA-SHA256'] = exports['DSA-WITH-SHA256'] = {
- sign: 'dsa',
- hash: 'sha256',
- id: new Buffer('', 'hex')
- }
- exports['DSA-SHA384'] = exports['DSA-WITH-SHA384'] = {
- sign: 'dsa',
- hash: 'sha384',
- id: new Buffer('', 'hex')
- }
- exports['DSA-SHA512'] = exports['DSA-WITH-SHA512'] = {
- sign: 'dsa',
- hash: 'sha512',
- id: new Buffer('', 'hex')
- }
- exports['DSA-RIPEMD160'] = {
- sign: 'dsa',
- hash: 'rmd160',
- id: new Buffer('', 'hex')
- }
- exports['RSA-RIPEMD160'] = exports.ripemd160WithRSA = {
- sign: 'rsa',
- hash: 'rmd160',
- id: new Buffer('3021300906052b2403020105000414', 'hex')
- }
- exports['RSA-MD5'] = exports.md5WithRSAEncryption = {
- sign: 'rsa',
- hash: 'md5',
- id: new Buffer('3020300c06082a864886f70d020505000410', 'hex')
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 166 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict'
- exports['1.3.132.0.10'] = 'secp256k1'
- exports['1.3.132.0.33'] = 'p224'
- exports['1.2.840.10045.3.1.1'] = 'p192'
- exports['1.2.840.10045.3.1.7'] = 'p256'
- exports['1.3.132.0.34'] = 'p384'
- exports['1.3.132.0.35'] = 'p521'
- /***/ },
- /* 167 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {'use strict';
- var buffer = __webpack_require__(1);
- var Buffer = buffer.Buffer;
- var SlowBuffer = buffer.SlowBuffer;
- var MAX_LEN = buffer.kMaxLength || 2147483647;
- exports.alloc = function alloc(size, fill, encoding) {
- if (typeof Buffer.alloc === 'function') {
- return Buffer.alloc(size, fill, encoding);
- }
- if (typeof encoding === 'number') {
- throw new TypeError('encoding must not be number');
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- var enc = encoding;
- var _fill = fill;
- if (_fill === undefined) {
- enc = undefined;
- _fill = 0;
- }
- var buf = new Buffer(size);
- if (typeof _fill === 'string') {
- var fillBuf = new Buffer(_fill, enc);
- var flen = fillBuf.length;
- var i = -1;
- while (++i < size) {
- buf[i] = fillBuf[i % flen];
- }
- } else {
- buf.fill(_fill);
- }
- return buf;
- }
- exports.allocUnsafe = function allocUnsafe(size) {
- if (typeof Buffer.allocUnsafe === 'function') {
- return Buffer.allocUnsafe(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new Buffer(size);
- }
- exports.from = function from(value, encodingOrOffset, length) {
- if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
- return Buffer.from(value, encodingOrOffset, length);
- }
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number');
- }
- if (typeof value === 'string') {
- return new Buffer(value, encodingOrOffset);
- }
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
- var offset = encodingOrOffset;
- if (arguments.length === 1) {
- return new Buffer(value);
- }
- if (typeof offset === 'undefined') {
- offset = 0;
- }
- var len = length;
- if (typeof len === 'undefined') {
- len = value.byteLength - offset;
- }
- if (offset >= value.byteLength) {
- throw new RangeError('\'offset\' is out of bounds');
- }
- if (len > value.byteLength - offset) {
- throw new RangeError('\'length\' is out of bounds');
- }
- return new Buffer(value.slice(offset, offset + len));
- }
- if (Buffer.isBuffer(value)) {
- var out = new Buffer(value.length);
- value.copy(out, 0, 0, value.length);
- return out;
- }
- if (value) {
- if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
- return new Buffer(value);
- }
- if (value.type === 'Buffer' && Array.isArray(value.data)) {
- return new Buffer(value.data);
- }
- }
- throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
- }
- exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
- if (typeof Buffer.allocUnsafeSlow === 'function') {
- return Buffer.allocUnsafeSlow(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size >= MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new SlowBuffer(size);
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 168 */
- /***/ function(module, exports, __webpack_require__) {
- var cof = __webpack_require__(27);
- module.exports = function(it, msg){
- if(typeof it != 'number' && cof(it) != 'Number')throw TypeError(msg);
- return +it;
- };
- /***/ },
- /* 169 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
- 'use strict';
- var toObject = __webpack_require__(16)
- , toIndex = __webpack_require__(52)
- , toLength = __webpack_require__(15);
- module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){
- var O = toObject(this)
- , len = toLength(O.length)
- , to = toIndex(target, len)
- , from = toIndex(start, len)
- , end = arguments.length > 2 ? arguments[2] : undefined
- , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
- , inc = 1;
- if(from < to && to < from + count){
- inc = -1;
- from += count - 1;
- to += count - 1;
- }
- while(count-- > 0){
- if(from in O)O[to] = O[from];
- else delete O[to];
- to += inc;
- from += inc;
- } return O;
- };
- /***/ },
- /* 170 */
- /***/ function(module, exports, __webpack_require__) {
- var forOf = __webpack_require__(60);
- module.exports = function(iter, ITERATOR){
- var result = [];
- forOf(iter, false, result.push, result, ITERATOR);
- return result;
- };
- /***/ },
- /* 171 */
- /***/ function(module, exports, __webpack_require__) {
- var aFunction = __webpack_require__(21)
- , toObject = __webpack_require__(16)
- , IObject = __webpack_require__(70)
- , toLength = __webpack_require__(15);
- module.exports = function(that, callbackfn, aLen, memo, isRight){
- aFunction(callbackfn);
- var O = toObject(that)
- , self = IObject(O)
- , length = toLength(O.length)
- , index = isRight ? length - 1 : 0
- , i = isRight ? -1 : 1;
- if(aLen < 2)for(;;){
- if(index in self){
- memo = self[index];
- index += i;
- break;
- }
- index += i;
- if(isRight ? index < 0 : length <= index){
- throw TypeError('Reduce of empty array with no initial value');
- }
- }
- for(;isRight ? index >= 0 : length > index; index += i)if(index in self){
- memo = callbackfn(memo, self[index], index, O);
- }
- return memo;
- };
- /***/ },
- /* 172 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var aFunction = __webpack_require__(21)
- , isObject = __webpack_require__(7)
- , invoke = __webpack_require__(86)
- , arraySlice = [].slice
- , factories = {};
- var construct = function(F, len, args){
- if(!(len in factories)){
- for(var n = [], i = 0; i < len; i++)n[i] = 'a[' + i + ']';
- factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
- } return factories[len](F, args);
- };
- module.exports = Function.bind || function bind(that /*, args... */){
- var fn = aFunction(this)
- , partArgs = arraySlice.call(arguments, 1);
- var bound = function(/* args... */){
- var args = partArgs.concat(arraySlice.call(arguments));
- return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
- };
- if(isObject(fn.prototype))bound.prototype = fn.prototype;
- return bound;
- };
- /***/ },
- /* 173 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var dP = __webpack_require__(11).f
- , create = __webpack_require__(47)
- , hide = __webpack_require__(19)
- , redefineAll = __webpack_require__(50)
- , ctx = __webpack_require__(35)
- , anInstance = __webpack_require__(39)
- , defined = __webpack_require__(28)
- , forOf = __webpack_require__(60)
- , $iterDefine = __webpack_require__(115)
- , step = __webpack_require__(178)
- , setSpecies = __webpack_require__(51)
- , DESCRIPTORS = __webpack_require__(10)
- , fastKey = __webpack_require__(40).fastKey
- , SIZE = DESCRIPTORS ? '_s' : 'size';
- var getEntry = function(that, key){
- // fast case
- var index = fastKey(key), entry;
- if(index !== 'F')return that._i[index];
- // frozen object case
- for(entry = that._f; entry; entry = entry.n){
- if(entry.k == key)return entry;
- }
- };
- module.exports = {
- getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
- var C = wrapper(function(that, iterable){
- anInstance(that, C, NAME, '_i');
- that._i = create(null); // index
- that._f = undefined; // first entry
- that._l = undefined; // last entry
- that[SIZE] = 0; // size
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- });
- redefineAll(C.prototype, {
- // 23.1.3.1 Map.prototype.clear()
- // 23.2.3.2 Set.prototype.clear()
- clear: function clear(){
- for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
- entry.r = true;
- if(entry.p)entry.p = entry.p.n = undefined;
- delete data[entry.i];
- }
- that._f = that._l = undefined;
- that[SIZE] = 0;
- },
- // 23.1.3.3 Map.prototype.delete(key)
- // 23.2.3.4 Set.prototype.delete(value)
- 'delete': function(key){
- var that = this
- , entry = getEntry(that, key);
- if(entry){
- var next = entry.n
- , prev = entry.p;
- delete that._i[entry.i];
- entry.r = true;
- if(prev)prev.n = next;
- if(next)next.p = prev;
- if(that._f == entry)that._f = next;
- if(that._l == entry)that._l = prev;
- that[SIZE]--;
- } return !!entry;
- },
- // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
- // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
- forEach: function forEach(callbackfn /*, that = undefined */){
- anInstance(this, C, 'forEach');
- var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3)
- , entry;
- while(entry = entry ? entry.n : this._f){
- f(entry.v, entry.k, this);
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- }
- },
- // 23.1.3.7 Map.prototype.has(key)
- // 23.2.3.7 Set.prototype.has(value)
- has: function has(key){
- return !!getEntry(this, key);
- }
- });
- if(DESCRIPTORS)dP(C.prototype, 'size', {
- get: function(){
- return defined(this[SIZE]);
- }
- });
- return C;
- },
- def: function(that, key, value){
- var entry = getEntry(that, key)
- , prev, index;
- // change existing entry
- if(entry){
- entry.v = value;
- // create new entry
- } else {
- that._l = entry = {
- i: index = fastKey(key, true), // <- index
- k: key, // <- key
- v: value, // <- value
- p: prev = that._l, // <- previous entry
- n: undefined, // <- next entry
- r: false // <- removed
- };
- if(!that._f)that._f = entry;
- if(prev)prev.n = entry;
- that[SIZE]++;
- // add to index
- if(index !== 'F')that._i[index] = entry;
- } return that;
- },
- getEntry: getEntry,
- setStrong: function(C, NAME, IS_MAP){
- // add .keys, .values, .entries, [@@iterator]
- // 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
- $iterDefine(C, NAME, function(iterated, kind){
- this._t = iterated; // target
- this._k = kind; // kind
- this._l = undefined; // previous
- }, function(){
- var that = this
- , kind = that._k
- , entry = that._l;
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- // get next entry
- if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
- // or finish the iteration
- that._t = undefined;
- return step(1);
- }
- // return step by kind
- if(kind == 'keys' )return step(0, entry.k);
- if(kind == 'values')return step(0, entry.v);
- return step(0, [entry.k, entry.v]);
- }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
- // add [@@species], 23.1.2.2, 23.2.2.2
- setSpecies(NAME);
- }
- };
- /***/ },
- /* 174 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- var classof = __webpack_require__(59)
- , from = __webpack_require__(170);
- module.exports = function(NAME){
- return function toJSON(){
- if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic");
- return from(this);
- };
- };
- /***/ },
- /* 175 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var redefineAll = __webpack_require__(50)
- , getWeak = __webpack_require__(40).getWeak
- , anObject = __webpack_require__(3)
- , isObject = __webpack_require__(7)
- , anInstance = __webpack_require__(39)
- , forOf = __webpack_require__(60)
- , createArrayMethod = __webpack_require__(31)
- , $has = __webpack_require__(17)
- , arrayFind = createArrayMethod(5)
- , arrayFindIndex = createArrayMethod(6)
- , id = 0;
- // fallback for uncaught frozen keys
- var uncaughtFrozenStore = function(that){
- return that._l || (that._l = new UncaughtFrozenStore);
- };
- var UncaughtFrozenStore = function(){
- this.a = [];
- };
- var findUncaughtFrozen = function(store, key){
- return arrayFind(store.a, function(it){
- return it[0] === key;
- });
- };
- UncaughtFrozenStore.prototype = {
- get: function(key){
- var entry = findUncaughtFrozen(this, key);
- if(entry)return entry[1];
- },
- has: function(key){
- return !!findUncaughtFrozen(this, key);
- },
- set: function(key, value){
- var entry = findUncaughtFrozen(this, key);
- if(entry)entry[1] = value;
- else this.a.push([key, value]);
- },
- 'delete': function(key){
- var index = arrayFindIndex(this.a, function(it){
- return it[0] === key;
- });
- if(~index)this.a.splice(index, 1);
- return !!~index;
- }
- };
- module.exports = {
- getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
- var C = wrapper(function(that, iterable){
- anInstance(that, C, NAME, '_i');
- that._i = id++; // collection id
- that._l = undefined; // leak store for uncaught frozen objects
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- });
- redefineAll(C.prototype, {
- // 23.3.3.2 WeakMap.prototype.delete(key)
- // 23.4.3.3 WeakSet.prototype.delete(value)
- 'delete': function(key){
- if(!isObject(key))return false;
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this)['delete'](key);
- return data && $has(data, this._i) && delete data[this._i];
- },
- // 23.3.3.4 WeakMap.prototype.has(key)
- // 23.4.3.4 WeakSet.prototype.has(value)
- has: function has(key){
- if(!isObject(key))return false;
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this).has(key);
- return data && $has(data, this._i);
- }
- });
- return C;
- },
- def: function(that, key, value){
- var data = getWeak(anObject(key), true);
- if(data === true)uncaughtFrozenStore(that).set(key, value);
- else data[that._i] = value;
- return that;
- },
- ufstore: uncaughtFrozenStore
- };
- /***/ },
- /* 176 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = !__webpack_require__(10) && !__webpack_require__(6)(function(){
- return Object.defineProperty(__webpack_require__(106)('div'), 'a', {get: function(){ return 7; }}).a != 7;
- });
- /***/ },
- /* 177 */
- /***/ function(module, exports, __webpack_require__) {
- // call something on iterator step with safe closing on error
- var anObject = __webpack_require__(3);
- module.exports = function(iterator, fn, value, entries){
- try {
- return entries ? fn(anObject(value)[0], value[1]) : fn(value);
- // 7.4.6 IteratorClose(iterator, completion)
- } catch(e){
- var ret = iterator['return'];
- if(ret !== undefined)anObject(ret.call(iterator));
- throw e;
- }
- };
- /***/ },
- /* 178 */
- /***/ function(module, exports) {
- module.exports = function(done, value){
- return {value: value, done: !!done};
- };
- /***/ },
- /* 179 */
- /***/ function(module, exports) {
- // 20.2.2.20 Math.log1p(x)
- module.exports = Math.log1p || function log1p(x){
- return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
- };
- /***/ },
- /* 180 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 19.1.2.1 Object.assign(target, source, ...)
- var getKeys = __webpack_require__(49)
- , gOPS = __webpack_require__(90)
- , pIE = __webpack_require__(71)
- , toObject = __webpack_require__(16)
- , IObject = __webpack_require__(70)
- , $assign = Object.assign;
- // should work with symbols and should have deterministic property order (V8 bug)
- module.exports = !$assign || __webpack_require__(6)(function(){
- var A = {}
- , B = {}
- , S = Symbol()
- , K = 'abcdefghijklmnopqrst';
- A[S] = 7;
- K.split('').forEach(function(k){ B[k] = k; });
- return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
- }) ? function assign(target, source){ // eslint-disable-line no-unused-vars
- var T = toObject(target)
- , aLen = arguments.length
- , index = 1
- , getSymbols = gOPS.f
- , isEnum = pIE.f;
- while(aLen > index){
- var S = IObject(arguments[index++])
- , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
- , length = keys.length
- , j = 0
- , key;
- while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];
- } return T;
- } : $assign;
- /***/ },
- /* 181 */
- /***/ function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(11)
- , anObject = __webpack_require__(3)
- , getKeys = __webpack_require__(49);
- module.exports = __webpack_require__(10) ? Object.defineProperties : function defineProperties(O, Properties){
- anObject(O);
- var keys = getKeys(Properties)
- , length = keys.length
- , i = 0
- , P;
- while(length > i)dP.f(O, P = keys[i++], Properties[P]);
- return O;
- };
- /***/ },
- /* 182 */
- /***/ function(module, exports, __webpack_require__) {
- // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
- var toIObject = __webpack_require__(24)
- , gOPN = __webpack_require__(48).f
- , toString = {}.toString;
- var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
- ? Object.getOwnPropertyNames(window) : [];
- var getWindowNames = function(it){
- try {
- return gOPN(it);
- } catch(e){
- return windowNames.slice();
- }
- };
- module.exports.f = function getOwnPropertyNames(it){
- return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
- };
- /***/ },
- /* 183 */
- /***/ function(module, exports, __webpack_require__) {
- var has = __webpack_require__(17)
- , toIObject = __webpack_require__(24)
- , arrayIndexOf = __webpack_require__(82)(false)
- , IE_PROTO = __webpack_require__(119)('IE_PROTO');
- module.exports = function(object, names){
- var O = toIObject(object)
- , i = 0
- , result = []
- , key;
- for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
- // Don't enum bug & hidden keys
- while(names.length > i)if(has(O, key = names[i++])){
- ~arrayIndexOf(result, key) || result.push(key);
- }
- return result;
- };
- /***/ },
- /* 184 */
- /***/ function(module, exports, __webpack_require__) {
- var getKeys = __webpack_require__(49)
- , toIObject = __webpack_require__(24)
- , isEnum = __webpack_require__(71).f;
- module.exports = function(isEntries){
- return function(it){
- var O = toIObject(it)
- , keys = getKeys(O)
- , length = keys.length
- , i = 0
- , result = []
- , key;
- while(length > i)if(isEnum.call(O, key = keys[i++])){
- result.push(isEntries ? [key, O[key]] : O[key]);
- } return result;
- };
- };
- /***/ },
- /* 185 */
- /***/ function(module, exports, __webpack_require__) {
- // all object keys, includes non-enumerable and symbols
- var gOPN = __webpack_require__(48)
- , gOPS = __webpack_require__(90)
- , anObject = __webpack_require__(3)
- , Reflect = __webpack_require__(5).Reflect;
- module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
- var keys = gOPN.f(anObject(it))
- , getSymbols = gOPS.f;
- return getSymbols ? keys.concat(getSymbols(it)) : keys;
- };
- /***/ },
- /* 186 */
- /***/ function(module, exports, __webpack_require__) {
- var $parseFloat = __webpack_require__(5).parseFloat
- , $trim = __webpack_require__(62).trim;
- module.exports = 1 / $parseFloat(__webpack_require__(124) + '-0') !== -Infinity ? function parseFloat(str){
- var string = $trim(String(str), 3)
- , result = $parseFloat(string);
- return result === 0 && string.charAt(0) == '-' ? -0 : result;
- } : $parseFloat;
- /***/ },
- /* 187 */
- /***/ function(module, exports, __webpack_require__) {
- var $parseInt = __webpack_require__(5).parseInt
- , $trim = __webpack_require__(62).trim
- , ws = __webpack_require__(124)
- , hex = /^[\-+]?0[xX]/;
- module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix){
- var string = $trim(String(str), 3);
- return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
- } : $parseInt;
- /***/ },
- /* 188 */
- /***/ function(module, exports) {
- // 7.2.9 SameValue(x, y)
- module.exports = Object.is || function is(x, y){
- return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
- };
- /***/ },
- /* 189 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-string-pad-start-end
- var toLength = __webpack_require__(15)
- , repeat = __webpack_require__(123)
- , defined = __webpack_require__(28);
- module.exports = function(that, maxLength, fillString, left){
- var S = String(defined(that))
- , stringLength = S.length
- , fillStr = fillString === undefined ? ' ' : String(fillString)
- , intMaxLength = toLength(maxLength);
- if(intMaxLength <= stringLength || fillStr == '')return S;
- var fillLen = intMaxLength - stringLength
- , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
- if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
- return left ? stringFiller + S : S + stringFiller;
- };
- /***/ },
- /* 190 */
- /***/ function(module, exports, __webpack_require__) {
- exports.f = __webpack_require__(8);
- /***/ },
- /* 191 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var strong = __webpack_require__(173);
- // 23.1 Map Objects
- module.exports = __webpack_require__(83)('Map', function(get){
- return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.1.3.6 Map.prototype.get(key)
- get: function get(key){
- var entry = strong.getEntry(this, key);
- return entry && entry.v;
- },
- // 23.1.3.9 Map.prototype.set(key, value)
- set: function set(key, value){
- return strong.def(this, key === 0 ? 0 : key, value);
- }
- }, strong, true);
- /***/ },
- /* 192 */
- /***/ function(module, exports, __webpack_require__) {
- // 21.2.5.3 get RegExp.prototype.flags()
- if(__webpack_require__(10) && /./g.flags != 'g')__webpack_require__(11).f(RegExp.prototype, 'flags', {
- configurable: true,
- get: __webpack_require__(85)
- });
- /***/ },
- /* 193 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var strong = __webpack_require__(173);
- // 23.2 Set Objects
- module.exports = __webpack_require__(83)('Set', function(get){
- return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.2.3.1 Set.prototype.add(value)
- add: function add(value){
- return strong.def(this, value = value === 0 ? 0 : value, value);
- }
- }, strong);
- /***/ },
- /* 194 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var each = __webpack_require__(31)(0)
- , redefine = __webpack_require__(22)
- , meta = __webpack_require__(40)
- , assign = __webpack_require__(180)
- , weak = __webpack_require__(175)
- , isObject = __webpack_require__(7)
- , has = __webpack_require__(17)
- , getWeak = meta.getWeak
- , isExtensible = Object.isExtensible
- , uncaughtFrozenStore = weak.ufstore
- , tmp = {}
- , InternalMap;
- var wrapper = function(get){
- return function WeakMap(){
- return get(this, arguments.length > 0 ? arguments[0] : undefined);
- };
- };
- var methods = {
- // 23.3.3.3 WeakMap.prototype.get(key)
- get: function get(key){
- if(isObject(key)){
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this).get(key);
- return data ? data[this._i] : undefined;
- }
- },
- // 23.3.3.5 WeakMap.prototype.set(key, value)
- set: function set(key, value){
- return weak.def(this, key, value);
- }
- };
- // 23.3 WeakMap Objects
- var $WeakMap = module.exports = __webpack_require__(83)('WeakMap', wrapper, methods, weak, true, true);
- // IE11 WeakMap frozen keys fix
- if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
- InternalMap = weak.getConstructor(wrapper);
- assign(InternalMap.prototype, methods);
- meta.NEED = true;
- each(['delete', 'has', 'get', 'set'], function(key){
- var proto = $WeakMap.prototype
- , method = proto[key];
- redefine(proto, key, function(a, b){
- // store frozen objects on internal weakmap shim
- if(isObject(a) && !isExtensible(a)){
- if(!this._f)this._f = new InternalMap;
- var result = this._f[key](a, b);
- return key == 'set' ? this : result;
- // store all the rest on native weakmap
- } return method.call(this, a, b);
- });
- });
- }
- /***/ },
- /* 195 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- /*
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
- * Digest Algorithm, as defined in RFC 1321.
- * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for more info.
- */
- var helpers = __webpack_require__(478);
- /*
- * Calculate the MD5 of an array of little-endian words, and a bit length
- */
- function core_md5(x, len)
- {
- /* append padding */
- x[len >> 5] |= 0x80 << ((len) % 32);
- x[(((len + 64) >>> 9) << 4) + 14] = len;
- var a = 1732584193;
- var b = -271733879;
- var c = -1732584194;
- var d = 271733878;
- for(var i = 0; i < x.length; i += 16)
- {
- var olda = a;
- var oldb = b;
- var oldc = c;
- var oldd = d;
- a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
- d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
- c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
- b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
- a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
- d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
- c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
- b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
- a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
- d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
- c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
- b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
- a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
- d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
- c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
- b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
- a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
- d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
- c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
- b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
- a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
- d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
- c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
- b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
- a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
- d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
- c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
- b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
- a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
- d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
- c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
- b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
- a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
- d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
- c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
- b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
- a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
- d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
- c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
- b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
- a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
- d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
- c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
- b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
- a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
- d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
- c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
- b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
- a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
- d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
- c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
- b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
- a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
- d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
- c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
- b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
- a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
- d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
- c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
- b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
- a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
- d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
- c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
- b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
- a = safe_add(a, olda);
- b = safe_add(b, oldb);
- c = safe_add(c, oldc);
- d = safe_add(d, oldd);
- }
- return Array(a, b, c, d);
- }
- /*
- * These functions implement the four basic operations the algorithm uses.
- */
- function md5_cmn(q, a, b, x, s, t)
- {
- return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
- }
- function md5_ff(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
- }
- function md5_gg(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
- }
- function md5_hh(a, b, c, d, x, s, t)
- {
- return md5_cmn(b ^ c ^ d, a, b, x, s, t);
- }
- function md5_ii(a, b, c, d, x, s, t)
- {
- return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
- }
- /*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
- function safe_add(x, y)
- {
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
- }
- /*
- * Bitwise rotate a 32-bit number to the left.
- */
- function bit_rol(num, cnt)
- {
- return (num << cnt) | (num >>> (32 - cnt));
- }
- module.exports = function md5(buf) {
- return helpers.hash(buf, core_md5, 16);
- };
- /***/ },
- /* 196 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {module.exports = false;
- // Only Node.JS has a process variable that is of [[Class]] process
- try {
- module.exports = Object.prototype.toString.call(global.process) === '[object process]'
- } catch(e) {}
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 197 */
- /***/ function(module, exports, __webpack_require__) {
- var randomBytes = __webpack_require__(73);
- module.exports = findPrime;
- findPrime.simpleSieve = simpleSieve;
- findPrime.fermatTest = fermatTest;
- var BN = __webpack_require__(12);
- var TWENTYFOUR = new BN(24);
- var MillerRabin = __webpack_require__(204);
- var millerRabin = new MillerRabin();
- var ONE = new BN(1);
- var TWO = new BN(2);
- var FIVE = new BN(5);
- var SIXTEEN = new BN(16);
- var EIGHT = new BN(8);
- var TEN = new BN(10);
- var THREE = new BN(3);
- var SEVEN = new BN(7);
- var ELEVEN = new BN(11);
- var FOUR = new BN(4);
- var TWELVE = new BN(12);
- var primes = null;
- function _getPrimes() {
- if (primes !== null)
- return primes;
- var limit = 0x100000;
- var res = [];
- res[0] = 2;
- for (var i = 1, k = 3; k < limit; k += 2) {
- var sqrt = Math.ceil(Math.sqrt(k));
- for (var j = 0; j < i && res[j] <= sqrt; j++)
- if (k % res[j] === 0)
- break;
- if (i !== j && res[j] <= sqrt)
- continue;
- res[i++] = k;
- }
- primes = res;
- return res;
- }
- function simpleSieve(p) {
- var primes = _getPrimes();
- for (var i = 0; i < primes.length; i++)
- if (p.modn(primes[i]) === 0) {
- if (p.cmpn(primes[i]) === 0) {
- return true;
- } else {
- return false;
- }
- }
- return true;
- }
- function fermatTest(p) {
- var red = BN.mont(p);
- return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
- }
- function findPrime(bits, gen) {
- if (bits < 16) {
- // this is what openssl does
- if (gen === 2 || gen === 5) {
- return new BN([0x8c, 0x7b]);
- } else {
- return new BN([0x8c, 0x27]);
- }
- }
- gen = new BN(gen);
- var num, n2;
- while (true) {
- num = new BN(randomBytes(Math.ceil(bits / 8)));
- while (num.bitLength() > bits) {
- num.ishrn(1);
- }
- if (num.isEven()) {
- num.iadd(ONE);
- }
- if (!num.testn(1)) {
- num.iadd(TWO);
- }
- if (!gen.cmp(TWO)) {
- while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
- num.iadd(FOUR);
- }
- } else if (!gen.cmp(FIVE)) {
- while (num.mod(TEN).cmp(THREE)) {
- num.iadd(FOUR);
- }
- }
- n2 = num.shrn(1);
- if (simpleSieve(n2) && simpleSieve(num) &&
- fermatTest(n2) && fermatTest(num) &&
- millerRabin.test(n2) && millerRabin.test(num)) {
- return num;
- }
- }
- }
- /***/ },
- /* 198 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {module.exports = realpath
- realpath.realpath = realpath
- realpath.sync = realpathSync
- realpath.realpathSync = realpathSync
- realpath.monkeypatch = monkeypatch
- realpath.unmonkeypatch = unmonkeypatch
- var origRealpath = fs.realpath
- var origRealpathSync = fs.realpathSync
- var version = process.version
- var ok = /^v[0-5]\./.test(version)
- var old = __webpack_require__(501)
- function newError (er) {
- return er && er.syscall === 'realpath' && (
- er.code === 'ELOOP' ||
- er.code === 'ENOMEM' ||
- er.code === 'ENAMETOOLONG'
- )
- }
- function realpath (p, cache, cb) {
- if (ok) {
- return origRealpath(p, cache, cb)
- }
- if (typeof cache === 'function') {
- cb = cache
- cache = null
- }
- origRealpath(p, cache, function (er, result) {
- if (newError(er)) {
- old.realpath(p, cache, cb)
- } else {
- cb(er, result)
- }
- })
- }
- function realpathSync (p, cache) {
- if (ok) {
- return origRealpathSync(p, cache)
- }
- try {
- return origRealpathSync(p, cache)
- } catch (er) {
- if (newError(er)) {
- return old.realpathSync(p, cache)
- } else {
- throw er
- }
- }
- }
- function monkeypatch () {
- fs.realpath = realpath
- fs.realpathSync = realpathSync
- }
- function unmonkeypatch () {
- fs.realpath = origRealpath
- fs.realpathSync = origRealpathSync
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 199 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {exports.alphasort = alphasort
- exports.alphasorti = alphasorti
- exports.setopts = setopts
- exports.ownProp = ownProp
- exports.makeAbs = makeAbs
- exports.finish = finish
- exports.mark = mark
- exports.isIgnored = isIgnored
- exports.childrenIgnored = childrenIgnored
- function ownProp (obj, field) {
- return Object.prototype.hasOwnProperty.call(obj, field)
- }
- var path = __webpack_require__(43)
- var minimatch = __webpack_require__(135)
- var isAbsolute = __webpack_require__(137)
- var Minimatch = minimatch.Minimatch
- function alphasorti (a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase())
- }
- function alphasort (a, b) {
- return a.localeCompare(b)
- }
- function setupIgnores (self, options) {
- self.ignore = options.ignore || []
- if (!Array.isArray(self.ignore))
- self.ignore = [self.ignore]
- if (self.ignore.length) {
- self.ignore = self.ignore.map(ignoreMap)
- }
- }
- // ignore patterns are always in dot:true mode.
- function ignoreMap (pattern) {
- var gmatcher = null
- if (pattern.slice(-3) === '/**') {
- var gpattern = pattern.replace(/(\/\*\*)+$/, '')
- gmatcher = new Minimatch(gpattern, { dot: true })
- }
- return {
- matcher: new Minimatch(pattern, { dot: true }),
- gmatcher: gmatcher
- }
- }
- function setopts (self, pattern, options) {
- if (!options)
- options = {}
- // base-matching: just use globstar for that.
- if (options.matchBase && -1 === pattern.indexOf("/")) {
- if (options.noglobstar) {
- throw new Error("base matching requires globstar")
- }
- pattern = "**/" + pattern
- }
- self.silent = !!options.silent
- self.pattern = pattern
- self.strict = options.strict !== false
- self.realpath = !!options.realpath
- self.realpathCache = options.realpathCache || Object.create(null)
- self.follow = !!options.follow
- self.dot = !!options.dot
- self.mark = !!options.mark
- self.nodir = !!options.nodir
- if (self.nodir)
- self.mark = true
- self.sync = !!options.sync
- self.nounique = !!options.nounique
- self.nonull = !!options.nonull
- self.nosort = !!options.nosort
- self.nocase = !!options.nocase
- self.stat = !!options.stat
- self.noprocess = !!options.noprocess
- self.maxLength = options.maxLength || Infinity
- self.cache = options.cache || Object.create(null)
- self.statCache = options.statCache || Object.create(null)
- self.symlinks = options.symlinks || Object.create(null)
- setupIgnores(self, options)
- self.changedCwd = false
- var cwd = process.cwd()
- if (!ownProp(options, "cwd"))
- self.cwd = cwd
- else {
- self.cwd = path.resolve(options.cwd)
- self.changedCwd = self.cwd !== cwd
- }
- self.root = options.root || path.resolve(self.cwd, "/")
- self.root = path.resolve(self.root)
- if (process.platform === "win32")
- self.root = self.root.replace(/\\/g, "/")
- self.cwdAbs = makeAbs(self, self.cwd)
- self.nomount = !!options.nomount
- // disable comments and negation in Minimatch.
- // Note that they are not supported in Glob itself anyway.
- options.nonegate = true
- options.nocomment = true
- self.minimatch = new Minimatch(pattern, options)
- self.options = self.minimatch.options
- }
- function finish (self) {
- var nou = self.nounique
- var all = nou ? [] : Object.create(null)
- for (var i = 0, l = self.matches.length; i < l; i ++) {
- var matches = self.matches[i]
- if (!matches || Object.keys(matches).length === 0) {
- if (self.nonull) {
- // do like the shell, and spit out the literal glob
- var literal = self.minimatch.globSet[i]
- if (nou)
- all.push(literal)
- else
- all[literal] = true
- }
- } else {
- // had matches
- var m = Object.keys(matches)
- if (nou)
- all.push.apply(all, m)
- else
- m.forEach(function (m) {
- all[m] = true
- })
- }
- }
- if (!nou)
- all = Object.keys(all)
- if (!self.nosort)
- all = all.sort(self.nocase ? alphasorti : alphasort)
- // at *some* point we statted all of these
- if (self.mark) {
- for (var i = 0; i < all.length; i++) {
- all[i] = self._mark(all[i])
- }
- if (self.nodir) {
- all = all.filter(function (e) {
- var notDir = !(/\/$/.test(e))
- var c = self.cache[e] || self.cache[makeAbs(self, e)]
- if (notDir && c)
- notDir = c !== 'DIR' && !Array.isArray(c)
- return notDir
- })
- }
- }
- if (self.ignore.length)
- all = all.filter(function(m) {
- return !isIgnored(self, m)
- })
- self.found = all
- }
- function mark (self, p) {
- var abs = makeAbs(self, p)
- var c = self.cache[abs]
- var m = p
- if (c) {
- var isDir = c === 'DIR' || Array.isArray(c)
- var slash = p.slice(-1) === '/'
- if (isDir && !slash)
- m += '/'
- else if (!isDir && slash)
- m = m.slice(0, -1)
- if (m !== p) {
- var mabs = makeAbs(self, m)
- self.statCache[mabs] = self.statCache[abs]
- self.cache[mabs] = self.cache[abs]
- }
- }
- return m
- }
- // lotta situps...
- function makeAbs (self, f) {
- var abs = f
- if (f.charAt(0) === '/') {
- abs = path.join(self.root, f)
- } else if (isAbsolute(f) || f === '') {
- abs = f
- } else if (self.changedCwd) {
- abs = path.resolve(self.cwd, f)
- } else {
- abs = path.resolve(f)
- }
- if (process.platform === 'win32')
- abs = abs.replace(/\\/g, '/')
- return abs
- }
- // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
- // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
- function isIgnored (self, path) {
- if (!self.ignore.length)
- return false
- return self.ignore.some(function(item) {
- return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
- })
- }
- function childrenIgnored (self, path) {
- if (!self.ignore.length)
- return false
- return self.ignore.some(function(item) {
- return !!(item.gmatcher && item.gmatcher.match(path))
- })
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 200 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Approach:
- //
- // 1. Get the minimatch set
- // 2. For each pattern in the set, PROCESS(pattern, false)
- // 3. Store matches per-set, then uniq them
- //
- // PROCESS(pattern, inGlobStar)
- // Get the first [n] items from pattern that are all strings
- // Join these together. This is PREFIX.
- // If there is no more remaining, then stat(PREFIX) and
- // add to matches if it succeeds. END.
- //
- // If inGlobStar and PREFIX is symlink and points to dir
- // set ENTRIES = []
- // else readdir(PREFIX) as ENTRIES
- // If fail, END
- //
- // with ENTRIES
- // If pattern[n] is GLOBSTAR
- // // handle the case where the globstar match is empty
- // // by pruning it out, and testing the resulting pattern
- // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
- // // handle other cases.
- // for ENTRY in ENTRIES (not dotfiles)
- // // attach globstar + tail onto the entry
- // // Mark that this entry is a globstar match
- // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
- //
- // else // not globstar
- // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
- // Test ENTRY against pattern[n]
- // If fails, continue
- // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
- //
- // Caveat:
- // Cache all stats and readdirs results to minimize syscall. Since all
- // we ever care about is existence and directory-ness, we can just keep
- // `true` for files, and [children,...] for directories, or `false` for
- // things that don't exist.
- module.exports = glob
- var rp = __webpack_require__(198)
- var minimatch = __webpack_require__(135)
- var Minimatch = minimatch.Minimatch
- var inherits = __webpack_require__(2)
- var EE = __webpack_require__(30).EventEmitter
- var path = __webpack_require__(43)
- var assert = __webpack_require__(144)
- var isAbsolute = __webpack_require__(137)
- var globSync = __webpack_require__(504)
- var common = __webpack_require__(199)
- var alphasort = common.alphasort
- var alphasorti = common.alphasorti
- var setopts = common.setopts
- var ownProp = common.ownProp
- var inflight = __webpack_require__(513)
- var util = __webpack_require__(44)
- var childrenIgnored = common.childrenIgnored
- var isIgnored = common.isIgnored
- var once = __webpack_require__(208)
- function glob (pattern, options, cb) {
- if (typeof options === 'function') cb = options, options = {}
- if (!options) options = {}
- if (options.sync) {
- if (cb)
- throw new TypeError('callback provided to sync glob')
- return globSync(pattern, options)
- }
- return new Glob(pattern, options, cb)
- }
- glob.sync = globSync
- var GlobSync = glob.GlobSync = globSync.GlobSync
- // old api surface
- glob.glob = glob
- function extend (origin, add) {
- if (add === null || typeof add !== 'object') {
- return origin
- }
- var keys = Object.keys(add)
- var i = keys.length
- while (i--) {
- origin[keys[i]] = add[keys[i]]
- }
- return origin
- }
- glob.hasMagic = function (pattern, options_) {
- var options = extend({}, options_)
- options.noprocess = true
- var g = new Glob(pattern, options)
- var set = g.minimatch.set
- if (set.length > 1)
- return true
- for (var j = 0; j < set[0].length; j++) {
- if (typeof set[0][j] !== 'string')
- return true
- }
- return false
- }
- glob.Glob = Glob
- inherits(Glob, EE)
- function Glob (pattern, options, cb) {
- if (typeof options === 'function') {
- cb = options
- options = null
- }
- if (options && options.sync) {
- if (cb)
- throw new TypeError('callback provided to sync glob')
- return new GlobSync(pattern, options)
- }
- if (!(this instanceof Glob))
- return new Glob(pattern, options, cb)
- setopts(this, pattern, options)
- this._didRealPath = false
- // process each pattern in the minimatch set
- var n = this.minimatch.set.length
- // The matches are stored as {<filename>: true,...} so that
- // duplicates are automagically pruned.
- // Later, we do an Object.keys() on these.
- // Keep them as a list so we can fill in when nonull is set.
- this.matches = new Array(n)
- if (typeof cb === 'function') {
- cb = once(cb)
- this.on('error', cb)
- this.on('end', function (matches) {
- cb(null, matches)
- })
- }
- var self = this
- var n = this.minimatch.set.length
- this._processing = 0
- this.matches = new Array(n)
- this._emitQueue = []
- this._processQueue = []
- this.paused = false
- if (this.noprocess)
- return this
- if (n === 0)
- return done()
- var sync = true
- for (var i = 0; i < n; i ++) {
- this._process(this.minimatch.set[i], i, false, done)
- }
- sync = false
- function done () {
- --self._processing
- if (self._processing <= 0) {
- if (sync) {
- process.nextTick(function () {
- self._finish()
- })
- } else {
- self._finish()
- }
- }
- }
- }
- Glob.prototype._finish = function () {
- assert(this instanceof Glob)
- if (this.aborted)
- return
- if (this.realpath && !this._didRealpath)
- return this._realpath()
- common.finish(this)
- this.emit('end', this.found)
- }
- Glob.prototype._realpath = function () {
- if (this._didRealpath)
- return
- this._didRealpath = true
- var n = this.matches.length
- if (n === 0)
- return this._finish()
- var self = this
- for (var i = 0; i < this.matches.length; i++)
- this._realpathSet(i, next)
- function next () {
- if (--n === 0)
- self._finish()
- }
- }
- Glob.prototype._realpathSet = function (index, cb) {
- var matchset = this.matches[index]
- if (!matchset)
- return cb()
- var found = Object.keys(matchset)
- var self = this
- var n = found.length
- if (n === 0)
- return cb()
- var set = this.matches[index] = Object.create(null)
- found.forEach(function (p, i) {
- // If there's a problem with the stat, then it means that
- // one or more of the links in the realpath couldn't be
- // resolved. just return the abs value in that case.
- p = self._makeAbs(p)
- rp.realpath(p, self.realpathCache, function (er, real) {
- if (!er)
- set[real] = true
- else if (er.syscall === 'stat')
- set[p] = true
- else
- self.emit('error', er) // srsly wtf right here
- if (--n === 0) {
- self.matches[index] = set
- cb()
- }
- })
- })
- }
- Glob.prototype._mark = function (p) {
- return common.mark(this, p)
- }
- Glob.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f)
- }
- Glob.prototype.abort = function () {
- this.aborted = true
- this.emit('abort')
- }
- Glob.prototype.pause = function () {
- if (!this.paused) {
- this.paused = true
- this.emit('pause')
- }
- }
- Glob.prototype.resume = function () {
- if (this.paused) {
- this.emit('resume')
- this.paused = false
- if (this._emitQueue.length) {
- var eq = this._emitQueue.slice(0)
- this._emitQueue.length = 0
- for (var i = 0; i < eq.length; i ++) {
- var e = eq[i]
- this._emitMatch(e[0], e[1])
- }
- }
- if (this._processQueue.length) {
- var pq = this._processQueue.slice(0)
- this._processQueue.length = 0
- for (var i = 0; i < pq.length; i ++) {
- var p = pq[i]
- this._processing--
- this._process(p[0], p[1], p[2], p[3])
- }
- }
- }
- }
- Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
- assert(this instanceof Glob)
- assert(typeof cb === 'function')
- if (this.aborted)
- return
- this._processing++
- if (this.paused) {
- this._processQueue.push([pattern, index, inGlobStar, cb])
- return
- }
- //console.error('PROCESS %d', this._processing, pattern)
- // Get the first [n] parts of pattern that are all strings.
- var n = 0
- while (typeof pattern[n] === 'string') {
- n ++
- }
- // now n is the index of the first one that is *not* a string.
- // see if there's anything else
- var prefix
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index, cb)
- return
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null
- break
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/')
- break
- }
- var remain = pattern.slice(n)
- // get the list of entries.
- var read
- if (prefix === null)
- read = '.'
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
- if (!prefix || !isAbsolute(prefix))
- prefix = '/' + prefix
- read = prefix
- } else
- read = prefix
- var abs = this._makeAbs(read)
- //if ignored, skip _processing
- if (childrenIgnored(this, read))
- return cb()
- var isGlobStar = remain[0] === minimatch.GLOBSTAR
- if (isGlobStar)
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
- else
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
- }
- Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this
- this._readdir(abs, inGlobStar, function (er, entries) {
- return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
- })
- }
- Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
- // if the abs isn't a dir, then nothing can match!
- if (!entries)
- return cb()
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0]
- var negate = !!this.minimatch.negate
- var rawGlob = pn._glob
- var dotOk = this.dot || rawGlob.charAt(0) === '.'
- var matchedEntries = []
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i]
- if (e.charAt(0) !== '.' || dotOk) {
- var m
- if (negate && !prefix) {
- m = !e.match(pn)
- } else {
- m = e.match(pn)
- }
- if (m)
- matchedEntries.push(e)
- }
- }
- //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
- var len = matchedEntries.length
- // If there are no matched entries, then nothing matches.
- if (len === 0)
- return cb()
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index])
- this.matches[index] = Object.create(null)
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i]
- if (prefix) {
- if (prefix !== '/')
- e = prefix + '/' + e
- else
- e = prefix + e
- }
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path.join(this.root, e)
- }
- this._emitMatch(index, e)
- }
- // This was the last one, and no stats were needed
- return cb()
- }
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift()
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i]
- var newPattern
- if (prefix) {
- if (prefix !== '/')
- e = prefix + '/' + e
- else
- e = prefix + e
- }
- this._process([e].concat(remain), index, inGlobStar, cb)
- }
- cb()
- }
- Glob.prototype._emitMatch = function (index, e) {
- if (this.aborted)
- return
- if (this.matches[index][e])
- return
- if (isIgnored(this, e))
- return
- if (this.paused) {
- this._emitQueue.push([index, e])
- return
- }
- var abs = this._makeAbs(e)
- if (this.nodir) {
- var c = this.cache[abs]
- if (c === 'DIR' || Array.isArray(c))
- return
- }
- if (this.mark)
- e = this._mark(e)
- this.matches[index][e] = true
- var st = this.statCache[abs]
- if (st)
- this.emit('stat', e, st)
- this.emit('match', e)
- }
- Glob.prototype._readdirInGlobStar = function (abs, cb) {
- if (this.aborted)
- return
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow)
- return this._readdir(abs, false, cb)
- var lstatkey = 'lstat\0' + abs
- var self = this
- var lstatcb = inflight(lstatkey, lstatcb_)
- if (lstatcb)
- fs.lstat(abs, lstatcb)
- function lstatcb_ (er, lstat) {
- if (er)
- return cb()
- var isSym = lstat.isSymbolicLink()
- self.symlinks[abs] = isSym
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && !lstat.isDirectory()) {
- self.cache[abs] = 'FILE'
- cb()
- } else
- self._readdir(abs, false, cb)
- }
- }
- Glob.prototype._readdir = function (abs, inGlobStar, cb) {
- if (this.aborted)
- return
- cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
- if (!cb)
- return
- //console.error('RD %j %j', +inGlobStar, abs)
- if (inGlobStar && !ownProp(this.symlinks, abs))
- return this._readdirInGlobStar(abs, cb)
- if (ownProp(this.cache, abs)) {
- var c = this.cache[abs]
- if (!c || c === 'FILE')
- return cb()
- if (Array.isArray(c))
- return cb(null, c)
- }
- var self = this
- fs.readdir(abs, readdirCb(this, abs, cb))
- }
- function readdirCb (self, abs, cb) {
- return function (er, entries) {
- if (er)
- self._readdirError(abs, er, cb)
- else
- self._readdirEntries(abs, entries, cb)
- }
- }
- Glob.prototype._readdirEntries = function (abs, entries, cb) {
- if (this.aborted)
- return
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i ++) {
- var e = entries[i]
- if (abs === '/')
- e = abs + e
- else
- e = abs + '/' + e
- this.cache[e] = true
- }
- }
- this.cache[abs] = entries
- return cb(null, entries)
- }
- Glob.prototype._readdirError = function (f, er, cb) {
- if (this.aborted)
- return
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR': // totally normal. means it *does* exist.
- var abs = this._makeAbs(f)
- this.cache[abs] = 'FILE'
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd)
- error.path = this.cwd
- error.code = er.code
- this.emit('error', error)
- this.abort()
- }
- break
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false
- break
- default: // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false
- if (this.strict) {
- this.emit('error', er)
- // If the error is handled, then we abort
- // if not, we threw out of here
- this.abort()
- }
- if (!this.silent)
- console.error('glob error', er)
- break
- }
- return cb()
- }
- Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this
- this._readdir(abs, inGlobStar, function (er, entries) {
- self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
- })
- }
- Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
- //console.error('pgs2', prefix, remain[0], entries)
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries)
- return cb()
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1)
- var gspref = prefix ? [ prefix ] : []
- var noGlobStar = gspref.concat(remainWithoutGlobStar)
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false, cb)
- var isSym = this.symlinks[abs]
- var len = entries.length
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar)
- return cb()
- for (var i = 0; i < len; i++) {
- var e = entries[i]
- if (e.charAt(0) === '.' && !this.dot)
- continue
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar)
- this._process(instead, index, true, cb)
- var below = gspref.concat(entries[i], remain)
- this._process(below, index, true, cb)
- }
- cb()
- }
- Glob.prototype._processSimple = function (prefix, index, cb) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var self = this
- this._stat(prefix, function (er, exists) {
- self._processSimple2(prefix, index, er, exists, cb)
- })
- }
- Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
- //console.error('ps2', prefix, exists)
- if (!this.matches[index])
- this.matches[index] = Object.create(null)
- // If it doesn't exist, then just mark the lack of results
- if (!exists)
- return cb()
- if (prefix && isAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix)
- if (prefix.charAt(0) === '/') {
- prefix = path.join(this.root, prefix)
- } else {
- prefix = path.resolve(this.root, prefix)
- if (trail)
- prefix += '/'
- }
- }
- if (process.platform === 'win32')
- prefix = prefix.replace(/\\/g, '/')
- // Mark this as a match
- this._emitMatch(index, prefix)
- cb()
- }
- // Returns either 'DIR', 'FILE', or false
- Glob.prototype._stat = function (f, cb) {
- var abs = this._makeAbs(f)
- var needDir = f.slice(-1) === '/'
- if (f.length > this.maxLength)
- return cb()
- if (!this.stat && ownProp(this.cache, abs)) {
- var c = this.cache[abs]
- if (Array.isArray(c))
- c = 'DIR'
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR')
- return cb(null, c)
- if (needDir && c === 'FILE')
- return cb()
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
- var exists
- var stat = this.statCache[abs]
- if (stat !== undefined) {
- if (stat === false)
- return cb(null, stat)
- else {
- var type = stat.isDirectory() ? 'DIR' : 'FILE'
- if (needDir && type === 'FILE')
- return cb()
- else
- return cb(null, type, stat)
- }
- }
- var self = this
- var statcb = inflight('stat\0' + abs, lstatcb_)
- if (statcb)
- fs.lstat(abs, statcb)
- function lstatcb_ (er, lstat) {
- if (lstat && lstat.isSymbolicLink()) {
- // If it's a symlink, then treat it as the target, unless
- // the target does not exist, then treat it as a file.
- return fs.stat(abs, function (er, stat) {
- if (er)
- self._stat2(f, abs, null, lstat, cb)
- else
- self._stat2(f, abs, er, stat, cb)
- })
- } else {
- self._stat2(f, abs, er, lstat, cb)
- }
- }
- }
- Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
- if (er) {
- this.statCache[abs] = false
- return cb()
- }
- var needDir = f.slice(-1) === '/'
- this.statCache[abs] = stat
- if (abs.slice(-1) === '/' && !stat.isDirectory())
- return cb(null, false, stat)
- var c = stat.isDirectory() ? 'DIR' : 'FILE'
- this.cache[abs] = this.cache[abs] || c
- if (needDir && c !== 'DIR')
- return cb()
- return cb(null, c, stat)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 201 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var base58 = __webpack_require__(56);
- var multihash = __webpack_require__(96);
- var urlPattern = /^https?:\/\/[^\/]+\/(ip(f|n)s)\/((\w+).*)/;
- var pathPattern = /^\/(ip(f|n)s)\/((\w+).*)/;
- function isMultihash(hash) {
- var formatted = convertToString(hash);
- try {
- var buffer = new Buffer(base58.decode(formatted));
- multihash.decode(buffer);
- return true;
- } catch (e) {
- return false;
- }
- }
- function isIpfs(input, pattern) {
- var formatted = convertToString(input);
- if (!formatted) {
- return false;
- }
- var match = formatted.match(pattern);
- if (!match) {
- return false;
- }
- if (match[1] !== 'ipfs') {
- return false;
- }
- var hash = match[4];
- return isMultihash(hash);
- }
- function isIpns(input, pattern) {
- var formatted = convertToString(input);
- if (!formatted) {
- return false;
- }
- var match = formatted.match(pattern);
- if (!match) {
- return false;
- }
- if (match[1] !== 'ipns') {
- return false;
- }
- return true;
- }
- function convertToString(input) {
- if (Buffer.isBuffer(input)) {
- return base58.encode(input);
- }
- if (typeof input === 'string') {
- return input;
- }
- return false;
- }
- module.exports = {
- multihash: isMultihash,
- ipfsUrl: function ipfsUrl(url) {
- return isIpfs(url, urlPattern);
- },
- ipnsUrl: function ipnsUrl(url) {
- return isIpns(url, urlPattern);
- },
- url: function url(_url) {
- return isIpfs(_url, urlPattern) || isIpns(_url, urlPattern);
- },
- urlPattern: urlPattern,
- ipfsPath: function ipfsPath(path) {
- return isIpfs(path, pathPattern);
- },
- ipnsPath: function ipnsPath(path) {
- return isIpns(path, pathPattern);
- },
- path: function path(_path) {
- return isIpfs(_path, pathPattern) || isIpns(_path, pathPattern);
- },
- pathPattern: pathPattern,
- urlOrPath: function urlOrPath(x) {
- return isIpfs(x, urlPattern) || isIpns(x, urlPattern) || isIpfs(x, pathPattern) || isIpns(x, pathPattern);
- }
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 202 */
- /***/ function(module, exports) {
- /**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]',
- stringTag = '[object String]';
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto.propertyIsEnumerable;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetPrototype = Object.getPrototypeOf,
- nativeKeys = Object.keys;
- /**
- * The base implementation of `_.forEach` without support for iteratee shorthands.
- *
- * @private
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object} Returns `collection`.
- */
- var baseEach = createBaseEach(baseForOwn);
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
- /**
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return object && baseFor(object, iteratee, keys);
- }
- /**
- * The base implementation of `_.has` without support for deep paths.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHas(object, key) {
- // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
- // that are composed entirely of index properties, return `false` for
- // `hasOwnProperty` checks of them.
- return hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototype(object) === null);
- }
- /**
- * The base implementation of `_.keys` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- return nativeKeys(Object(object));
- }
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- /**
- * Creates a `baseEach` or `baseEachRight` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseEach(eachFunc, fromRight) {
- return function(collection, iteratee) {
- if (collection == null) {
- return collection;
- }
- if (!isArrayLike(collection)) {
- return eachFunc(collection, iteratee);
- }
- var length = collection.length,
- index = fromRight ? length : -1,
- iterable = Object(collection);
- while ((fromRight ? index-- : ++index < length)) {
- if (iteratee(iterable[index], index, iterable) === false) {
- break;
- }
- }
- return collection;
- };
- }
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
- /**
- * Gets the `[[Prototype]]` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
- */
- function getPrototype(value) {
- return nativeGetPrototype(Object(value));
- }
- /**
- * Creates an array of index keys for `object` values of arrays,
- * `arguments` objects, and strings, otherwise `null` is returned.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array|null} Returns index keys, else `null`.
- */
- function indexKeys(object) {
- var length = object ? object.length : undefined;
- if (isLength(length) &&
- (isArray(object) || isString(object) || isArguments(object))) {
- return baseTimes(length, String);
- }
- return null;
- }
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- length = length == null ? MAX_SAFE_INTEGER : length;
- return !!length &&
- (typeof value == 'number' || reIsUint.test(value)) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
- return value === proto;
- }
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @type {Function}
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
- }
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object,
- * else `false`.
- * @example
- *
- * _.isArrayLikeObject([1, 2, 3]);
- * // => true
- *
- * _.isArrayLikeObject(document.body.children);
- * // => true
- *
- * _.isArrayLikeObject('abc');
- * // => false
- *
- * _.isArrayLikeObject(_.noop);
- * // => false
- */
- function isArrayLikeObject(value) {
- return isObjectLike(value) && isArrayLike(value);
- }
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
- }
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- var isProto = isPrototype(object);
- if (!(isProto || isArrayLike(object))) {
- return baseKeys(object);
- }
- var indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
- for (var key in object) {
- if (baseHas(object, key) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(isProto && key == 'constructor')) {
- result.push(key);
- }
- }
- return result;
- }
- module.exports = baseEach;
- /***/ },
- /* 203 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(module, global) {/**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- var stringToPath = __webpack_require__(520);
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
- /** Used to compose bitmasks for comparison styles. */
- var UNORDERED_COMPARE_FLAG = 1,
- PARTIAL_COMPARE_FLAG = 2;
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0,
- MAX_SAFE_INTEGER = 9007199254740991;
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag = '[object Object]',
- promiseTag = '[object Promise]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- symbolTag = '[object Symbol]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- dataViewTag = '[object DataView]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to match property names within property paths. */
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
- reIsPlainProp = /^\w*$/;
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
- /** Used to detect host constructors (Safari). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
- typedArrayTags[weakMapTag] = false;
- /** Used to determine if values are of the language type `Object`. */
- var objectTypes = {
- 'function': true,
- 'object': true
- };
- /** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
- ? exports
- : undefined;
- /** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
- ? module
- : undefined;
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(objectTypes[typeof self] && self);
- /** Detect free variable `window`. */
- var freeWindow = checkGlobal(objectTypes[typeof window] && window);
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
- /**
- * Used as a reference to the global object.
- *
- * The `this` value is used if it's the global object to avoid Greasemonkey's
- * restricted `window` object, otherwise the `window` object is used.
- */
- var root = freeGlobal ||
- ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
- freeSelf || thisGlobal || Function('return this')();
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- /**
- * A specialized version of `_.some` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function arraySome(array, predicate) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (predicate(array[index], index, array)) {
- return true;
- }
- }
- return false;
- }
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- /**
- * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
- * of key-value pairs for `object` corresponding to the property names of `props`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array} props The property names to get values for.
- * @returns {Object} Returns the key-value pairs.
- */
- function baseToPairs(object, props) {
- return arrayMap(props, function(key) {
- return [key, object[key]];
- });
- }
- /**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
- /**
- * Checks if `value` is a host object in IE < 9.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
- */
- function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
- }
- return result;
- }
- /**
- * Converts `map` to its key-value pairs.
- *
- * @private
- * @param {Object} map The map to convert.
- * @returns {Array} Returns the key-value pairs.
- */
- function mapToArray(map) {
- var index = -1,
- result = Array(map.size);
- map.forEach(function(value, key) {
- result[++index] = [key, value];
- });
- return result;
- }
- /**
- * Converts `set` to an array of its values.
- *
- * @private
- * @param {Object} set The set to convert.
- * @returns {Array} Returns the values.
- */
- function setToArray(set) {
- var index = -1,
- result = Array(set.size);
- set.forEach(function(value) {
- result[++index] = value;
- });
- return result;
- }
- /**
- * Converts `set` to its value-value pairs.
- *
- * @private
- * @param {Object} set The set to convert.
- * @returns {Array} Returns the value-value pairs.
- */
- function setToPairs(set) {
- var index = -1,
- result = Array(set.size);
- set.forEach(function(value) {
- result[++index] = [value, value];
- });
- return result;
- }
- /** Used for built-in method references. */
- var arrayProto = Array.prototype,
- objectProto = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString = Function.prototype.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /** Built-in value references. */
- var Symbol = root.Symbol,
- Uint8Array = root.Uint8Array,
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
- splice = arrayProto.splice;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetPrototype = Object.getPrototypeOf,
- nativeKeys = Object.keys;
- /* Built-in method references that are verified to be native. */
- var DataView = getNative(root, 'DataView'),
- Map = getNative(root, 'Map'),
- Promise = getNative(root, 'Promise'),
- Set = getNative(root, 'Set'),
- WeakMap = getNative(root, 'WeakMap'),
- nativeCreate = getNative(Object, 'create');
- /** Used to detect maps, sets, and weakmaps. */
- var dataViewCtorString = toSource(DataView),
- mapCtorString = toSource(Map),
- promiseCtorString = toSource(Promise),
- setCtorString = toSource(Set),
- weakMapCtorString = toSource(WeakMap);
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = Symbol ? Symbol.prototype : undefined,
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
- /**
- * Creates a hash object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Hash(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the hash.
- *
- * @private
- * @name clear
- * @memberOf Hash
- */
- function hashClear() {
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
- }
- /**
- * Removes `key` and its value from the hash.
- *
- * @private
- * @name delete
- * @memberOf Hash
- * @param {Object} hash The hash to modify.
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function hashDelete(key) {
- return this.has(key) && delete this.__data__[key];
- }
- /**
- * Gets the hash value for `key`.
- *
- * @private
- * @name get
- * @memberOf Hash
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function hashGet(key) {
- var data = this.__data__;
- if (nativeCreate) {
- var result = data[key];
- return result === HASH_UNDEFINED ? undefined : result;
- }
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
- }
- /**
- * Checks if a hash value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Hash
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function hashHas(key) {
- var data = this.__data__;
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
- }
- /**
- * Sets the hash `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Hash
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the hash instance.
- */
- function hashSet(key, value) {
- var data = this.__data__;
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
- return this;
- }
- // Add methods to `Hash`.
- Hash.prototype.clear = hashClear;
- Hash.prototype['delete'] = hashDelete;
- Hash.prototype.get = hashGet;
- Hash.prototype.has = hashHas;
- Hash.prototype.set = hashSet;
- /**
- * Creates an list cache object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function ListCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the list cache.
- *
- * @private
- * @name clear
- * @memberOf ListCache
- */
- function listCacheClear() {
- this.__data__ = [];
- }
- /**
- * Removes `key` and its value from the list cache.
- *
- * @private
- * @name delete
- * @memberOf ListCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function listCacheDelete(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- return false;
- }
- var lastIndex = data.length - 1;
- if (index == lastIndex) {
- data.pop();
- } else {
- splice.call(data, index, 1);
- }
- return true;
- }
- /**
- * Gets the list cache value for `key`.
- *
- * @private
- * @name get
- * @memberOf ListCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function listCacheGet(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- return index < 0 ? undefined : data[index][1];
- }
- /**
- * Checks if a list cache value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf ListCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function listCacheHas(key) {
- return assocIndexOf(this.__data__, key) > -1;
- }
- /**
- * Sets the list cache `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf ListCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the list cache instance.
- */
- function listCacheSet(key, value) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- data.push([key, value]);
- } else {
- data[index][1] = value;
- }
- return this;
- }
- // Add methods to `ListCache`.
- ListCache.prototype.clear = listCacheClear;
- ListCache.prototype['delete'] = listCacheDelete;
- ListCache.prototype.get = listCacheGet;
- ListCache.prototype.has = listCacheHas;
- ListCache.prototype.set = listCacheSet;
- /**
- * Creates a map cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function MapCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the map.
- *
- * @private
- * @name clear
- * @memberOf MapCache
- */
- function mapCacheClear() {
- this.__data__ = {
- 'hash': new Hash,
- 'map': new (Map || ListCache),
- 'string': new Hash
- };
- }
- /**
- * Removes `key` and its value from the map.
- *
- * @private
- * @name delete
- * @memberOf MapCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function mapCacheDelete(key) {
- return getMapData(this, key)['delete'](key);
- }
- /**
- * Gets the map value for `key`.
- *
- * @private
- * @name get
- * @memberOf MapCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function mapCacheGet(key) {
- return getMapData(this, key).get(key);
- }
- /**
- * Checks if a map value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf MapCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function mapCacheHas(key) {
- return getMapData(this, key).has(key);
- }
- /**
- * Sets the map `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf MapCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the map cache instance.
- */
- function mapCacheSet(key, value) {
- getMapData(this, key).set(key, value);
- return this;
- }
- // Add methods to `MapCache`.
- MapCache.prototype.clear = mapCacheClear;
- MapCache.prototype['delete'] = mapCacheDelete;
- MapCache.prototype.get = mapCacheGet;
- MapCache.prototype.has = mapCacheHas;
- MapCache.prototype.set = mapCacheSet;
- /**
- *
- * Creates an array cache object to store unique values.
- *
- * @private
- * @constructor
- * @param {Array} [values] The values to cache.
- */
- function SetCache(values) {
- var index = -1,
- length = values ? values.length : 0;
- this.__data__ = new MapCache;
- while (++index < length) {
- this.add(values[index]);
- }
- }
- /**
- * Adds `value` to the array cache.
- *
- * @private
- * @name add
- * @memberOf SetCache
- * @alias push
- * @param {*} value The value to cache.
- * @returns {Object} Returns the cache instance.
- */
- function setCacheAdd(value) {
- this.__data__.set(value, HASH_UNDEFINED);
- return this;
- }
- /**
- * Checks if `value` is in the array cache.
- *
- * @private
- * @name has
- * @memberOf SetCache
- * @param {*} value The value to search for.
- * @returns {number} Returns `true` if `value` is found, else `false`.
- */
- function setCacheHas(value) {
- return this.__data__.has(value);
- }
- // Add methods to `SetCache`.
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
- SetCache.prototype.has = setCacheHas;
- /**
- * Creates a stack cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Stack(entries) {
- this.__data__ = new ListCache(entries);
- }
- /**
- * Removes all key-value entries from the stack.
- *
- * @private
- * @name clear
- * @memberOf Stack
- */
- function stackClear() {
- this.__data__ = new ListCache;
- }
- /**
- * Removes `key` and its value from the stack.
- *
- * @private
- * @name delete
- * @memberOf Stack
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function stackDelete(key) {
- return this.__data__['delete'](key);
- }
- /**
- * Gets the stack value for `key`.
- *
- * @private
- * @name get
- * @memberOf Stack
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function stackGet(key) {
- return this.__data__.get(key);
- }
- /**
- * Checks if a stack value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Stack
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function stackHas(key) {
- return this.__data__.has(key);
- }
- /**
- * Sets the stack `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Stack
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the stack cache instance.
- */
- function stackSet(key, value) {
- var cache = this.__data__;
- if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
- cache = this.__data__ = new MapCache(cache.__data__);
- }
- cache.set(key, value);
- return this;
- }
- // Add methods to `Stack`.
- Stack.prototype.clear = stackClear;
- Stack.prototype['delete'] = stackDelete;
- Stack.prototype.get = stackGet;
- Stack.prototype.has = stackHas;
- Stack.prototype.set = stackSet;
- /**
- * Gets the index at which the `key` is found in `array` of key-value pairs.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} key The key to search for.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function assocIndexOf(array, key) {
- var length = array.length;
- while (length--) {
- if (eq(array[length][0], key)) {
- return length;
- }
- }
- return -1;
- }
- /**
- * The base implementation of `_.get` without support for default values.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @returns {*} Returns the resolved value.
- */
- function baseGet(object, path) {
- path = isKey(path, object) ? [path] : castPath(path);
- var index = 0,
- length = path.length;
- while (object != null && index < length) {
- object = object[toKey(path[index++])];
- }
- return (index && index == length) ? object : undefined;
- }
- /**
- * The base implementation of `_.has` without support for deep paths.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHas(object, key) {
- // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
- // that are composed entirely of index properties, return `false` for
- // `hasOwnProperty` checks of them.
- return hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototype(object) === null);
- }
- /**
- * The base implementation of `_.hasIn` without support for deep paths.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHasIn(object, key) {
- return key in Object(object);
- }
- /**
- * The base implementation of `_.isEqual` which supports partial comparisons
- * and tracks traversed objects.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {boolean} [bitmask] The bitmask of comparison flags.
- * The bitmask may be composed of the following flags:
- * 1 - Unordered comparison
- * 2 - Partial comparison
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- */
- function baseIsEqual(value, other, customizer, bitmask, stack) {
- if (value === other) {
- return true;
- }
- if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
- return value !== value && other !== other;
- }
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
- }
- /**
- * A specialized version of `baseIsEqual` for arrays and objects which performs
- * deep comparisons and tracks traversed objects enabling objects with circular
- * references to be compared.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
- var objIsArr = isArray(object),
- othIsArr = isArray(other),
- objTag = arrayTag,
- othTag = arrayTag;
- if (!objIsArr) {
- objTag = getTag(object);
- objTag = objTag == argsTag ? objectTag : objTag;
- }
- if (!othIsArr) {
- othTag = getTag(other);
- othTag = othTag == argsTag ? objectTag : othTag;
- }
- var objIsObj = objTag == objectTag && !isHostObject(object),
- othIsObj = othTag == objectTag && !isHostObject(other),
- isSameTag = objTag == othTag;
- if (isSameTag && !objIsObj) {
- stack || (stack = new Stack);
- return (objIsArr || isTypedArray(object))
- ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
- : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
- }
- if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
- if (objIsWrapped || othIsWrapped) {
- var objUnwrapped = objIsWrapped ? object.value() : object,
- othUnwrapped = othIsWrapped ? other.value() : other;
- stack || (stack = new Stack);
- return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
- }
- }
- if (!isSameTag) {
- return false;
- }
- stack || (stack = new Stack);
- return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
- }
- /**
- * The base implementation of `_.isMatch` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @param {Object} source The object of property values to match.
- * @param {Array} matchData The property names, values, and compare flags to match.
- * @param {Function} [customizer] The function to customize comparisons.
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
- */
- function baseIsMatch(object, source, matchData, customizer) {
- var index = matchData.length,
- length = index,
- noCustomizer = !customizer;
- if (object == null) {
- return !length;
- }
- object = Object(object);
- while (index--) {
- var data = matchData[index];
- if ((noCustomizer && data[2])
- ? data[1] !== object[data[0]]
- : !(data[0] in object)
- ) {
- return false;
- }
- }
- while (++index < length) {
- data = matchData[index];
- var key = data[0],
- objValue = object[key],
- srcValue = data[1];
- if (noCustomizer && data[2]) {
- if (objValue === undefined && !(key in object)) {
- return false;
- }
- } else {
- var stack = new Stack;
- if (customizer) {
- var result = customizer(objValue, srcValue, key, object, source, stack);
- }
- if (!(result === undefined
- ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
- : result
- )) {
- return false;
- }
- }
- }
- return true;
- }
- /**
- * The base implementation of `_.iteratee`.
- *
- * @private
- * @param {*} [value=_.identity] The value to convert to an iteratee.
- * @returns {Function} Returns the iteratee.
- */
- function baseIteratee(value) {
- // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
- // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
- if (typeof value == 'function') {
- return value;
- }
- if (value == null) {
- return identity;
- }
- if (typeof value == 'object') {
- return isArray(value)
- ? baseMatchesProperty(value[0], value[1])
- : baseMatches(value);
- }
- return property(value);
- }
- /**
- * The base implementation of `_.keys` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- return nativeKeys(Object(object));
- }
- /**
- * The base implementation of `_.matches` which doesn't clone `source`.
- *
- * @private
- * @param {Object} source The object of property values to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatches(source) {
- var matchData = getMatchData(source);
- if (matchData.length == 1 && matchData[0][2]) {
- return matchesStrictComparable(matchData[0][0], matchData[0][1]);
- }
- return function(object) {
- return object === source || baseIsMatch(object, source, matchData);
- };
- }
- /**
- * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
- *
- * @private
- * @param {string} path The path of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatchesProperty(path, srcValue) {
- if (isKey(path) && isStrictComparable(srcValue)) {
- return matchesStrictComparable(toKey(path), srcValue);
- }
- return function(object) {
- var objValue = get(object, path);
- return (objValue === undefined && objValue === srcValue)
- ? hasIn(object, path)
- : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
- };
- }
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- /**
- * A specialized version of `baseProperty` which supports deep paths.
- *
- * @private
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function basePropertyDeep(path) {
- return function(object) {
- return baseGet(object, path);
- };
- }
- /**
- * Casts `value` to a path array if it's not one.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Array} Returns the cast property path array.
- */
- function castPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
- /**
- * Creates a `_.toPairs` or `_.toPairsIn` function.
- *
- * @private
- * @param {Function} keysFunc The function to get the keys of a given object.
- * @returns {Function} Returns the new pairs function.
- */
- function createToPairs(keysFunc) {
- return function(object) {
- var tag = getTag(object);
- if (tag == mapTag) {
- return mapToArray(object);
- }
- if (tag == setTag) {
- return setToPairs(object);
- }
- return baseToPairs(object, keysFunc(object));
- };
- }
- /**
- * A specialized version of `baseIsEqualDeep` for arrays with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Array} array The array to compare.
- * @param {Array} other The other array to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `array` and `other` objects.
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
- */
- function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
- arrLength = array.length,
- othLength = other.length;
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
- return false;
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(array);
- if (stacked) {
- return stacked == other;
- }
- var index = -1,
- result = true,
- seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
- stack.set(array, other);
- // Ignore non-index properties.
- while (++index < arrLength) {
- var arrValue = array[index],
- othValue = other[index];
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, arrValue, index, other, array, stack)
- : customizer(arrValue, othValue, index, array, other, stack);
- }
- if (compared !== undefined) {
- if (compared) {
- continue;
- }
- result = false;
- break;
- }
- // Recursively compare arrays (susceptible to call stack limits).
- if (seen) {
- if (!arraySome(other, function(othValue, othIndex) {
- if (!seen.has(othIndex) &&
- (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
- return seen.add(othIndex);
- }
- })) {
- result = false;
- break;
- }
- } else if (!(
- arrValue === othValue ||
- equalFunc(arrValue, othValue, customizer, bitmask, stack)
- )) {
- result = false;
- break;
- }
- }
- stack['delete'](array);
- return result;
- }
- /**
- * A specialized version of `baseIsEqualDeep` for comparing objects of
- * the same `toStringTag`.
- *
- * **Note:** This function only supports comparing values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {string} tag The `toStringTag` of the objects to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
- switch (tag) {
- case dataViewTag:
- if ((object.byteLength != other.byteLength) ||
- (object.byteOffset != other.byteOffset)) {
- return false;
- }
- object = object.buffer;
- other = other.buffer;
- case arrayBufferTag:
- if ((object.byteLength != other.byteLength) ||
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
- return false;
- }
- return true;
- case boolTag:
- case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and
- // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
- // not equal.
- return +object == +other;
- case errorTag:
- return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object) ? other != +other : object == +other;
- case regexpTag:
- case stringTag:
- // Coerce regexes to strings and treat strings, primitives and objects,
- // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
- // for more details.
- return object == (other + '');
- case mapTag:
- var convert = mapToArray;
- case setTag:
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
- convert || (convert = setToArray);
- if (object.size != other.size && !isPartial) {
- return false;
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(object);
- if (stacked) {
- return stacked == other;
- }
- bitmask |= UNORDERED_COMPARE_FLAG;
- stack.set(object, other);
- // Recursively compare objects (susceptible to call stack limits).
- return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
- case symbolTag:
- if (symbolValueOf) {
- return symbolValueOf.call(object) == symbolValueOf.call(other);
- }
- }
- return false;
- }
- /**
- * A specialized version of `baseIsEqualDeep` for objects with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
- objProps = keys(object),
- objLength = objProps.length,
- othProps = keys(other),
- othLength = othProps.length;
- if (objLength != othLength && !isPartial) {
- return false;
- }
- var index = objLength;
- while (index--) {
- var key = objProps[index];
- if (!(isPartial ? key in other : baseHas(other, key))) {
- return false;
- }
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(object);
- if (stacked) {
- return stacked == other;
- }
- var result = true;
- stack.set(object, other);
- var skipCtor = isPartial;
- while (++index < objLength) {
- key = objProps[index];
- var objValue = object[key],
- othValue = other[key];
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, objValue, key, other, object, stack)
- : customizer(objValue, othValue, key, object, other, stack);
- }
- // Recursively compare objects (susceptible to call stack limits).
- if (!(compared === undefined
- ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
- : compared
- )) {
- result = false;
- break;
- }
- skipCtor || (skipCtor = key == 'constructor');
- }
- if (result && !skipCtor) {
- var objCtor = object.constructor,
- othCtor = other.constructor;
- // Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor &&
- ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
- result = false;
- }
- }
- stack['delete'](object);
- return result;
- }
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
- /**
- * Gets the data for `map`.
- *
- * @private
- * @param {Object} map The map to query.
- * @param {string} key The reference key.
- * @returns {*} Returns the map data.
- */
- function getMapData(map, key) {
- var data = map.__data__;
- return isKeyable(key)
- ? data[typeof key == 'string' ? 'string' : 'hash']
- : data.map;
- }
- /**
- * Gets the property names, values, and compare flags of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the match data of `object`.
- */
- function getMatchData(object) {
- var result = toPairs(object),
- length = result.length;
- while (length--) {
- result[length][2] = isStrictComparable(result[length][1]);
- }
- return result;
- }
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = object[key];
- return isNative(value) ? value : undefined;
- }
- /**
- * Gets the `[[Prototype]]` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
- */
- function getPrototype(value) {
- return nativeGetPrototype(Object(value));
- }
- /**
- * Gets the `toStringTag` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function getTag(value) {
- return objectToString.call(value);
- }
- // Fallback for data views, maps, sets, and weak maps in IE 11,
- // for data views in Edge, and promises in Node.js.
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
- (Map && getTag(new Map) != mapTag) ||
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
- (Set && getTag(new Set) != setTag) ||
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
- getTag = function(value) {
- var result = objectToString.call(value),
- Ctor = result == objectTag ? value.constructor : undefined,
- ctorString = Ctor ? toSource(Ctor) : undefined;
- if (ctorString) {
- switch (ctorString) {
- case dataViewCtorString: return dataViewTag;
- case mapCtorString: return mapTag;
- case promiseCtorString: return promiseTag;
- case setCtorString: return setTag;
- case weakMapCtorString: return weakMapTag;
- }
- }
- return result;
- };
- }
- /**
- * Checks if `path` exists on `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @param {Function} hasFunc The function to check properties.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- */
- function hasPath(object, path, hasFunc) {
- path = isKey(path, object) ? [path] : castPath(path);
- var result,
- index = -1,
- length = path.length;
- while (++index < length) {
- var key = toKey(path[index]);
- if (!(result = object != null && hasFunc(object, key))) {
- break;
- }
- object = object[key];
- }
- if (result) {
- return result;
- }
- var length = object ? object.length : 0;
- return !!length && isLength(length) && isIndex(key, length) &&
- (isArray(object) || isString(object) || isArguments(object));
- }
- /**
- * Creates an array of index keys for `object` values of arrays,
- * `arguments` objects, and strings, otherwise `null` is returned.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array|null} Returns index keys, else `null`.
- */
- function indexKeys(object) {
- var length = object ? object.length : undefined;
- if (isLength(length) &&
- (isArray(object) || isString(object) || isArguments(object))) {
- return baseTimes(length, String);
- }
- return null;
- }
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- length = length == null ? MAX_SAFE_INTEGER : length;
- return !!length &&
- (typeof value == 'number' || reIsUint.test(value)) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
- /**
- * Checks if `value` is a property name and not a property path.
- *
- * @private
- * @param {*} value The value to check.
- * @param {Object} [object] The object to query keys on.
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
- */
- function isKey(value, object) {
- if (isArray(value)) {
- return false;
- }
- var type = typeof value;
- if (type == 'number' || type == 'symbol' || type == 'boolean' ||
- value == null || isSymbol(value)) {
- return true;
- }
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
- (object != null && value in Object(object));
- }
- /**
- * Checks if `value` is suitable for use as unique object key.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
- */
- function isKeyable(value) {
- var type = typeof value;
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
- ? (value !== '__proto__')
- : (value === null);
- }
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
- return value === proto;
- }
- /**
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` if suitable for strict
- * equality comparisons, else `false`.
- */
- function isStrictComparable(value) {
- return value === value && !isObject(value);
- }
- /**
- * A specialized version of `matchesProperty` for source values suitable
- * for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function matchesStrictComparable(key, srcValue) {
- return function(object) {
- if (object == null) {
- return false;
- }
- return object[key] === srcValue &&
- (srcValue !== undefined || (key in Object(object)));
- };
- }
- /**
- * Converts `value` to a string key if it's not a string or symbol.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {string|symbol} Returns the key.
- */
- function toKey(value) {
- if (typeof value == 'string' || isSymbol(value)) {
- return value;
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
- }
- /**
- * Converts `func` to its source code.
- *
- * @private
- * @param {Function} func The function to process.
- * @returns {string} Returns the source code.
- */
- function toSource(func) {
- if (func != null) {
- try {
- return funcToString.call(func);
- } catch (e) {}
- try {
- return (func + '');
- } catch (e) {}
- }
- return '';
- }
- /**
- * Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * comparison between two values to determine if they are equivalent.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
- *
- * _.eq(object, object);
- * // => true
- *
- * _.eq(object, other);
- * // => false
- *
- * _.eq('a', 'a');
- * // => true
- *
- * _.eq('a', Object('a'));
- * // => false
- *
- * _.eq(NaN, NaN);
- * // => true
- */
- function eq(value, other) {
- return value === other || (value !== value && other !== other);
- }
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @type {Function}
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
- }
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object,
- * else `false`.
- * @example
- *
- * _.isArrayLikeObject([1, 2, 3]);
- * // => true
- *
- * _.isArrayLikeObject(document.body.children);
- * // => true
- *
- * _.isArrayLikeObject('abc');
- * // => false
- *
- * _.isArrayLikeObject(_.noop);
- * // => false
- */
- function isArrayLikeObject(value) {
- return isObjectLike(value) && isArrayLike(value);
- }
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- /**
- * Checks if `value` is a native function.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function,
- * else `false`.
- * @example
- *
- * _.isNative(Array.prototype.push);
- * // => true
- *
- * _.isNative(_);
- * // => false
- */
- function isNative(value) {
- if (!isObject(value)) {
- return false;
- }
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
- return pattern.test(toSource(value));
- }
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
- }
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
- }
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- function isTypedArray(value) {
- return isObjectLike(value) &&
- isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
- }
- /**
- * Gets the value at `path` of `object`. If the resolved value is
- * `undefined`, the `defaultValue` is used in its place.
- *
- * @static
- * @memberOf _
- * @since 3.7.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @param {*} [defaultValue] The value returned for `undefined` resolved values.
- * @returns {*} Returns the resolved value.
- * @example
- *
- * var object = { 'a': [{ 'b': { 'c': 3 } }] };
- *
- * _.get(object, 'a[0].b.c');
- * // => 3
- *
- * _.get(object, ['a', '0', 'b', 'c']);
- * // => 3
- *
- * _.get(object, 'a.b.c', 'default');
- * // => 'default'
- */
- function get(object, path, defaultValue) {
- var result = object == null ? undefined : baseGet(object, path);
- return result === undefined ? defaultValue : result;
- }
- /**
- * Checks if `path` is a direct or inherited property of `object`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- * @example
- *
- * var object = _.create({ 'a': _.create({ 'b': 2 }) });
- *
- * _.hasIn(object, 'a');
- * // => true
- *
- * _.hasIn(object, 'a.b');
- * // => true
- *
- * _.hasIn(object, ['a', 'b']);
- * // => true
- *
- * _.hasIn(object, 'b');
- * // => false
- */
- function hasIn(object, path) {
- return object != null && hasPath(object, path, baseHasIn);
- }
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- var isProto = isPrototype(object);
- if (!(isProto || isArrayLike(object))) {
- return baseKeys(object);
- }
- var indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
- for (var key in object) {
- if (baseHas(object, key) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(isProto && key == 'constructor')) {
- result.push(key);
- }
- }
- return result;
- }
- /**
- * Creates an array of own enumerable string keyed-value pairs for `object`
- * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
- * entries are returned.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @alias entries
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the key-value pairs.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.toPairs(new Foo);
- * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
- */
- var toPairs = createToPairs(keys);
- /**
- * This method returns the first argument given to it.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.identity(object) === object;
- * // => true
- */
- function identity(value) {
- return value;
- }
- /**
- * Creates a function that returns the value at `path` of a given object.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- * @example
- *
- * var objects = [
- * { 'a': { 'b': 2 } },
- * { 'a': { 'b': 1 } }
- * ];
- *
- * _.map(objects, _.property('a.b'));
- * // => [2, 1]
- *
- * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
- * // => [1, 2]
- */
- function property(path) {
- return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
- }
- module.exports = baseIteratee;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
- /***/ },
- /* 204 */
- /***/ function(module, exports, __webpack_require__) {
- var bn = __webpack_require__(12);
- var brorand = __webpack_require__(156);
- function MillerRabin(rand) {
- this.rand = rand || new brorand.Rand();
- }
- module.exports = MillerRabin;
- MillerRabin.create = function create(rand) {
- return new MillerRabin(rand);
- };
- MillerRabin.prototype._rand = function _rand(n) {
- var len = n.bitLength();
- var buf = this.rand.generate(Math.ceil(len / 8));
- // Set low bits
- buf[0] |= 3;
- // Mask high bits
- var mask = len & 0x7;
- if (mask !== 0)
- buf[buf.length - 1] >>= 7 - mask;
- return new bn(buf);
- }
- MillerRabin.prototype.test = function test(n, k, cb) {
- var len = n.bitLength();
- var red = bn.mont(n);
- var rone = new bn(1).toRed(red);
- if (!k)
- k = Math.max(1, (len / 48) | 0);
- // Find d and s, (n - 1) = (2 ^ s) * d;
- var n1 = n.subn(1);
- var n2 = n1.subn(1);
- for (var s = 0; !n1.testn(s); s++) {}
- var d = n.shrn(s);
- var rn1 = n1.toRed(red);
- var prime = true;
- for (; k > 0; k--) {
- var a = this._rand(n2);
- if (cb)
- cb(a);
- var x = a.toRed(red).redPow(d);
- if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
- continue;
- for (var i = 1; i < s; i++) {
- x = x.redSqr();
- if (x.cmp(rone) === 0)
- return false;
- if (x.cmp(rn1) === 0)
- break;
- }
- if (i === s)
- return false;
- }
- return prime;
- };
- MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
- var len = n.bitLength();
- var red = bn.mont(n);
- var rone = new bn(1).toRed(red);
- if (!k)
- k = Math.max(1, (len / 48) | 0);
- // Find d and s, (n - 1) = (2 ^ s) * d;
- var n1 = n.subn(1);
- var n2 = n1.subn(1);
- for (var s = 0; !n1.testn(s); s++) {}
- var d = n.shrn(s);
- var rn1 = n1.toRed(red);
- for (; k > 0; k--) {
- var a = this._rand(n2);
- var g = n.gcd(a);
- if (g.cmpn(1) !== 0)
- return g;
- var x = a.toRed(red).redPow(d);
- if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
- continue;
- for (var i = 1; i < s; i++) {
- x = x.redSqr();
- if (x.cmp(rone) === 0)
- return x.fromRed().subn(1).gcd(n);
- if (x.cmp(rn1) === 0)
- break;
- }
- if (i === s) {
- x = x.redSqr();
- return x.fromRed().subn(1).gcd(n);
- }
- }
- return false;
- };
- /***/ },
- /* 205 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var multihash = __webpack_require__(96);
- var crypto = __webpack_require__(584);
- var mh = module.exports = Multihashing;
- mh.Buffer = Buffer; // for browser things
- function Multihashing(buf, func, length) {
- return multihash.encode(mh.digest(buf, func, length), func, length);
- }
- // expose multihash itself, to avoid silly double requires.
- mh.multihash = multihash;
- mh.digest = function (buf, func, length) {
- var digest = mh.createHash(func).update(buf).digest();
- if (length) {
- digest = digest.slice(0, length);
- }
- return digest;
- };
- mh.createHash = function (func, length) {
- func = multihash.coerceCode(func);
- if (!mh.functions[func]) {
- throw new Error('multihash function ' + func + ' not yet supported');
- }
- return mh.functions[func]();
- };
- mh.functions = {
- 0x11: gsha1,
- 0x12: gsha2_256,
- 0x13: gsha2_512
- // 0x14: gsha3 // not implemented yet
- // 0x40: blake2b, // not implemented yet
- // 0x41: blake2s, // not implemented yet
- };
- function gsha1() {
- return crypto.createHash('sha1');
- }
- function gsha2_256() {
- return crypto.createHash('sha256');
- }
- function gsha2_512() {
- return crypto.createHash('sha512');
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 206 */
- /***/ function(module, exports, __webpack_require__) {
- var through = __webpack_require__(532)
- var split = __webpack_require__(566)
- var EOL = __webpack_require__(209).EOL
- module.exports = parse
- module.exports.serialize = module.exports.stringify = serialize
- module.exports.parse = parse
- function parse (opts) {
- opts = opts || {}
- opts.strict = opts.strict !== false
- function parseRow (row) {
- try {
- if (row) return JSON.parse(row)
- } catch (e) {
- if (opts.strict) {
- this.emit('error', new Error('Could not parse row ' + row.slice(0, 50) + '...'))
- }
- }
- }
- return split(parseRow)
- }
- function serialize (opts) {
- return through.obj(opts, function(obj, enc, cb) {
- cb(null, JSON.stringify(obj) + EOL)
- })
- }
- /***/ },
- /* 207 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- module.exports = Duplex;
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) keys.push(key);
- return keys;
- }
- /*</replacement>*/
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Readable = __webpack_require__(528);
- var Writable = __webpack_require__(530);
- util.inherits(Duplex, Readable);
- forEach(objectKeys(Writable.prototype), function(method) {
- if (!Duplex.prototype[method])
- Duplex.prototype[method] = Writable.prototype[method];
- });
- function Duplex(options) {
- if (!(this instanceof Duplex))
- return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false)
- this.readable = false;
- if (options && options.writable === false)
- this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false)
- this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended)
- return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- process.nextTick(this.end.bind(this));
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 208 */
- /***/ function(module, exports, __webpack_require__) {
- var wrappy = __webpack_require__(228)
- module.exports = wrappy(once)
- once.proto = once(function () {
- Object.defineProperty(Function.prototype, 'once', {
- value: function () {
- return once(this)
- },
- configurable: true
- })
- })
- function once (fn) {
- var f = function () {
- if (f.called) return f.value
- f.called = true
- return f.value = fn.apply(this, arguments)
- }
- f.called = false
- return f
- }
- /***/ },
- /* 209 */
- /***/ function(module, exports) {
- exports.endianness = function () { return 'LE' };
- exports.hostname = function () {
- if (typeof location !== 'undefined') {
- return location.hostname
- }
- else return '';
- };
- exports.loadavg = function () { return [] };
- exports.uptime = function () { return 0 };
- exports.freemem = function () {
- return Number.MAX_VALUE;
- };
- exports.totalmem = function () {
- return Number.MAX_VALUE;
- };
- exports.cpus = function () { return [] };
- exports.type = function () { return 'Browser' };
- exports.release = function () {
- if (typeof navigator !== 'undefined') {
- return navigator.appVersion;
- }
- return '';
- };
- exports.networkInterfaces
- = exports.getNetworkInterfaces
- = function () { return {} };
- exports.arch = function () { return 'javascript' };
- exports.platform = function () { return 'browser' };
- exports.tmpdir = exports.tmpDir = function () {
- return '/tmp';
- };
- exports.EOL = '\n';
- /***/ },
- /* 210 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var createHmac = __webpack_require__(130)
- var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
- exports.pbkdf2 = pbkdf2
- function pbkdf2 (password, salt, iterations, keylen, digest, callback) {
- if (typeof digest === 'function') {
- callback = digest
- digest = undefined
- }
- if (typeof callback !== 'function') {
- throw new Error('No callback provided to pbkdf2')
- }
- var result = pbkdf2Sync(password, salt, iterations, keylen, digest)
- setTimeout(function () {
- callback(undefined, result)
- })
- }
- exports.pbkdf2Sync = pbkdf2Sync
- function pbkdf2Sync (password, salt, iterations, keylen, digest) {
- if (typeof iterations !== 'number') {
- throw new TypeError('Iterations not a number')
- }
- if (iterations < 0) {
- throw new TypeError('Bad iterations')
- }
- if (typeof keylen !== 'number') {
- throw new TypeError('Key length not a number')
- }
- if (keylen < 0 || keylen > MAX_ALLOC) {
- throw new TypeError('Bad key length')
- }
- digest = digest || 'sha1'
- if (!Buffer.isBuffer(password)) password = new Buffer(password, 'binary')
- if (!Buffer.isBuffer(salt)) salt = new Buffer(salt, 'binary')
- var hLen
- var l = 1
- var DK = new Buffer(keylen)
- var block1 = new Buffer(salt.length + 4)
- salt.copy(block1, 0, 0, salt.length)
- var r
- var T
- for (var i = 1; i <= l; i++) {
- block1.writeUInt32BE(i, salt.length)
- var U = createHmac(digest, password).update(block1).digest()
- if (!hLen) {
- hLen = U.length
- T = new Buffer(hLen)
- l = Math.ceil(keylen / hLen)
- r = keylen - (l - 1) * hLen
- }
- U.copy(T, 0, 0, hLen)
- for (var j = 1; j < iterations; j++) {
- U = createHmac(digest, password).update(U).digest()
- for (var k = 0; k < hLen; k++) {
- T[k] ^= U[k]
- }
- }
- var destPos = (i - 1) * hLen
- var len = (i === l ? r : hLen)
- T.copy(DK, destPos, 0, len)
- }
- return DK
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 211 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(63);
- module.exports = function (seed, len) {
- var t = new Buffer('');
- var i = 0, c;
- while (t.length < len) {
- c = i2ops(i++);
- t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
- }
- return t.slice(0, len);
- };
- function i2ops(c) {
- var out = new Buffer(4);
- out.writeUInt32BE(c,0);
- return out;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 212 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(12);
- function withPublic(paddedMsg, key) {
- return new Buffer(paddedMsg
- .toRed(bn.mont(key.modulus))
- .redPow(new bn(key.publicExponent))
- .fromRed()
- .toArray());
- }
- module.exports = withPublic;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 213 */
- /***/ function(module, exports) {
- module.exports = function xor(a, b) {
- var len = a.length;
- var i = -1;
- while (++i < len) {
- a[i] ^= b[i];
- }
- return a
- };
- /***/ },
- /* 214 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(55)
- /***/ },
- /* 215 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a passthrough stream.
- // basically just the most minimal sort of Transform stream.
- // Every written chunk gets output as-is.
- 'use strict';
- module.exports = PassThrough;
- var Transform = __webpack_require__(138);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(PassThrough, Transform);
- function PassThrough(options) {
- if (!(this instanceof PassThrough)) return new PassThrough(options);
- Transform.call(this, options);
- }
- PassThrough.prototype._transform = function (chunk, encoding, cb) {
- cb(null, chunk);
- };
- /***/ },
- /* 216 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
- module.exports = Readable;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var isArray = __webpack_require__(133);
- /*</replacement>*/
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- var EE = __webpack_require__(30);
- /*<replacement>*/
- var EElistenerCount = function (emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(9);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(30).EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- /*<replacement>*/
- var debugUtil = __webpack_require__(585);
- var debug = undefined;
- if (debugUtil && debugUtil.debuglog) {
- debug = debugUtil.debuglog('stream');
- } else {
- debug = function () {};
- }
- /*</replacement>*/
- var StringDecoder;
- util.inherits(Readable, Stream);
- var Duplex;
- function ReadableState(options, stream) {
- Duplex = Duplex || __webpack_require__(55);
- options = options || {};
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- this.buffer = [];
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- this.resumeScheduled = false;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- var Duplex;
- function Readable(options) {
- Duplex = Duplex || __webpack_require__(55);
- if (!(this instanceof Readable)) return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- if (options && typeof options.read === 'function') this._read = options.read;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function (chunk, encoding) {
- var state = this._readableState;
- if (!state.objectMode && typeof chunk === 'string') {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = new Buffer(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function (chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- Readable.prototype.isPaused = function () {
- return this._readableState.flowing === false;
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null) {
- state.reading = false;
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var e = new Error('stream.unshift() after end event');
- stream.emit('error', e);
- } else {
- var skipAdd;
- if (state.decoder && !addToFront && !encoding) {
- chunk = state.decoder.write(chunk);
- skipAdd = !state.objectMode && chunk.length === 0;
- }
- if (!addToFront) state.reading = false;
- // Don't add to the buffer if we've decoded to an empty string chunk and
- // we're not in object mode
- if (!skipAdd) {
- // if we want the data now, just emit it.
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
- if (state.needReadable) emitReadable(stream);
- }
- }
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function (enc) {
- if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
- };
- // Don't raise the hwm > 8MB
- var MAX_HWM = 0x800000;
- function computeNewHighWaterMark(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2
- n--;
- n |= n >>> 1;
- n |= n >>> 2;
- n |= n >>> 4;
- n |= n >>> 8;
- n |= n >>> 16;
- n++;
- }
- return n;
- }
- function howMuchToRead(n, state) {
- if (state.length === 0 && state.ended) return 0;
- if (state.objectMode) return n === 0 ? 0 : 1;
- if (n === null || isNaN(n)) {
- // only flow one buffer at a time
- if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
- }
- if (n <= 0) return 0;
- // If we're asking for more than the target buffer level,
- // then raise the water mark. Bump up to the next highest
- // power of 2, to prevent increasing it excessively in tiny
- // amounts.
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
- // don't have that much. return null, unless we've ended.
- if (n > state.length) {
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- } else {
- return state.length;
- }
- }
- return n;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function (n) {
- debug('read', n);
- var state = this._readableState;
- var nOrig = n;
- if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0) endReadable(this);
- return null;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- }
- if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0) state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- }
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
- var ret;
- if (n > 0) ret = fromList(n, state);else ret = null;
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- }
- state.length -= n;
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (state.length === 0 && !state.ended) state.needReadable = true;
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
- if (ret !== null) this.emit('data', ret);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.ended) return;
- if (state.decoder) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
- }
- }
- function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- processNextTick(maybeReadMore_, stream, state);
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;else len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function (n) {
- this.emit('error', new Error('not implemented'));
- };
- Readable.prototype.pipe = function (dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- debug('onunpipe');
- if (readable === src) {
- cleanup();
- }
- }
- function onend() {
- debug('onend');
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- var cleanedUp = false;
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- src.removeListener('data', ondata);
- cleanedUp = true;
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
- }
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- var ret = dest.write(chunk);
- if (false === ret) {
- // If the user unpiped during `dest.write()`, it is possible
- // to get stuck in a permanently paused state if that write
- // also returned false.
- if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) {
- debug('false write response, pause', src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- }
- src.pause();
- }
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
- }
- // This is a brutally ugly hack to make sure that our error handler
- // is attached before any userland ones. NEVER DO THIS.
- 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];
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function () {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain) state.awaitDrain--;
- if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
- }
- Readable.prototype.unpipe = function (dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0) return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes) return this;
- if (!dest) dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest) dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- for (var _i = 0; _i < len; _i++) {
- dests[_i].emit('unpipe', this);
- }return this;
- }
- // try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1) return this;
- state.pipes.splice(i, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function (ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- // If listening to data, and it has not explicitly been paused,
- // then call resume to start the flow of data on the next tick.
- if (ev === 'data' && false !== this._readableState.flowing) {
- this.resume();
- }
- if (ev === 'readable' && !this._readableState.endEmitted) {
- var state = this._readableState;
- if (!state.readableListening) {
- state.readableListening = true;
- state.emittedReadable = false;
- state.needReadable = true;
- if (!state.reading) {
- processNextTick(nReadingNextTick, this);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- function nReadingNextTick(self) {
- debug('readable nexttick read 0');
- self.read(0);
- }
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function () {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- resume(this, state);
- }
- return this;
- };
- function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- processNextTick(resume_, stream, state);
- }
- }
- function resume_(stream, state) {
- if (!state.reading) {
- debug('resume read 0');
- stream.read(0);
- }
- state.resumeScheduled = false;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading) stream.read(0);
- }
- Readable.prototype.pause = function () {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
- };
- function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- if (state.flowing) {
- do {
- var chunk = stream.read();
- } while (null !== chunk && state.flowing);
- }
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function (stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function () {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function (chunk) {
- debug('wrapped data');
- if (state.decoder) chunk = state.decoder.write(chunk);
- // don't skip over falsy values in objectMode
- if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (this[i] === undefined && typeof stream[i] === 'function') {
- this[i] = function (method) {
- return function () {
- return stream[method].apply(stream, arguments);
- };
- }(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function (ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function (n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- function fromList(n, state) {
- var list = state.buffer;
- var length = state.length;
- var stringMode = !!state.decoder;
- var objectMode = !!state.objectMode;
- var ret;
- // nothing in the list, definitely empty.
- if (list.length === 0) return null;
- if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
- // read it all, truncate the array.
- if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
- list.length = 0;
- } else {
- // read just some of it.
- if (n < list[0].length) {
- // just take a part of the first list item.
- // slice is the same for buffers and strings.
- var buf = list[0];
- ret = buf.slice(0, n);
- list[0] = buf.slice(n);
- } else if (n === list[0].length) {
- // first list is a perfect match
- ret = list.shift();
- } else {
- // complex case.
- // we have enough to cover it, but it spans past the first buffer.
- if (stringMode) ret = '';else ret = new Buffer(n);
- var c = 0;
- for (var i = 0, l = list.length; i < l && c < n; i++) {
- var buf = list[0];
- var cpy = Math.min(n - c, buf.length);
- if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy);
- if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift();
- c += cpy;
- }
- }
- }
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0) throw new Error('endReadable called on non-empty stream');
- if (!state.endEmitted) {
- state.ended = true;
- processNextTick(endReadableNT, state, stream);
- }
- }
- function endReadableNT(state, stream) {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf(xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 217 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/**
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
- * in FIPS 180-2
- * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- *
- */
- var inherits = __webpack_require__(2)
- var Hash = __webpack_require__(65)
- var K = [
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
- ]
- var W = new Array(64)
- function Sha256 () {
- this.init()
- this._w = W // new Array(64)
- Hash.call(this, 64, 56)
- }
- inherits(Sha256, Hash)
- Sha256.prototype.init = function () {
- this._a = 0x6a09e667
- this._b = 0xbb67ae85
- this._c = 0x3c6ef372
- this._d = 0xa54ff53a
- this._e = 0x510e527f
- this._f = 0x9b05688c
- this._g = 0x1f83d9ab
- this._h = 0x5be0cd19
- return this
- }
- function ch (x, y, z) {
- return z ^ (x & (y ^ z))
- }
- function maj (x, y, z) {
- return (x & y) | (z & (x | y))
- }
- function sigma0 (x) {
- return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
- }
- function sigma1 (x) {
- return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
- }
- function gamma0 (x) {
- return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
- }
- function gamma1 (x) {
- return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
- }
- Sha256.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- var f = this._f | 0
- var g = this._g | 0
- var h = this._h | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
- for (var j = 0; j < 64; ++j) {
- var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
- var T2 = (sigma0(a) + maj(a, b, c)) | 0
- h = g
- g = f
- f = e
- e = (d + T1) | 0
- d = c
- c = b
- b = a
- a = (T1 + T2) | 0
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- this._f = (f + this._f) | 0
- this._g = (g + this._g) | 0
- this._h = (h + this._h) | 0
- }
- Sha256.prototype._hash = function () {
- var H = new Buffer(32)
- H.writeInt32BE(this._a, 0)
- H.writeInt32BE(this._b, 4)
- H.writeInt32BE(this._c, 8)
- H.writeInt32BE(this._d, 12)
- H.writeInt32BE(this._e, 16)
- H.writeInt32BE(this._f, 20)
- H.writeInt32BE(this._g, 24)
- H.writeInt32BE(this._h, 28)
- return H
- }
- module.exports = Sha256
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 218 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2)
- var Hash = __webpack_require__(65)
- var K = [
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
- ]
- var W = new Array(160)
- function Sha512 () {
- this.init()
- this._w = W
- Hash.call(this, 128, 112)
- }
- inherits(Sha512, Hash)
- Sha512.prototype.init = function () {
- this._ah = 0x6a09e667
- this._bh = 0xbb67ae85
- this._ch = 0x3c6ef372
- this._dh = 0xa54ff53a
- this._eh = 0x510e527f
- this._fh = 0x9b05688c
- this._gh = 0x1f83d9ab
- this._hh = 0x5be0cd19
- this._al = 0xf3bcc908
- this._bl = 0x84caa73b
- this._cl = 0xfe94f82b
- this._dl = 0x5f1d36f1
- this._el = 0xade682d1
- this._fl = 0x2b3e6c1f
- this._gl = 0xfb41bd6b
- this._hl = 0x137e2179
- return this
- }
- function Ch (x, y, z) {
- return z ^ (x & (y ^ z))
- }
- function maj (x, y, z) {
- return (x & y) | (z & (x | y))
- }
- function sigma0 (x, xl) {
- return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
- }
- function sigma1 (x, xl) {
- return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
- }
- function Gamma0 (x, xl) {
- return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
- }
- function Gamma0l (x, xl) {
- return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
- }
- function Gamma1 (x, xl) {
- return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
- }
- function Gamma1l (x, xl) {
- return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
- }
- function getCarry (a, b) {
- return (a >>> 0) < (b >>> 0) ? 1 : 0
- }
- Sha512.prototype._update = function (M) {
- var W = this._w
- var ah = this._ah | 0
- var bh = this._bh | 0
- var ch = this._ch | 0
- var dh = this._dh | 0
- var eh = this._eh | 0
- var fh = this._fh | 0
- var gh = this._gh | 0
- var hh = this._hh | 0
- var al = this._al | 0
- var bl = this._bl | 0
- var cl = this._cl | 0
- var dl = this._dl | 0
- var el = this._el | 0
- var fl = this._fl | 0
- var gl = this._gl | 0
- var hl = this._hl | 0
- for (var i = 0; i < 32; i += 2) {
- W[i] = M.readInt32BE(i * 4)
- W[i + 1] = M.readInt32BE(i * 4 + 4)
- }
- for (; i < 160; i += 2) {
- var xh = W[i - 15 * 2]
- var xl = W[i - 15 * 2 + 1]
- var gamma0 = Gamma0(xh, xl)
- var gamma0l = Gamma0l(xl, xh)
- xh = W[i - 2 * 2]
- xl = W[i - 2 * 2 + 1]
- var gamma1 = Gamma1(xh, xl)
- var gamma1l = Gamma1l(xl, xh)
- // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
- var Wi7h = W[i - 7 * 2]
- var Wi7l = W[i - 7 * 2 + 1]
- var Wi16h = W[i - 16 * 2]
- var Wi16l = W[i - 16 * 2 + 1]
- var Wil = (gamma0l + Wi7l) | 0
- var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
- Wil = (Wil + gamma1l) | 0
- Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
- Wil = (Wil + Wi16l) | 0
- Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
- W[i] = Wih
- W[i + 1] = Wil
- }
- for (var j = 0; j < 160; j += 2) {
- Wih = W[j]
- Wil = W[j + 1]
- var majh = maj(ah, bh, ch)
- var majl = maj(al, bl, cl)
- var sigma0h = sigma0(ah, al)
- var sigma0l = sigma0(al, ah)
- var sigma1h = sigma1(eh, el)
- var sigma1l = sigma1(el, eh)
- // t1 = h + sigma1 + ch + K[j] + W[j]
- var Kih = K[j]
- var Kil = K[j + 1]
- var chh = Ch(eh, fh, gh)
- var chl = Ch(el, fl, gl)
- var t1l = (hl + sigma1l) | 0
- var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
- t1l = (t1l + chl) | 0
- t1h = (t1h + chh + getCarry(t1l, chl)) | 0
- t1l = (t1l + Kil) | 0
- t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
- t1l = (t1l + Wil) | 0
- t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
- // t2 = sigma0 + maj
- var t2l = (sigma0l + majl) | 0
- var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
- hh = gh
- hl = gl
- gh = fh
- gl = fl
- fh = eh
- fl = el
- el = (dl + t1l) | 0
- eh = (dh + t1h + getCarry(el, dl)) | 0
- dh = ch
- dl = cl
- ch = bh
- cl = bl
- bh = ah
- bl = al
- al = (t1l + t2l) | 0
- ah = (t1h + t2h + getCarry(al, t1l)) | 0
- }
- this._al = (this._al + al) | 0
- this._bl = (this._bl + bl) | 0
- this._cl = (this._cl + cl) | 0
- this._dl = (this._dl + dl) | 0
- this._el = (this._el + el) | 0
- this._fl = (this._fl + fl) | 0
- this._gl = (this._gl + gl) | 0
- this._hl = (this._hl + hl) | 0
- this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
- this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
- this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
- this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
- this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
- this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
- this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
- this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
- }
- Sha512.prototype._hash = function () {
- var H = new Buffer(64)
- function writeInt64BE (h, l, offset) {
- H.writeInt32BE(h, offset)
- H.writeInt32BE(l, offset + 4)
- }
- writeInt64BE(this._ah, this._al, 0)
- writeInt64BE(this._bh, this._bl, 8)
- writeInt64BE(this._ch, this._cl, 16)
- writeInt64BE(this._dh, this._dl, 24)
- writeInt64BE(this._eh, this._el, 32)
- writeInt64BE(this._fh, this._fl, 40)
- writeInt64BE(this._gh, this._gl, 48)
- writeInt64BE(this._hh, this._hl, 56)
- return H
- }
- module.exports = Sha512
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 219 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- module.exports = Duplex;
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) keys.push(key);
- return keys;
- }
- /*</replacement>*/
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Readable = __webpack_require__(568);
- var Writable = __webpack_require__(570);
- util.inherits(Duplex, Readable);
- forEach(objectKeys(Writable.prototype), function(method) {
- if (!Duplex.prototype[method])
- Duplex.prototype[method] = Writable.prototype[method];
- });
- function Duplex(options) {
- if (!(this instanceof Duplex))
- return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false)
- this.readable = false;
- if (options && options.writable === false)
- this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false)
- this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended)
- return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- process.nextTick(this.end.bind(this));
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 220 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(574)
- var extend = __webpack_require__(98)
- var statusCodes = __webpack_require__(293)
- var url = __webpack_require__(226)
- var http = exports
- http.request = function (opts, cb) {
- if (typeof opts === 'string')
- opts = url.parse(opts)
- else
- opts = extend(opts)
- // Normally, the page is loaded from http or https, so not specifying a protocol
- // will result in a (valid) protocol-relative url. However, this won't work if
- // the protocol is something else, like 'file:'
- var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
- var protocol = opts.protocol || defaultProtocol
- var host = opts.hostname || opts.host
- var port = opts.port
- var path = opts.path || '/'
- // Necessary for IPv6 addresses
- if (host && host.indexOf(':') !== -1)
- host = '[' + host + ']'
- // This may be a relative url. The browser should always be able to interpret it correctly.
- opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
- opts.method = (opts.method || 'GET').toUpperCase()
- opts.headers = opts.headers || {}
- // Also valid opts.auth, opts.mode
- var req = new ClientRequest(opts)
- if (cb)
- req.on('response', cb)
- return req
- }
- http.get = function get (opts, cb) {
- var req = http.request(opts, cb)
- req.end()
- return req
- }
- http.Agent = function () {}
- http.Agent.defaultMaxSockets = 4
- http.STATUS_CODES = statusCodes
- http.METHODS = [
- 'CHECKOUT',
- 'CONNECT',
- 'COPY',
- 'DELETE',
- 'GET',
- 'HEAD',
- 'LOCK',
- 'M-SEARCH',
- 'MERGE',
- 'MKACTIVITY',
- 'MKCOL',
- 'MOVE',
- 'NOTIFY',
- 'OPTIONS',
- 'PATCH',
- 'POST',
- 'PROPFIND',
- 'PROPPATCH',
- 'PURGE',
- 'PUT',
- 'REPORT',
- 'SEARCH',
- 'SUBSCRIBE',
- 'TRACE',
- 'UNLOCK',
- 'UNSUBSCRIBE'
- ]
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 221 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableByteStream)
- exports.blobConstructor = false
- try {
- new Blob([new ArrayBuffer(1)])
- exports.blobConstructor = true
- } catch (e) {}
- var xhr = new global.XMLHttpRequest()
- // If location.host is empty, e.g. if this page/worker was loaded
- // from a Blob, then use example.com to avoid an error
- xhr.open('GET', global.location.host ? '/' : 'https://example.com')
- function checkTypeSupport (type) {
- try {
- xhr.responseType = type
- return xhr.responseType === type
- } catch (e) {}
- return false
- }
- // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
- // Safari 7.1 appears to have fixed this bug.
- var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
- var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
- exports.arraybuffer = haveArrayBuffer && checkTypeSupport('arraybuffer')
- // These next two tests unavoidably show warnings in Chrome. Since fetch will always
- // be used if it's available, just return false for these to avoid the warnings.
- exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
- exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
- checkTypeSupport('moz-chunked-arraybuffer')
- exports.overrideMimeType = isFunction(xhr.overrideMimeType)
- exports.vbArray = isFunction(global.VBArray)
- function isFunction (value) {
- return typeof value === 'function'
- }
- xhr = null // Help gc
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 222 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
- module.exports = Readable;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var isArray = __webpack_require__(133);
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- /*<replacement>*/
- var EE = __webpack_require__(30).EventEmitter;
- var EElistenerCount = function (emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(9);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(30).EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*<replacement>*/
- var bufferShim = __webpack_require__(167);
- /*</replacement>*/
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- /*<replacement>*/
- var debugUtil = __webpack_require__(586);
- var debug = void 0;
- if (debugUtil && debugUtil.debuglog) {
- debug = debugUtil.debuglog('stream');
- } else {
- debug = function () {};
- }
- /*</replacement>*/
- var StringDecoder;
- util.inherits(Readable, Stream);
- var hasPrependListener = typeof EE.prototype.prependListener === 'function';
- function prependListener(emitter, event, fn) {
- if (hasPrependListener) return emitter.prependListener(event, fn);
- // This is a brutally ugly hack to make sure that our error handler
- // is attached before any userland ones. NEVER DO THIS. This is here
- // only because this code needs to continue to work with older versions
- // of Node.js that do not include the prependListener() method. The goal
- // is to eventually remove this hack.
- 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]];
- }
- var Duplex;
- function ReadableState(options, stream) {
- Duplex = Duplex || __webpack_require__(66);
- options = options || {};
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- this.buffer = [];
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- this.resumeScheduled = false;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- var Duplex;
- function Readable(options) {
- Duplex = Duplex || __webpack_require__(66);
- if (!(this instanceof Readable)) return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- if (options && typeof options.read === 'function') this._read = options.read;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function (chunk, encoding) {
- var state = this._readableState;
- if (!state.objectMode && typeof chunk === 'string') {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = bufferShim.from(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function (chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- Readable.prototype.isPaused = function () {
- return this._readableState.flowing === false;
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null) {
- state.reading = false;
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var _e = new Error('stream.unshift() after end event');
- stream.emit('error', _e);
- } else {
- var skipAdd;
- if (state.decoder && !addToFront && !encoding) {
- chunk = state.decoder.write(chunk);
- skipAdd = !state.objectMode && chunk.length === 0;
- }
- if (!addToFront) state.reading = false;
- // Don't add to the buffer if we've decoded to an empty string chunk and
- // we're not in object mode
- if (!skipAdd) {
- // if we want the data now, just emit it.
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
- if (state.needReadable) emitReadable(stream);
- }
- }
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function (enc) {
- if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
- };
- // Don't raise the hwm > 8MB
- var MAX_HWM = 0x800000;
- function computeNewHighWaterMark(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2
- n--;
- n |= n >>> 1;
- n |= n >>> 2;
- n |= n >>> 4;
- n |= n >>> 8;
- n |= n >>> 16;
- n++;
- }
- return n;
- }
- function howMuchToRead(n, state) {
- if (state.length === 0 && state.ended) return 0;
- if (state.objectMode) return n === 0 ? 0 : 1;
- if (n === null || isNaN(n)) {
- // only flow one buffer at a time
- if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
- }
- if (n <= 0) return 0;
- // If we're asking for more than the target buffer level,
- // then raise the water mark. Bump up to the next highest
- // power of 2, to prevent increasing it excessively in tiny
- // amounts.
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
- // don't have that much. return null, unless we've ended.
- if (n > state.length) {
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- } else {
- return state.length;
- }
- }
- return n;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function (n) {
- debug('read', n);
- var state = this._readableState;
- var nOrig = n;
- if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0) endReadable(this);
- return null;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- }
- if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0) state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- }
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
- var ret;
- if (n > 0) ret = fromList(n, state);else ret = null;
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- }
- state.length -= n;
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (state.length === 0 && !state.ended) state.needReadable = true;
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
- if (ret !== null) this.emit('data', ret);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.ended) return;
- if (state.decoder) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
- }
- }
- function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- processNextTick(maybeReadMore_, stream, state);
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;else len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function (n) {
- this.emit('error', new Error('not implemented'));
- };
- Readable.prototype.pipe = function (dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- debug('onunpipe');
- if (readable === src) {
- cleanup();
- }
- }
- function onend() {
- debug('onend');
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- var cleanedUp = false;
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- src.removeListener('data', ondata);
- cleanedUp = true;
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
- }
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- var ret = dest.write(chunk);
- if (false === ret) {
- // If the user unpiped during `dest.write()`, it is possible
- // to get stuck in a permanently paused state if that write
- // also returned false.
- // => Check whether `dest` is still a piping destination.
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
- debug('false write response, pause', src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- }
- src.pause();
- }
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
- }
- // Make sure our error handler is attached before userland ones.
- prependListener(dest, 'error', onerror);
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function () {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain) state.awaitDrain--;
- if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
- }
- Readable.prototype.unpipe = function (dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0) return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes) return this;
- if (!dest) dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest) dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- for (var _i = 0; _i < len; _i++) {
- dests[_i].emit('unpipe', this);
- }return this;
- }
- // try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1) return this;
- state.pipes.splice(i, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function (ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- // If listening to data, and it has not explicitly been paused,
- // then call resume to start the flow of data on the next tick.
- if (ev === 'data' && false !== this._readableState.flowing) {
- this.resume();
- }
- if (ev === 'readable' && !this._readableState.endEmitted) {
- var state = this._readableState;
- if (!state.readableListening) {
- state.readableListening = true;
- state.emittedReadable = false;
- state.needReadable = true;
- if (!state.reading) {
- processNextTick(nReadingNextTick, this);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- function nReadingNextTick(self) {
- debug('readable nexttick read 0');
- self.read(0);
- }
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function () {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- resume(this, state);
- }
- return this;
- };
- function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- processNextTick(resume_, stream, state);
- }
- }
- function resume_(stream, state) {
- if (!state.reading) {
- debug('resume read 0');
- stream.read(0);
- }
- state.resumeScheduled = false;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading) stream.read(0);
- }
- Readable.prototype.pause = function () {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
- };
- function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- if (state.flowing) {
- do {
- var chunk = stream.read();
- } while (null !== chunk && state.flowing);
- }
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function (stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function () {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function (chunk) {
- debug('wrapped data');
- if (state.decoder) chunk = state.decoder.write(chunk);
- // don't skip over falsy values in objectMode
- if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (this[i] === undefined && typeof stream[i] === 'function') {
- this[i] = function (method) {
- return function () {
- return stream[method].apply(stream, arguments);
- };
- }(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function (ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function (n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- function fromList(n, state) {
- var list = state.buffer;
- var length = state.length;
- var stringMode = !!state.decoder;
- var objectMode = !!state.objectMode;
- var ret;
- // nothing in the list, definitely empty.
- if (list.length === 0) return null;
- if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
- // read it all, truncate the array.
- if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
- list.length = 0;
- } else {
- // read just some of it.
- if (n < list[0].length) {
- // just take a part of the first list item.
- // slice is the same for buffers and strings.
- var buf = list[0];
- ret = buf.slice(0, n);
- list[0] = buf.slice(n);
- } else if (n === list[0].length) {
- // first list is a perfect match
- ret = list.shift();
- } else {
- // complex case.
- // we have enough to cover it, but it spans past the first buffer.
- if (stringMode) ret = '';else ret = bufferShim.allocUnsafe(n);
- var c = 0;
- for (var i = 0, l = list.length; i < l && c < n; i++) {
- var _buf = list[0];
- var cpy = Math.min(n - c, _buf.length);
- if (stringMode) ret += _buf.slice(0, cpy);else _buf.copy(ret, c, 0, cpy);
- if (cpy < _buf.length) list[0] = _buf.slice(cpy);else list.shift();
- c += cpy;
- }
- }
- }
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
- if (!state.endEmitted) {
- state.ended = true;
- processNextTick(endReadableNT, state, stream);
- }
- }
- function endReadableNT(state, stream) {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf(xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 223 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- 'use strict';
- module.exports = Transform;
- var Duplex = __webpack_require__(66);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(stream) {
- this.afterTransform = function (er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- this.writeencoding = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (data !== null && data !== undefined) stream.push(data);
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
- Duplex.call(this, options);
- this._transformState = new TransformState(this);
- // when the writable side finishes, then flush out anything remaining.
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
- if (typeof options.flush === 'function') this._flush = options.flush;
- }
- this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er) {
- done(stream, er);
- });else done(stream);
- });
- }
- Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('Not implemented');
- };
- Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function (n) {
- var ts = this._transformState;
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er) {
- if (er) return stream.emit('error', er);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
- if (ws.length) throw new Error('Calling transform done when ws.length != 0');
- if (ts.transforming) throw new Error('Calling transform done when still transforming');
- return stream.push(null);
- }
- /***/ },
- /* 224 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process, setImmediate) {// A bit simpler than readable streams.
- // Implement an async ._write(chunk, encoding, cb), and it'll handle all
- // the drain event emission and buffering.
- 'use strict';
- module.exports = Writable;
- /*<replacement>*/
- var processNextTick = __webpack_require__(64);
- /*</replacement>*/
- /*<replacement>*/
- var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- /*<replacement>*/
- var internalUtil = {
- deprecate: __webpack_require__(227)
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(9);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(30).EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*<replacement>*/
- var bufferShim = __webpack_require__(167);
- /*</replacement>*/
- util.inherits(Writable, Stream);
- function nop() {}
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- this.next = null;
- }
- var Duplex;
- function WritableState(options, stream) {
- Duplex = Duplex || __webpack_require__(66);
- options = options || {};
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function (er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.bufferedRequest = null;
- this.lastBufferedRequest = null;
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- // count buffered requests
- this.bufferedRequestCount = 0;
- // allocate the first CorkedRequest, there is always
- // one allocated and free to use, and we maintain at most two
- this.corkedRequestsFree = new CorkedRequest(this);
- }
- WritableState.prototype.getBuffer = function writableStateGetBuffer() {
- var current = this.bufferedRequest;
- var out = [];
- while (current) {
- out.push(current);
- current = current.next;
- }
- return out;
- };
- (function () {
- try {
- Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function () {
- return this.getBuffer();
- }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
- });
- } catch (_) {}
- })();
- var Duplex;
- function Writable(options) {
- Duplex = Duplex || __webpack_require__(66);
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- if (options) {
- if (typeof options.write === 'function') this._write = options.write;
- if (typeof options.writev === 'function') this._writev = options.writev;
- }
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function () {
- this.emit('error', new Error('Cannot pipe, not readable'));
- };
- function writeAfterEnd(stream, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- processNextTick(cb, er);
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- var er = false;
- // Always throw error if a null is written
- // if we are not in object mode then throw
- // if it is not a buffer, string, or undefined.
- if (chunk === null) {
- er = new TypeError('May not write null values to stream');
- } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- if (er) {
- stream.emit('error', er);
- processNextTick(cb, er);
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function (chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
- if (typeof cb !== 'function') cb = nop;
- if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- }
- return ret;
- };
- Writable.prototype.cork = function () {
- var state = this._writableState;
- state.corked++;
- };
- Writable.prototype.uncork = function () {
- var state = this._writableState;
- if (state.corked) {
- state.corked--;
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
- }
- };
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
- // node::ParseEncoding() requires lower case.
- if (typeof encoding === 'string') encoding = encoding.toLowerCase();
- 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);
- this._writableState.defaultEncoding = encoding;
- return this;
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
- chunk = bufferShim.from(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret) state.needDrain = true;
- if (state.writing || state.corked) {
- var last = state.lastBufferedRequest;
- state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
- if (last) {
- last.next = state.lastBufferedRequest;
- } else {
- state.bufferedRequest = state.lastBufferedRequest;
- }
- state.bufferedRequestCount += 1;
- } else {
- doWrite(stream, state, false, len, chunk, encoding, cb);
- }
- return ret;
- }
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- --state.pendingcb;
- if (sync) processNextTick(cb, er);else cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er) onwriteError(stream, state, sync, er, cb);else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(state);
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
- clearBuffer(stream, state);
- }
- if (sync) {
- /*<replacement>*/
- asyncWrite(afterWrite, stream, state, finished, cb);
- /*</replacement>*/
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished) onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- var entry = state.bufferedRequest;
- if (stream._writev && entry && entry.next) {
- // Fast case, write everything using _writev()
- var l = state.bufferedRequestCount;
- var buffer = new Array(l);
- var holder = state.corkedRequestsFree;
- holder.entry = entry;
- var count = 0;
- while (entry) {
- buffer[count] = entry;
- entry = entry.next;
- count += 1;
- }
- doWrite(stream, state, true, state.length, buffer, '', holder.finish);
- // doWrite is almost always async, defer these to save a bit of time
- // as the hot path ends with doWrite
- state.pendingcb++;
- state.lastBufferedRequest = null;
- if (holder.next) {
- state.corkedRequestsFree = holder.next;
- holder.next = null;
- } else {
- state.corkedRequestsFree = new CorkedRequest(state);
- }
- } else {
- // Slow case, write chunks one-by-one
- while (entry) {
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, false, len, chunk, encoding, cb);
- entry = entry.next;
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- break;
- }
- }
- if (entry === null) state.lastBufferedRequest = null;
- }
- state.bufferedRequestCount = 0;
- state.bufferedRequest = entry;
- state.bufferProcessing = false;
- }
- Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('not implemented'));
- };
- Writable.prototype._writev = null;
- Writable.prototype.end = function (chunk, encoding, cb) {
- var state = this._writableState;
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished) endWritable(this, state, cb);
- };
- function needFinish(state) {
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
- }
- function prefinish(stream, state) {
- if (!state.prefinished) {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
- function finishMaybe(stream, state) {
- var need = needFinish(state);
- if (need) {
- if (state.pendingcb === 0) {
- prefinish(stream, state);
- state.finished = true;
- stream.emit('finish');
- } else {
- prefinish(stream, state);
- }
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished) processNextTick(cb);else stream.once('finish', cb);
- }
- state.ended = true;
- stream.writable = false;
- }
- // It seems a linked list but it is not
- // there will be only 2 of these for each stream
- function CorkedRequest(state) {
- var _this = this;
- this.next = null;
- this.entry = null;
- this.finish = function (err) {
- var entry = _this.entry;
- _this.entry = null;
- while (entry) {
- var cb = entry.callback;
- state.pendingcb--;
- cb(err);
- entry = entry.next;
- }
- if (state.corkedRequestsFree) {
- state.corkedRequestsFree.next = _this;
- } else {
- state.corkedRequestsFree = _this;
- }
- };
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(74).setImmediate))
- /***/ },
- /* 225 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {var Stream = (function (){
- try {
- return __webpack_require__(9); // hack to fix a circular dependency issue when used with browserify
- } catch(_){}
- }());
- exports = module.exports = __webpack_require__(222);
- exports.Stream = Stream || exports;
- exports.Readable = exports;
- exports.Writable = __webpack_require__(224);
- exports.Duplex = __webpack_require__(66);
- exports.Transform = __webpack_require__(223);
- exports.PassThrough = __webpack_require__(576);
- if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
- module.exports = Stream;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 226 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- 'use strict';
- var punycode = __webpack_require__(545);
- var util = __webpack_require__(578);
- exports.parse = urlParse;
- exports.resolve = urlResolve;
- exports.resolveObject = urlResolveObject;
- exports.format = urlFormat;
- exports.Url = Url;
- function Url() {
- this.protocol = null;
- this.slashes = null;
- this.auth = null;
- this.host = null;
- this.port = null;
- this.hostname = null;
- this.hash = null;
- this.search = null;
- this.query = null;
- this.pathname = null;
- this.path = null;
- this.href = null;
- }
- // Reference: RFC 3986, RFC 1808, RFC 2396
- // define these here so at least they only have to be
- // compiled once on the first module load.
- var protocolPattern = /^([a-z0-9.+-]+:)/i,
- portPattern = /:[0-9]*$/,
- // Special case for a simple path URL
- simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
- // RFC 2396: characters reserved for delimiting URLs.
- // We actually just auto-escape these.
- delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
- // RFC 2396: characters not allowed for various reasons.
- unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
- // Allowed by RFCs, but cause of XSS attacks. Always escape these.
- autoEscape = ['\''].concat(unwise),
- // Characters that are never ever allowed in a hostname.
- // Note that any invalid chars are also handled, but these
- // are the ones that are *expected* to be seen, so we fast-path
- // them.
- nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
- hostEndingChars = ['/', '?', '#'],
- hostnameMaxLen = 255,
- hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
- hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
- // protocols that can allow "unsafe" and "unwise" chars.
- unsafeProtocol = {
- 'javascript': true,
- 'javascript:': true
- },
- // protocols that never have a hostname.
- hostlessProtocol = {
- 'javascript': true,
- 'javascript:': true
- },
- // protocols that always contain a // bit.
- slashedProtocol = {
- 'http': true,
- 'https': true,
- 'ftp': true,
- 'gopher': true,
- 'file': true,
- 'http:': true,
- 'https:': true,
- 'ftp:': true,
- 'gopher:': true,
- 'file:': true
- },
- querystring = __webpack_require__(548);
- function urlParse(url, parseQueryString, slashesDenoteHost) {
- if (url && util.isObject(url) && url instanceof Url) return url;
- var u = new Url;
- u.parse(url, parseQueryString, slashesDenoteHost);
- return u;
- }
- Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
- if (!util.isString(url)) {
- throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
- }
- // Copy chrome, IE, opera backslash-handling behavior.
- // Back slashes before the query string get converted to forward slashes
- // See: https://code.google.com/p/chromium/issues/detail?id=25916
- var queryIndex = url.indexOf('?'),
- splitter =
- (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
- uSplit = url.split(splitter),
- slashRegex = /\\/g;
- uSplit[0] = uSplit[0].replace(slashRegex, '/');
- url = uSplit.join(splitter);
- var rest = url;
- // trim before proceeding.
- // This is to support parse stuff like " http://foo.com \n"
- rest = rest.trim();
- if (!slashesDenoteHost && url.split('#').length === 1) {
- // Try fast path regexp
- var simplePath = simplePathPattern.exec(rest);
- if (simplePath) {
- this.path = rest;
- this.href = rest;
- this.pathname = simplePath[1];
- if (simplePath[2]) {
- this.search = simplePath[2];
- if (parseQueryString) {
- this.query = querystring.parse(this.search.substr(1));
- } else {
- this.query = this.search.substr(1);
- }
- } else if (parseQueryString) {
- this.search = '';
- this.query = {};
- }
- return this;
- }
- }
- var proto = protocolPattern.exec(rest);
- if (proto) {
- proto = proto[0];
- var lowerProto = proto.toLowerCase();
- this.protocol = lowerProto;
- rest = rest.substr(proto.length);
- }
- // figure out if it's got a host
- // user@server is *always* interpreted as a hostname, and url
- // resolution will treat //foo/bar as host=foo,path=bar because that's
- // how the browser resolves relative URLs.
- if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
- var slashes = rest.substr(0, 2) === '//';
- if (slashes && !(proto && hostlessProtocol[proto])) {
- rest = rest.substr(2);
- this.slashes = true;
- }
- }
- if (!hostlessProtocol[proto] &&
- (slashes || (proto && !slashedProtocol[proto]))) {
- // there's a hostname.
- // the first instance of /, ?, ;, or # ends the host.
- //
- // If there is an @ in the hostname, then non-host chars *are* allowed
- // to the left of the last @ sign, unless some host-ending character
- // comes *before* the @-sign.
- // URLs are obnoxious.
- //
- // ex:
- // http://a@b@c/ => user:a@b host:c
- // http://a@b?@c => user:a host:c path:/?@c
- // v0.12 TODO(isaacs): This is not quite how Chrome does things.
- // Review our test case against browsers more comprehensively.
- // find the first instance of any hostEndingChars
- var hostEnd = -1;
- for (var i = 0; i < hostEndingChars.length; i++) {
- var hec = rest.indexOf(hostEndingChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
- hostEnd = hec;
- }
- // at this point, either we have an explicit point where the
- // auth portion cannot go past, or the last @ char is the decider.
- var auth, atSign;
- if (hostEnd === -1) {
- // atSign can be anywhere.
- atSign = rest.lastIndexOf('@');
- } else {
- // atSign must be in auth portion.
- // http://a@b/c@d => host:b auth:a path:/c@d
- atSign = rest.lastIndexOf('@', hostEnd);
- }
- // Now we have a portion which is definitely the auth.
- // Pull that off.
- if (atSign !== -1) {
- auth = rest.slice(0, atSign);
- rest = rest.slice(atSign + 1);
- this.auth = decodeURIComponent(auth);
- }
- // the host is the remaining to the left of the first non-host char
- hostEnd = -1;
- for (var i = 0; i < nonHostChars.length; i++) {
- var hec = rest.indexOf(nonHostChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
- hostEnd = hec;
- }
- // if we still have not hit it, then the entire thing is a host.
- if (hostEnd === -1)
- hostEnd = rest.length;
- this.host = rest.slice(0, hostEnd);
- rest = rest.slice(hostEnd);
- // pull out port.
- this.parseHost();
- // we've indicated that there is a hostname,
- // so even if it's empty, it has to be present.
- this.hostname = this.hostname || '';
- // if hostname begins with [ and ends with ]
- // assume that it's an IPv6 address.
- var ipv6Hostname = this.hostname[0] === '[' &&
- this.hostname[this.hostname.length - 1] === ']';
- // validate a little.
- if (!ipv6Hostname) {
- var hostparts = this.hostname.split(/\./);
- for (var i = 0, l = hostparts.length; i < l; i++) {
- var part = hostparts[i];
- if (!part) continue;
- if (!part.match(hostnamePartPattern)) {
- var newpart = '';
- for (var j = 0, k = part.length; j < k; j++) {
- if (part.charCodeAt(j) > 127) {
- // we replace non-ASCII char with a temporary placeholder
- // we need this to make sure size of hostname is not
- // broken by replacing non-ASCII by nothing
- newpart += 'x';
- } else {
- newpart += part[j];
- }
- }
- // we test again with ASCII char only
- if (!newpart.match(hostnamePartPattern)) {
- var validParts = hostparts.slice(0, i);
- var notHost = hostparts.slice(i + 1);
- var bit = part.match(hostnamePartStart);
- if (bit) {
- validParts.push(bit[1]);
- notHost.unshift(bit[2]);
- }
- if (notHost.length) {
- rest = '/' + notHost.join('.') + rest;
- }
- this.hostname = validParts.join('.');
- break;
- }
- }
- }
- }
- if (this.hostname.length > hostnameMaxLen) {
- this.hostname = '';
- } else {
- // hostnames are always lower case.
- this.hostname = this.hostname.toLowerCase();
- }
- if (!ipv6Hostname) {
- // IDNA Support: Returns a punycoded representation of "domain".
- // It only converts parts of the domain name that
- // have non-ASCII characters, i.e. it doesn't matter if
- // you call it with a domain that already is ASCII-only.
- this.hostname = punycode.toASCII(this.hostname);
- }
- var p = this.port ? ':' + this.port : '';
- var h = this.hostname || '';
- this.host = h + p;
- this.href += this.host;
- // strip [ and ] from the hostname
- // the host field still retains them, though
- if (ipv6Hostname) {
- this.hostname = this.hostname.substr(1, this.hostname.length - 2);
- if (rest[0] !== '/') {
- rest = '/' + rest;
- }
- }
- }
- // now rest is set to the post-host stuff.
- // chop off any delim chars.
- if (!unsafeProtocol[lowerProto]) {
- // First, make 100% sure that any "autoEscape" chars get
- // escaped, even if encodeURIComponent doesn't think they
- // need to be.
- for (var i = 0, l = autoEscape.length; i < l; i++) {
- var ae = autoEscape[i];
- if (rest.indexOf(ae) === -1)
- continue;
- var esc = encodeURIComponent(ae);
- if (esc === ae) {
- esc = escape(ae);
- }
- rest = rest.split(ae).join(esc);
- }
- }
- // chop off from the tail first.
- var hash = rest.indexOf('#');
- if (hash !== -1) {
- // got a fragment string.
- this.hash = rest.substr(hash);
- rest = rest.slice(0, hash);
- }
- var qm = rest.indexOf('?');
- if (qm !== -1) {
- this.search = rest.substr(qm);
- this.query = rest.substr(qm + 1);
- if (parseQueryString) {
- this.query = querystring.parse(this.query);
- }
- rest = rest.slice(0, qm);
- } else if (parseQueryString) {
- // no query string, but parseQueryString still requested
- this.search = '';
- this.query = {};
- }
- if (rest) this.pathname = rest;
- if (slashedProtocol[lowerProto] &&
- this.hostname && !this.pathname) {
- this.pathname = '/';
- }
- //to support http.request
- if (this.pathname || this.search) {
- var p = this.pathname || '';
- var s = this.search || '';
- this.path = p + s;
- }
- // finally, reconstruct the href based on what has been validated.
- this.href = this.format();
- return this;
- };
- // format a parsed object into a url string
- function urlFormat(obj) {
- // ensure it's an object, and not a string url.
- // If it's an obj, this is a no-op.
- // this way, you can call url_format() on strings
- // to clean up potentially wonky urls.
- if (util.isString(obj)) obj = urlParse(obj);
- if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
- return obj.format();
- }
- Url.prototype.format = function() {
- var auth = this.auth || '';
- if (auth) {
- auth = encodeURIComponent(auth);
- auth = auth.replace(/%3A/i, ':');
- auth += '@';
- }
- var protocol = this.protocol || '',
- pathname = this.pathname || '',
- hash = this.hash || '',
- host = false,
- query = '';
- if (this.host) {
- host = auth + this.host;
- } else if (this.hostname) {
- host = auth + (this.hostname.indexOf(':') === -1 ?
- this.hostname :
- '[' + this.hostname + ']');
- if (this.port) {
- host += ':' + this.port;
- }
- }
- if (this.query &&
- util.isObject(this.query) &&
- Object.keys(this.query).length) {
- query = querystring.stringify(this.query);
- }
- var search = this.search || (query && ('?' + query)) || '';
- if (protocol && protocol.substr(-1) !== ':') protocol += ':';
- // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
- // unless they had them to begin with.
- if (this.slashes ||
- (!protocol || slashedProtocol[protocol]) && host !== false) {
- host = '//' + (host || '');
- if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
- } else if (!host) {
- host = '';
- }
- if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
- if (search && search.charAt(0) !== '?') search = '?' + search;
- pathname = pathname.replace(/[?#]/g, function(match) {
- return encodeURIComponent(match);
- });
- search = search.replace('#', '%23');
- return protocol + host + pathname + search + hash;
- };
- function urlResolve(source, relative) {
- return urlParse(source, false, true).resolve(relative);
- }
- Url.prototype.resolve = function(relative) {
- return this.resolveObject(urlParse(relative, false, true)).format();
- };
- function urlResolveObject(source, relative) {
- if (!source) return relative;
- return urlParse(source, false, true).resolveObject(relative);
- }
- Url.prototype.resolveObject = function(relative) {
- if (util.isString(relative)) {
- var rel = new Url();
- rel.parse(relative, false, true);
- relative = rel;
- }
- var result = new Url();
- var tkeys = Object.keys(this);
- for (var tk = 0; tk < tkeys.length; tk++) {
- var tkey = tkeys[tk];
- result[tkey] = this[tkey];
- }
- // hash is always overridden, no matter what.
- // even href="" will remove it.
- result.hash = relative.hash;
- // if the relative url is empty, then there's nothing left to do here.
- if (relative.href === '') {
- result.href = result.format();
- return result;
- }
- // hrefs like //foo/bar always cut to the protocol.
- if (relative.slashes && !relative.protocol) {
- // take everything except the protocol from relative
- var rkeys = Object.keys(relative);
- for (var rk = 0; rk < rkeys.length; rk++) {
- var rkey = rkeys[rk];
- if (rkey !== 'protocol')
- result[rkey] = relative[rkey];
- }
- //urlParse appends trailing / to urls like http://www.example.com
- if (slashedProtocol[result.protocol] &&
- result.hostname && !result.pathname) {
- result.path = result.pathname = '/';
- }
- result.href = result.format();
- return result;
- }
- if (relative.protocol && relative.protocol !== result.protocol) {
- // if it's a known url protocol, then changing
- // the protocol does weird things
- // first, if it's not file:, then we MUST have a host,
- // and if there was a path
- // to begin with, then we MUST have a path.
- // if it is file:, then the host is dropped,
- // because that's known to be hostless.
- // anything else is assumed to be absolute.
- if (!slashedProtocol[relative.protocol]) {
- var keys = Object.keys(relative);
- for (var v = 0; v < keys.length; v++) {
- var k = keys[v];
- result[k] = relative[k];
- }
- result.href = result.format();
- return result;
- }
- result.protocol = relative.protocol;
- if (!relative.host && !hostlessProtocol[relative.protocol]) {
- var relPath = (relative.pathname || '').split('/');
- while (relPath.length && !(relative.host = relPath.shift()));
- if (!relative.host) relative.host = '';
- if (!relative.hostname) relative.hostname = '';
- if (relPath[0] !== '') relPath.unshift('');
- if (relPath.length < 2) relPath.unshift('');
- result.pathname = relPath.join('/');
- } else {
- result.pathname = relative.pathname;
- }
- result.search = relative.search;
- result.query = relative.query;
- result.host = relative.host || '';
- result.auth = relative.auth;
- result.hostname = relative.hostname || relative.host;
- result.port = relative.port;
- // to support http.request
- if (result.pathname || result.search) {
- var p = result.pathname || '';
- var s = result.search || '';
- result.path = p + s;
- }
- result.slashes = result.slashes || relative.slashes;
- result.href = result.format();
- return result;
- }
- var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
- isRelAbs = (
- relative.host ||
- relative.pathname && relative.pathname.charAt(0) === '/'
- ),
- mustEndAbs = (isRelAbs || isSourceAbs ||
- (result.host && relative.pathname)),
- removeAllDots = mustEndAbs,
- srcPath = result.pathname && result.pathname.split('/') || [],
- relPath = relative.pathname && relative.pathname.split('/') || [],
- psychotic = result.protocol && !slashedProtocol[result.protocol];
- // if the url is a non-slashed url, then relative
- // links like ../.. should be able
- // to crawl up to the hostname, as well. This is strange.
- // result.protocol has already been set by now.
- // Later on, put the first path part into the host field.
- if (psychotic) {
- result.hostname = '';
- result.port = null;
- if (result.host) {
- if (srcPath[0] === '') srcPath[0] = result.host;
- else srcPath.unshift(result.host);
- }
- result.host = '';
- if (relative.protocol) {
- relative.hostname = null;
- relative.port = null;
- if (relative.host) {
- if (relPath[0] === '') relPath[0] = relative.host;
- else relPath.unshift(relative.host);
- }
- relative.host = null;
- }
- mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
- }
- if (isRelAbs) {
- // it's absolute.
- result.host = (relative.host || relative.host === '') ?
- relative.host : result.host;
- result.hostname = (relative.hostname || relative.hostname === '') ?
- relative.hostname : result.hostname;
- result.search = relative.search;
- result.query = relative.query;
- srcPath = relPath;
- // fall through to the dot-handling below.
- } else if (relPath.length) {
- // it's relative
- // throw away the existing file, and take the new path instead.
- if (!srcPath) srcPath = [];
- srcPath.pop();
- srcPath = srcPath.concat(relPath);
- result.search = relative.search;
- result.query = relative.query;
- } else if (!util.isNullOrUndefined(relative.search)) {
- // just pull out the search.
- // like href='?foo'.
- // Put this after the other two cases because it simplifies the booleans
- if (psychotic) {
- result.hostname = result.host = srcPath.shift();
- //occationaly the auth can get stuck only in host
- //this especially happens in cases like
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ?
- result.host.split('@') : false;
- if (authInHost) {
- result.auth = authInHost.shift();
- result.host = result.hostname = authInHost.shift();
- }
- }
- result.search = relative.search;
- result.query = relative.query;
- //to support http.request
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
- result.path = (result.pathname ? result.pathname : '') +
- (result.search ? result.search : '');
- }
- result.href = result.format();
- return result;
- }
- if (!srcPath.length) {
- // no path at all. easy.
- // we've already handled the other stuff above.
- result.pathname = null;
- //to support http.request
- if (result.search) {
- result.path = '/' + result.search;
- } else {
- result.path = null;
- }
- result.href = result.format();
- return result;
- }
- // if a url ENDs in . or .., then it must get a trailing slash.
- // however, if it ends in anything else non-slashy,
- // then it must NOT get a trailing slash.
- var last = srcPath.slice(-1)[0];
- var hasTrailingSlash = (
- (result.host || relative.host || srcPath.length > 1) &&
- (last === '.' || last === '..') || last === '');
- // strip single dots, resolve double dots to parent dir
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = srcPath.length; i >= 0; i--) {
- last = srcPath[i];
- if (last === '.') {
- srcPath.splice(i, 1);
- } else if (last === '..') {
- srcPath.splice(i, 1);
- up++;
- } else if (up) {
- srcPath.splice(i, 1);
- up--;
- }
- }
- // if the path is allowed to go above the root, restore leading ..s
- if (!mustEndAbs && !removeAllDots) {
- for (; up--; up) {
- srcPath.unshift('..');
- }
- }
- if (mustEndAbs && srcPath[0] !== '' &&
- (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
- srcPath.unshift('');
- }
- if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
- srcPath.push('');
- }
- var isAbsolute = srcPath[0] === '' ||
- (srcPath[0] && srcPath[0].charAt(0) === '/');
- // put the host back
- if (psychotic) {
- result.hostname = result.host = isAbsolute ? '' :
- srcPath.length ? srcPath.shift() : '';
- //occationaly the auth can get stuck only in host
- //this especially happens in cases like
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ?
- result.host.split('@') : false;
- if (authInHost) {
- result.auth = authInHost.shift();
- result.host = result.hostname = authInHost.shift();
- }
- }
- mustEndAbs = mustEndAbs || (result.host && srcPath.length);
- if (mustEndAbs && !isAbsolute) {
- srcPath.unshift('');
- }
- if (!srcPath.length) {
- result.pathname = null;
- result.path = null;
- } else {
- result.pathname = srcPath.join('/');
- }
- //to support request.http
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
- result.path = (result.pathname ? result.pathname : '') +
- (result.search ? result.search : '');
- }
- result.auth = relative.auth || result.auth;
- result.slashes = result.slashes || relative.slashes;
- result.href = result.format();
- return result;
- };
- Url.prototype.parseHost = function() {
- var host = this.host;
- var port = portPattern.exec(host);
- if (port) {
- port = port[0];
- if (port !== ':') {
- this.port = port.substr(1);
- }
- host = host.substr(0, host.length - port.length);
- }
- if (host) this.hostname = host;
- };
- /***/ },
- /* 227 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {
- /**
- * Module exports.
- */
- module.exports = deprecate;
- /**
- * Mark that a method should not be used.
- * Returns a modified function which warns once by default.
- *
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
- *
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
- * will throw an Error when invoked.
- *
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
- * will invoke `console.trace()` instead of `console.error()`.
- *
- * @param {Function} fn - the function to deprecate
- * @param {String} msg - the string to print to the console when `fn` is invoked
- * @returns {Function} a new "deprecated" version of `fn`
- * @api public
- */
- function deprecate (fn, msg) {
- if (config('noDeprecation')) {
- return fn;
- }
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (config('throwDeprecation')) {
- throw new Error(msg);
- } else if (config('traceDeprecation')) {
- console.trace(msg);
- } else {
- console.warn(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
- return deprecated;
- }
- /**
- * Checks `localStorage` for boolean values for the given `name`.
- *
- * @param {String} name
- * @returns {Boolean}
- * @api private
- */
- function config (name) {
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
- try {
- if (!global.localStorage) return false;
- } catch (_) {
- return false;
- }
- var val = global.localStorage[name];
- if (null == val) return false;
- return String(val).toLowerCase() === 'true';
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 228 */
- /***/ function(module, exports) {
- // Returns a wrapper function that returns a wrapped callback
- // The wrapper function should do some stuff, and return a
- // presumably different callback function.
- // This makes sure that own properties are retained, so that
- // decorations and such are not lost along the way.
- module.exports = wrappy
- function wrappy (fn, cb) {
- if (fn && cb) return wrappy(fn)(cb)
- if (typeof fn !== 'function')
- throw new TypeError('need wrapper function')
- Object.keys(fn).forEach(function (k) {
- wrapper[k] = fn[k]
- })
- return wrapper
- function wrapper() {
- var args = new Array(arguments.length)
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i]
- }
- var ret = fn.apply(this, args)
- var cb = args[args.length-1]
- if (typeof ret === 'function' && ret !== cb) {
- Object.keys(cb).forEach(function (k) {
- ret[k] = cb[k]
- })
- }
- return ret
- }
- }
- /***/ },
- /* 229 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- 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; };
- var multiaddr = __webpack_require__(524);
- var loadCommands = __webpack_require__(278);
- var getConfig = __webpack_require__(275);
- var getRequestAPI = __webpack_require__(279);
- function IpfsAPI(hostOrMultiaddr, port, opts) {
- var config = getConfig();
- try {
- var maddr = multiaddr(hostOrMultiaddr).nodeAddress();
- config.host = maddr.address;
- config.port = maddr.port;
- } catch (e) {
- if (typeof hostOrMultiaddr === 'string') {
- config.host = hostOrMultiaddr;
- config.port = port && (typeof port === 'undefined' ? 'undefined' : _typeof(port)) !== 'object' ? port : config.port;
- }
- }
- var lastIndex = arguments.length;
- while (!opts && lastIndex-- > 0) {
- opts = arguments[lastIndex];
- if (opts) break;
- }
- Object.assign(config, opts);
- // autoconfigure in browser
- if (!config.host && typeof window !== 'undefined') {
- var split = window.location.host.split(':');
- config.host = split[0];
- config.port = split[1];
- }
- var requestAPI = getRequestAPI(config);
- var cmds = loadCommands(requestAPI);
- cmds.send = requestAPI;
- cmds.Buffer = Buffer;
- return cmds;
- }
- exports = module.exports = IpfsAPI;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 230 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {"use strict";
- __webpack_require__(476);
- __webpack_require__(553);
- __webpack_require__(295);
- /* eslint max-len: 0 */
- if (global._babelPolyfill) {
- throw new Error("only one instance of babel-polyfill is allowed");
- }
- global._babelPolyfill = true;
- // Should be removed in the next major release:
- var DEFINE_PROPERTY = "defineProperty";
- function define(O, key, value) {
- O[key] || Object[DEFINE_PROPERTY](O, key, {
- writable: true,
- configurable: true,
- value: value
- });
- }
- define(String.prototype, "padLeft", "".padStart);
- define(String.prototype, "padRight", "".padEnd);
- "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) {
- [][key] && define(Array, key, Function.call.bind([][key]));
- });
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 231 */
- /***/ function(module, exports) {
- module.exports = {
- "modp1": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
- },
- "modp2": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
- },
- "modp5": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
- },
- "modp14": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
- },
- "modp15": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
- },
- "modp16": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
- },
- "modp17": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
- },
- "modp18": {
- "gen": "02",
- "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
- }
- };
- /***/ },
- /* 232 */
- /***/ function(module, exports) {
- module.exports = {
- "_args": [
- [
- "elliptic@^6.0.0",
- "/Users/ground-control/code/js-ipfs-api/node_modules/browserify-sign"
- ]
- ],
- "_from": "elliptic@>=6.0.0 <7.0.0",
- "_id": "[email protected]",
- "_inCache": true,
- "_installable": true,
- "_location": "/elliptic",
- "_nodeVersion": "6.0.0",
- "_npmOperationalInternal": {
- "host": "packages-16-east.internal.npmjs.com",
- "tmp": "tmp/elliptic-6.3.1.tgz_1465921413402_0.5202967382501811"
- },
- "_npmUser": {
- "email": "[email protected]",
- "name": "indutny"
- },
- "_npmVersion": "3.8.6",
- "_phantomChildren": {},
- "_requested": {
- "name": "elliptic",
- "raw": "elliptic@^6.0.0",
- "rawSpec": "^6.0.0",
- "scope": null,
- "spec": ">=6.0.0 <7.0.0",
- "type": "range"
- },
- "_requiredBy": [
- "/browserify-sign",
- "/create-ecdh"
- ],
- "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.1.tgz",
- "_shasum": "17781f2109ab0ec686b146bdcff5d2e8c6aeceda",
- "_shrinkwrap": null,
- "_spec": "elliptic@^6.0.0",
- "_where": "/Users/ground-control/code/js-ipfs-api/node_modules/browserify-sign",
- "author": {
- "email": "[email protected]",
- "name": "Fedor Indutny"
- },
- "bugs": {
- "url": "https://github.com/indutny/elliptic/issues"
- },
- "dependencies": {
- "bn.js": "^4.4.0",
- "brorand": "^1.0.1",
- "hash.js": "^1.0.0",
- "inherits": "^2.0.1"
- },
- "description": "EC cryptography",
- "devDependencies": {
- "brfs": "^1.4.3",
- "coveralls": "^2.11.3",
- "grunt": "^0.4.5",
- "grunt-browserify": "^5.0.0",
- "grunt-contrib-connect": "^1.0.0",
- "grunt-contrib-copy": "^1.0.0",
- "grunt-contrib-uglify": "^1.0.1",
- "grunt-mocha-istanbul": "^3.0.1",
- "grunt-saucelabs": "^8.6.2",
- "istanbul": "^0.4.2",
- "jscs": "^2.9.0",
- "jshint": "^2.6.0",
- "mocha": "^2.1.0"
- },
- "directories": {},
- "dist": {
- "shasum": "17781f2109ab0ec686b146bdcff5d2e8c6aeceda",
- "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.1.tgz"
- },
- "files": [
- "lib"
- ],
- "gitHead": "c53f5cf3d832c0073eb4a4ed423a464cbce68f3e",
- "homepage": "https://github.com/indutny/elliptic",
- "keywords": [
- "EC",
- "Elliptic",
- "curve",
- "Cryptography"
- ],
- "license": "MIT",
- "main": "lib/elliptic.js",
- "maintainers": [
- {
- "email": "[email protected]",
- "name": "indutny"
- }
- ],
- "name": "elliptic",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git+ssh://[email protected]/indutny/elliptic.git"
- },
- "scripts": {
- "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
- "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
- "lint": "npm run jscs && npm run jshint",
- "test": "npm run lint && npm run unit",
- "unit": "istanbul test _mocha --reporter=spec test/index.js",
- "version": "grunt dist && git add dist/"
- },
- "version": "6.3.1"
- };
- /***/ },
- /* 233 */
- /***/ function(module, exports) {
- module.exports = {
- "2.16.840.1.101.3.4.1.1": "aes-128-ecb",
- "2.16.840.1.101.3.4.1.2": "aes-128-cbc",
- "2.16.840.1.101.3.4.1.3": "aes-128-ofb",
- "2.16.840.1.101.3.4.1.4": "aes-128-cfb",
- "2.16.840.1.101.3.4.1.21": "aes-192-ecb",
- "2.16.840.1.101.3.4.1.22": "aes-192-cbc",
- "2.16.840.1.101.3.4.1.23": "aes-192-ofb",
- "2.16.840.1.101.3.4.1.24": "aes-192-cfb",
- "2.16.840.1.101.3.4.1.41": "aes-256-ecb",
- "2.16.840.1.101.3.4.1.42": "aes-256-cbc",
- "2.16.840.1.101.3.4.1.43": "aes-256-ofb",
- "2.16.840.1.101.3.4.1.44": "aes-256-cfb"
- };
- /***/ },
- /* 234 */
- /***/ function(module, exports) {
- module.exports = {
- "name": "ipfs-api",
- "version": "6.0.2",
- "description": "A client library for the IPFS API",
- "main": "lib/index.js",
- "jsnext:main": "src/index.js",
- "dependencies": {
- "async": "^2.0.0-rc.5",
- "babel-runtime": "^6.6.1",
- "bl": "^1.1.2",
- "bs58": "^3.0.0",
- "detect-node": "^2.0.3",
- "flatmap": "0.0.3",
- "glob": "^7.0.3",
- "ipfs-merkle-dag": "^0.6.0",
- "is-ipfs": "^0.2.0",
- "isstream": "^0.1.2",
- "multiaddr": "^2.0.0",
- "multipart-stream": "^2.0.1",
- "ndjson": "^1.4.3",
- "promisify-es6": "^1.0.1",
- "qs": "^6.1.0",
- "wreck": "^7.0.2"
- },
- "engines": {
- "node": ">=4.2.2"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/ipfs/js-ipfs-api"
- },
- "devDependencies": {
- "aegir": "^3.2.0",
- "chai": "^3.5.0",
- "gulp": "^3.9.1",
- "interface-ipfs-core": "^0.4.3",
- "ipfsd-ctl": "^0.14.0",
- "pre-commit": "^1.1.2",
- "stream-equal": "^0.1.8",
- "stream-http": "^2.2.0",
- "streamifier": "^0.1.1"
- },
- "scripts": {
- "test": "gulp test",
- "test:node": "gulp test:node",
- "test:browser": "gulp test:browser",
- "lint": "aegir-lint",
- "build": "gulp build",
- "release": "gulp release",
- "release-minor": "gulp release --type minor",
- "release-major": "gulp release --type major",
- "coverage": "gulp coverage",
- "coverage-publish": "aegir-coverage publish"
- },
- "pre-commit": [
- "lint",
- "test"
- ],
- "keywords": [
- "ipfs"
- ],
- "author": "Matt Bell <[email protected]>",
- "contributors": [
- "Alex Mingoia <[email protected]>",
- "Connor Keenan <[email protected]>",
- "David Braun <[email protected]>",
- "David Dias <[email protected]>",
- "Fil <[email protected]>",
- "Francisco Baio Dias <[email protected]>",
- "Gavin McDermott <[email protected]>",
- "Harlan T Wood <[email protected]>",
- "Harlan T Wood <[email protected]>",
- "Holodisc <[email protected]>",
- "Jason Carver <[email protected]>",
- "Jeromy <[email protected]>",
- "Juan Batiz-Benet <[email protected]>",
- "Kristoffer Ström <[email protected]>",
- "Matt Bell <[email protected]>",
- "Mithgol <[email protected]>",
- "Richard Littauer <[email protected]>",
- "Stephen Whitmore <[email protected]>",
- "Travis Person <[email protected]>",
- "Victor Bjelkholm <[email protected]>",
- "dignifiedquire <[email protected]>",
- "ethers <[email protected]>",
- "greenkeeperio-bot <[email protected]>",
- "haad <[email protected]>",
- "nginnever <[email protected]>",
- "priecint <[email protected]>",
- "samuli <[email protected]>"
- ],
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/ipfs/js-ipfs-api/issues"
- },
- "homepage": "https://github.com/ipfs/js-ipfs-api"
- };
- /***/ },
- /* 235 */
- /***/ function(module, exports, __webpack_require__) {
- var asn1 = __webpack_require__(77);
- var inherits = __webpack_require__(2);
- var api = exports;
- api.define = function define(name, body) {
- return new Entity(name, body);
- };
- function Entity(name, body) {
- this.name = name;
- this.body = body;
- this.decoders = {};
- this.encoders = {};
- };
- Entity.prototype._createNamed = function createNamed(base) {
- var named;
- try {
- named = __webpack_require__(583).runInThisContext(
- '(function ' + this.name + '(entity) {\n' +
- ' this._initNamed(entity);\n' +
- '})'
- );
- } catch (e) {
- named = function (entity) {
- this._initNamed(entity);
- };
- }
- inherits(named, base);
- named.prototype._initNamed = function initnamed(entity) {
- base.call(this, entity);
- };
- return new named(this);
- };
- Entity.prototype._getDecoder = function _getDecoder(enc) {
- enc = enc || 'der';
- // Lazily create decoder
- if (!this.decoders.hasOwnProperty(enc))
- this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
- return this.decoders[enc];
- };
- Entity.prototype.decode = function decode(data, enc, options) {
- return this._getDecoder(enc).decode(data, options);
- };
- Entity.prototype._getEncoder = function _getEncoder(enc) {
- enc = enc || 'der';
- // Lazily create encoder
- if (!this.encoders.hasOwnProperty(enc))
- this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
- return this.encoders[enc];
- };
- Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
- return this._getEncoder(enc).encode(data, reporter);
- };
- /***/ },
- /* 236 */
- /***/ function(module, exports, __webpack_require__) {
- var Reporter = __webpack_require__(67).Reporter;
- var EncoderBuffer = __webpack_require__(67).EncoderBuffer;
- var DecoderBuffer = __webpack_require__(67).DecoderBuffer;
- var assert = __webpack_require__(72);
- // Supported tags
- var tags = [
- 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
- 'gentime', 'utctime', 'null_', 'enum', 'int',
- 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
- 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
- ];
- // Public methods list
- var methods = [
- 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
- 'any', 'contains'
- ].concat(tags);
- // Overrided methods list
- var overrided = [
- '_peekTag', '_decodeTag', '_use',
- '_decodeStr', '_decodeObjid', '_decodeTime',
- '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
- '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
- '_encodeNull', '_encodeInt', '_encodeBool'
- ];
- function Node(enc, parent) {
- var state = {};
- this._baseState = state;
- state.enc = enc;
- state.parent = parent || null;
- state.children = null;
- // State
- state.tag = null;
- state.args = null;
- state.reverseArgs = null;
- state.choice = null;
- state.optional = false;
- state.any = false;
- state.obj = false;
- state.use = null;
- state.useDecoder = null;
- state.key = null;
- state['default'] = null;
- state.explicit = null;
- state.implicit = null;
- state.contains = null;
- // Should create new instance on each method
- if (!state.parent) {
- state.children = [];
- this._wrap();
- }
- }
- module.exports = Node;
- var stateProps = [
- 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
- 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
- 'implicit'
- ];
- Node.prototype.clone = function clone() {
- var state = this._baseState;
- var cstate = {};
- stateProps.forEach(function(prop) {
- cstate[prop] = state[prop];
- });
- var res = new this.constructor(cstate.parent);
- res._baseState = cstate;
- return res;
- };
- Node.prototype._wrap = function wrap() {
- var state = this._baseState;
- methods.forEach(function(method) {
- this[method] = function _wrappedMethod() {
- var clone = new this.constructor(this);
- state.children.push(clone);
- return clone[method].apply(clone, arguments);
- };
- }, this);
- };
- Node.prototype._init = function init(body) {
- var state = this._baseState;
- assert(state.parent === null);
- body.call(this);
- // Filter children
- state.children = state.children.filter(function(child) {
- return child._baseState.parent === this;
- }, this);
- assert.equal(state.children.length, 1, 'Root node can have only one child');
- };
- Node.prototype._useArgs = function useArgs(args) {
- var state = this._baseState;
- // Filter children and args
- var children = args.filter(function(arg) {
- return arg instanceof this.constructor;
- }, this);
- args = args.filter(function(arg) {
- return !(arg instanceof this.constructor);
- }, this);
- if (children.length !== 0) {
- assert(state.children === null);
- state.children = children;
- // Replace parent to maintain backward link
- children.forEach(function(child) {
- child._baseState.parent = this;
- }, this);
- }
- if (args.length !== 0) {
- assert(state.args === null);
- state.args = args;
- state.reverseArgs = args.map(function(arg) {
- if (typeof arg !== 'object' || arg.constructor !== Object)
- return arg;
- var res = {};
- Object.keys(arg).forEach(function(key) {
- if (key == (key | 0))
- key |= 0;
- var value = arg[key];
- res[value] = key;
- });
- return res;
- });
- }
- };
- //
- // Overrided methods
- //
- overrided.forEach(function(method) {
- Node.prototype[method] = function _overrided() {
- var state = this._baseState;
- throw new Error(method + ' not implemented for encoding: ' + state.enc);
- };
- });
- //
- // Public methods
- //
- tags.forEach(function(tag) {
- Node.prototype[tag] = function _tagMethod() {
- var state = this._baseState;
- var args = Array.prototype.slice.call(arguments);
- assert(state.tag === null);
- state.tag = tag;
- this._useArgs(args);
- return this;
- };
- });
- Node.prototype.use = function use(item) {
- var state = this._baseState;
- assert(state.use === null);
- state.use = item;
- return this;
- };
- Node.prototype.optional = function optional() {
- var state = this._baseState;
- state.optional = true;
- return this;
- };
- Node.prototype.def = function def(val) {
- var state = this._baseState;
- assert(state['default'] === null);
- state['default'] = val;
- state.optional = true;
- return this;
- };
- Node.prototype.explicit = function explicit(num) {
- var state = this._baseState;
- assert(state.explicit === null && state.implicit === null);
- state.explicit = num;
- return this;
- };
- Node.prototype.implicit = function implicit(num) {
- var state = this._baseState;
- assert(state.explicit === null && state.implicit === null);
- state.implicit = num;
- return this;
- };
- Node.prototype.obj = function obj() {
- var state = this._baseState;
- var args = Array.prototype.slice.call(arguments);
- state.obj = true;
- if (args.length !== 0)
- this._useArgs(args);
- return this;
- };
- Node.prototype.key = function key(newKey) {
- var state = this._baseState;
- assert(state.key === null);
- state.key = newKey;
- return this;
- };
- Node.prototype.any = function any() {
- var state = this._baseState;
- state.any = true;
- return this;
- };
- Node.prototype.choice = function choice(obj) {
- var state = this._baseState;
- assert(state.choice === null);
- state.choice = obj;
- this._useArgs(Object.keys(obj).map(function(key) {
- return obj[key];
- }));
- return this;
- };
- Node.prototype.contains = function contains(item) {
- var state = this._baseState;
- assert(state.use === null);
- state.contains = item;
- return this;
- };
- //
- // Decoding
- //
- Node.prototype._decode = function decode(input) {
- var state = this._baseState;
- // Decode root node
- if (state.parent === null)
- return input.wrapResult(state.children[0]._decode(input));
- var result = state['default'];
- var present = true;
- var prevKey;
- if (state.key !== null)
- prevKey = input.enterKey(state.key);
- // Check if tag is there
- if (state.optional) {
- var tag = null;
- if (state.explicit !== null)
- tag = state.explicit;
- else if (state.implicit !== null)
- tag = state.implicit;
- else if (state.tag !== null)
- tag = state.tag;
- if (tag === null && !state.any) {
- // Trial and Error
- var save = input.save();
- try {
- if (state.choice === null)
- this._decodeGeneric(state.tag, input);
- else
- this._decodeChoice(input);
- present = true;
- } catch (e) {
- present = false;
- }
- input.restore(save);
- } else {
- present = this._peekTag(input, tag, state.any);
- if (input.isError(present))
- return present;
- }
- }
- // Push object on stack
- var prevObj;
- if (state.obj && present)
- prevObj = input.enterObject();
- if (present) {
- // Unwrap explicit values
- if (state.explicit !== null) {
- var explicit = this._decodeTag(input, state.explicit);
- if (input.isError(explicit))
- return explicit;
- input = explicit;
- }
- // Unwrap implicit and normal values
- if (state.use === null && state.choice === null) {
- if (state.any)
- var save = input.save();
- var body = this._decodeTag(
- input,
- state.implicit !== null ? state.implicit : state.tag,
- state.any
- );
- if (input.isError(body))
- return body;
- if (state.any)
- result = input.raw(save);
- else
- input = body;
- }
- // Select proper method for tag
- if (state.any)
- result = result;
- else if (state.choice === null)
- result = this._decodeGeneric(state.tag, input);
- else
- result = this._decodeChoice(input);
- if (input.isError(result))
- return result;
- // Decode children
- if (!state.any && state.choice === null && state.children !== null) {
- state.children.forEach(function decodeChildren(child) {
- // NOTE: We are ignoring errors here, to let parser continue with other
- // parts of encoded data
- child._decode(input);
- });
- }
- // Decode contained/encoded by schema, only in bit or octet strings
- if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
- var data = new DecoderBuffer(result);
- result = this._getUse(state.contains, input._reporterState.obj)._decode(data);
- }
- }
- // Pop object
- if (state.obj && present)
- result = input.leaveObject(prevObj);
- // Set key
- if (state.key !== null && (result !== null || present === true))
- input.leaveKey(prevKey, state.key, result);
- return result;
- };
- Node.prototype._decodeGeneric = function decodeGeneric(tag, input) {
- var state = this._baseState;
- if (tag === 'seq' || tag === 'set')
- return null;
- if (tag === 'seqof' || tag === 'setof')
- return this._decodeList(input, tag, state.args[0]);
- else if (/str$/.test(tag))
- return this._decodeStr(input, tag);
- else if (tag === 'objid' && state.args)
- return this._decodeObjid(input, state.args[0], state.args[1]);
- else if (tag === 'objid')
- return this._decodeObjid(input, null, null);
- else if (tag === 'gentime' || tag === 'utctime')
- return this._decodeTime(input, tag);
- else if (tag === 'null_')
- return this._decodeNull(input);
- else if (tag === 'bool')
- return this._decodeBool(input);
- else if (tag === 'int' || tag === 'enum')
- return this._decodeInt(input, state.args && state.args[0]);
- else if (state.use !== null)
- return this._getUse(state.use, input._reporterState.obj)._decode(input);
- else
- return input.error('unknown tag: ' + tag);
- };
- Node.prototype._getUse = function _getUse(entity, obj) {
- var state = this._baseState;
- // Create altered use decoder if implicit is set
- state.useDecoder = this._use(entity, obj);
- assert(state.useDecoder._baseState.parent === null);
- state.useDecoder = state.useDecoder._baseState.children[0];
- if (state.implicit !== state.useDecoder._baseState.implicit) {
- state.useDecoder = state.useDecoder.clone();
- state.useDecoder._baseState.implicit = state.implicit;
- }
- return state.useDecoder;
- };
- Node.prototype._decodeChoice = function decodeChoice(input) {
- var state = this._baseState;
- var result = null;
- var match = false;
- Object.keys(state.choice).some(function(key) {
- var save = input.save();
- var node = state.choice[key];
- try {
- var value = node._decode(input);
- if (input.isError(value))
- return false;
- result = { type: key, value: value };
- match = true;
- } catch (e) {
- input.restore(save);
- return false;
- }
- return true;
- }, this);
- if (!match)
- return input.error('Choice not matched');
- return result;
- };
- //
- // Encoding
- //
- Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
- return new EncoderBuffer(data, this.reporter);
- };
- Node.prototype._encode = function encode(data, reporter, parent) {
- var state = this._baseState;
- if (state['default'] !== null && state['default'] === data)
- return;
- var result = this._encodeValue(data, reporter, parent);
- if (result === undefined)
- return;
- if (this._skipDefault(result, reporter, parent))
- return;
- return result;
- };
- Node.prototype._encodeValue = function encode(data, reporter, parent) {
- var state = this._baseState;
- // Decode root node
- if (state.parent === null)
- return state.children[0]._encode(data, reporter || new Reporter());
- var result = null;
- // Set reporter to share it with a child class
- this.reporter = reporter;
- // Check if data is there
- if (state.optional && data === undefined) {
- if (state['default'] !== null)
- data = state['default']
- else
- return;
- }
- // Encode children first
- var content = null;
- var primitive = false;
- if (state.any) {
- // Anything that was given is translated to buffer
- result = this._createEncoderBuffer(data);
- } else if (state.choice) {
- result = this._encodeChoice(data, reporter);
- } else if (state.contains) {
- content = this._getUse(state.contains, parent)._encode(data, reporter);
- primitive = true;
- } else if (state.children) {
- content = state.children.map(function(child) {
- if (child._baseState.tag === 'null_')
- return child._encode(null, reporter, data);
- if (child._baseState.key === null)
- return reporter.error('Child should have a key');
- var prevKey = reporter.enterKey(child._baseState.key);
- if (typeof data !== 'object')
- return reporter.error('Child expected, but input is not object');
- var res = child._encode(data[child._baseState.key], reporter, data);
- reporter.leaveKey(prevKey);
- return res;
- }, this).filter(function(child) {
- return child;
- });
- content = this._createEncoderBuffer(content);
- } else {
- if (state.tag === 'seqof' || state.tag === 'setof') {
- // TODO(indutny): this should be thrown on DSL level
- if (!(state.args && state.args.length === 1))
- return reporter.error('Too many args for : ' + state.tag);
- if (!Array.isArray(data))
- return reporter.error('seqof/setof, but data is not Array');
- var child = this.clone();
- child._baseState.implicit = null;
- content = this._createEncoderBuffer(data.map(function(item) {
- var state = this._baseState;
- return this._getUse(state.args[0], data)._encode(item, reporter);
- }, child));
- } else if (state.use !== null) {
- result = this._getUse(state.use, parent)._encode(data, reporter);
- } else {
- content = this._encodePrimitive(state.tag, data);
- primitive = true;
- }
- }
- // Encode data itself
- var result;
- if (!state.any && state.choice === null) {
- var tag = state.implicit !== null ? state.implicit : state.tag;
- var cls = state.implicit === null ? 'universal' : 'context';
- if (tag === null) {
- if (state.use === null)
- reporter.error('Tag could be ommited only for .use()');
- } else {
- if (state.use === null)
- result = this._encodeComposite(tag, primitive, cls, content);
- }
- }
- // Wrap in explicit
- if (state.explicit !== null)
- result = this._encodeComposite(state.explicit, false, 'context', result);
- return result;
- };
- Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
- var state = this._baseState;
- var node = state.choice[data.type];
- if (!node) {
- assert(
- false,
- data.type + ' not found in ' +
- JSON.stringify(Object.keys(state.choice)));
- }
- return node._encode(data.value, reporter);
- };
- Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
- var state = this._baseState;
- if (/str$/.test(tag))
- return this._encodeStr(data, tag);
- else if (tag === 'objid' && state.args)
- return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
- else if (tag === 'objid')
- return this._encodeObjid(data, null, null);
- else if (tag === 'gentime' || tag === 'utctime')
- return this._encodeTime(data, tag);
- else if (tag === 'null_')
- return this._encodeNull();
- else if (tag === 'int' || tag === 'enum')
- return this._encodeInt(data, state.args && state.reverseArgs[0]);
- else if (tag === 'bool')
- return this._encodeBool(data);
- else
- throw new Error('Unsupported tag: ' + tag);
- };
- Node.prototype._isNumstr = function isNumstr(str) {
- return /^[0-9 ]*$/.test(str);
- };
- Node.prototype._isPrintstr = function isPrintstr(str) {
- return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
- };
- /***/ },
- /* 237 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- function Reporter(options) {
- this._reporterState = {
- obj: null,
- path: [],
- options: options || {},
- errors: []
- };
- }
- exports.Reporter = Reporter;
- Reporter.prototype.isError = function isError(obj) {
- return obj instanceof ReporterError;
- };
- Reporter.prototype.save = function save() {
- var state = this._reporterState;
- return { obj: state.obj, pathLen: state.path.length };
- };
- Reporter.prototype.restore = function restore(data) {
- var state = this._reporterState;
- state.obj = data.obj;
- state.path = state.path.slice(0, data.pathLen);
- };
- Reporter.prototype.enterKey = function enterKey(key) {
- return this._reporterState.path.push(key);
- };
- Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
- var state = this._reporterState;
- state.path = state.path.slice(0, index - 1);
- if (state.obj !== null)
- state.obj[key] = value;
- };
- Reporter.prototype.enterObject = function enterObject() {
- var state = this._reporterState;
- var prev = state.obj;
- state.obj = {};
- return prev;
- };
- Reporter.prototype.leaveObject = function leaveObject(prev) {
- var state = this._reporterState;
- var now = state.obj;
- state.obj = prev;
- return now;
- };
- Reporter.prototype.error = function error(msg) {
- var err;
- var state = this._reporterState;
- var inherited = msg instanceof ReporterError;
- if (inherited) {
- err = msg;
- } else {
- err = new ReporterError(state.path.map(function(elem) {
- return '[' + JSON.stringify(elem) + ']';
- }).join(''), msg.message || msg, msg.stack);
- }
- if (!state.options.partial)
- throw err;
- if (!inherited)
- state.errors.push(err);
- return err;
- };
- Reporter.prototype.wrapResult = function wrapResult(result) {
- var state = this._reporterState;
- if (!state.options.partial)
- return result;
- return {
- result: this.isError(result) ? null : result,
- errors: state.errors
- };
- };
- function ReporterError(path, msg) {
- this.path = path;
- this.rethrow(msg);
- };
- inherits(ReporterError, Error);
- ReporterError.prototype.rethrow = function rethrow(msg) {
- this.message = msg + ' at: ' + (this.path || '(shallow)');
- if (Error.captureStackTrace)
- Error.captureStackTrace(this, ReporterError);
- if (!this.stack) {
- try {
- // IE only adds stack when thrown
- throw new Error(this.message);
- } catch (e) {
- this.stack = e.stack;
- }
- }
- return this;
- };
- /***/ },
- /* 238 */
- /***/ function(module, exports, __webpack_require__) {
- var constants = __webpack_require__(141);
- exports.tagClass = {
- 0: 'universal',
- 1: 'application',
- 2: 'context',
- 3: 'private'
- };
- exports.tagClassByName = constants._reverse(exports.tagClass);
- exports.tag = {
- 0x00: 'end',
- 0x01: 'bool',
- 0x02: 'int',
- 0x03: 'bitstr',
- 0x04: 'octstr',
- 0x05: 'null_',
- 0x06: 'objid',
- 0x07: 'objDesc',
- 0x08: 'external',
- 0x09: 'real',
- 0x0a: 'enum',
- 0x0b: 'embed',
- 0x0c: 'utf8str',
- 0x0d: 'relativeOid',
- 0x10: 'seq',
- 0x11: 'set',
- 0x12: 'numstr',
- 0x13: 'printstr',
- 0x14: 't61str',
- 0x15: 'videostr',
- 0x16: 'ia5str',
- 0x17: 'utctime',
- 0x18: 'gentime',
- 0x19: 'graphstr',
- 0x1a: 'iso646str',
- 0x1b: 'genstr',
- 0x1c: 'unistr',
- 0x1d: 'charstr',
- 0x1e: 'bmpstr'
- };
- exports.tagByName = constants._reverse(exports.tag);
- /***/ },
- /* 239 */
- /***/ function(module, exports, __webpack_require__) {
- var decoders = exports;
- decoders.der = __webpack_require__(142);
- decoders.pem = __webpack_require__(240);
- /***/ },
- /* 240 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- var Buffer = __webpack_require__(1).Buffer;
- var DERDecoder = __webpack_require__(142);
- function PEMDecoder(entity) {
- DERDecoder.call(this, entity);
- this.enc = 'pem';
- };
- inherits(PEMDecoder, DERDecoder);
- module.exports = PEMDecoder;
- PEMDecoder.prototype.decode = function decode(data, options) {
- var lines = data.toString().split(/[\r\n]+/g);
- var label = options.label.toUpperCase();
- var re = /^-----(BEGIN|END) ([^-]+)-----$/;
- var start = -1;
- var end = -1;
- for (var i = 0; i < lines.length; i++) {
- var match = lines[i].match(re);
- if (match === null)
- continue;
- if (match[2] !== label)
- continue;
- if (start === -1) {
- if (match[1] !== 'BEGIN')
- break;
- start = i;
- } else {
- if (match[1] !== 'END')
- break;
- end = i;
- break;
- }
- }
- if (start === -1 || end === -1)
- throw new Error('PEM section not found for: ' + label);
- var base64 = lines.slice(start + 1, end).join('');
- // Remove excessive symbols
- base64.replace(/[^a-z0-9\+\/=]+/gi, '');
- var input = new Buffer(base64, 'base64');
- return DERDecoder.prototype.decode.call(this, input, options);
- };
- /***/ },
- /* 241 */
- /***/ function(module, exports, __webpack_require__) {
- var encoders = exports;
- encoders.der = __webpack_require__(143);
- encoders.pem = __webpack_require__(242);
- /***/ },
- /* 242 */
- /***/ function(module, exports, __webpack_require__) {
- var inherits = __webpack_require__(2);
- var DEREncoder = __webpack_require__(143);
- function PEMEncoder(entity) {
- DEREncoder.call(this, entity);
- this.enc = 'pem';
- };
- inherits(PEMEncoder, DEREncoder);
- module.exports = PEMEncoder;
- PEMEncoder.prototype.encode = function encode(data, options) {
- var buf = DEREncoder.prototype.encode.call(this, data);
- var p = buf.toString('base64');
- var out = [ '-----BEGIN ' + options.label + '-----' ];
- for (var i = 0; i < p.length; i += 64)
- out.push(p.slice(i, i + 64));
- out.push('-----END ' + options.label + '-----');
- return out.join('\n');
- };
- /***/ },
- /* 243 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- // Declare internals
- var internals = {};
- exports.escapeJavaScript = function (input) {
- if (!input) {
- return '';
- }
- var escaped = '';
- for (var i = 0; i < input.length; ++i) {
- var charCode = input.charCodeAt(i);
- if (internals.isSafe(charCode)) {
- escaped += input[i];
- } else {
- escaped += internals.escapeJavaScriptChar(charCode);
- }
- }
- return escaped;
- };
- exports.escapeHtml = function (input) {
- if (!input) {
- return '';
- }
- var escaped = '';
- for (var i = 0; i < input.length; ++i) {
- var charCode = input.charCodeAt(i);
- if (internals.isSafe(charCode)) {
- escaped += input[i];
- } else {
- escaped += internals.escapeHtmlChar(charCode);
- }
- }
- return escaped;
- };
- internals.escapeJavaScriptChar = function (charCode) {
- if (charCode >= 256) {
- return '\\u' + internals.padLeft('' + charCode, 4);
- }
- var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
- return '\\x' + internals.padLeft(hexValue, 2);
- };
- internals.escapeHtmlChar = function (charCode) {
- var namedEscape = internals.namedHtml[charCode];
- if (typeof namedEscape !== 'undefined') {
- return namedEscape;
- }
- if (charCode >= 256) {
- return '&#' + charCode + ';';
- }
- var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
- return '&#x' + internals.padLeft(hexValue, 2) + ';';
- };
- internals.padLeft = function (str, len) {
- while (str.length < len) {
- str = '0' + str;
- }
- return str;
- };
- internals.isSafe = function (charCode) {
- return typeof internals.safeCharCodes[charCode] !== 'undefined';
- };
- internals.namedHtml = {
- '38': '&',
- '60': '<',
- '62': '>',
- '34': '"',
- '160': ' ',
- '162': '¢',
- '163': '£',
- '164': '¤',
- '169': '©',
- '174': '®'
- };
- internals.safeCharCodes = function () {
- var safe = {};
- for (var i = 32; i < 123; ++i) {
- if (i >= 97 || // a-z
- i >= 65 && i <= 90 || // A-Z
- i >= 48 && i <= 57 || // 0-9
- i === 32 || // space
- i === 46 || // .
- i === 44 || // ,
- i === 45 || // -
- i === 58 || // :
- i === 95) {
- // _
- safe[i] = null;
- }
- }
- return safe;
- }();
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 244 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var multihashing = __webpack_require__(205);
- exports = module.exports;
- // Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits
- exports.hash = function (data) {
- return multihashing(data, 'sha2-256');
- };
- /***/ },
- /* 245 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var _createClass = function () {
- function defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
- }
- }return function (Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- var Block = __webpack_require__(147);
- // Batch is to defer writes
- module.exports = function () {
- function Batch(ds, max) {
- _classCallCheck(this, Batch);
- if (!ds) {
- throw Error('Invalid DAG Service');
- }
- this.dagService = ds;
- this.blocks = [];
- this.size = 0;
- this.maxSize = max || 0;
- }
- _createClass(Batch, [{
- key: 'add',
- value: function add(node, cb) {
- if (!node) {
- return cb('Node is invalid');
- }
- var data = node.encoded();
- if (!data) {
- return cb('Node is unencoded');
- }
- this.size += data.length;
- var block = new Block(data);
- this.blocks.push(block);
- if (this.size > this.maxSize) {
- this.commit(cb, block.key);
- } else {
- cb(null, block.key);
- }
- }
- }, {
- key: 'commit',
- value: function commit(cb, key) {
- var _this = this;
- this.dagService.blocks().addBlocks(this.blocks, function (err) {
- if (err) {
- return cb(err);
- }
- _this.blocks = [];
- _this.size = 0;
- cb(null, key);
- });
- }
- }]);
- return Batch;
- }();
- /***/ },
- /* 246 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var _createClass = function () {
- function defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
- }
- }return function (Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
- };
- }();
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- var Block = __webpack_require__(147);
- var isIPFS = __webpack_require__(201);
- var base58 = __webpack_require__(56);
- var DAGNode = __webpack_require__(149);
- module.exports = function () {
- function DAGService(blockService) {
- _classCallCheck(this, DAGService);
- if (!blockService) {
- throw new Error('DAGService requires a BlockService instance');
- }
- this.bs = blockService;
- }
- // add a DAGNode to the service, storing it on the block service
- _createClass(DAGService, [{
- key: 'add',
- value: function add(node, callback) {
- this.bs.addBlock(new Block(node.encoded()), callback);
- }
- // DEPRECATED - https://github.com/ipfs/go-ipfs/issues/2262
- // this.addRecursive
- // get retrieves a DAGNode, using the Block Service
- }, {
- key: 'get',
- value: function get(multihash, callback) {
- var isMhash = isIPFS.multihash(multihash);
- var isPath = isIPFS.path(multihash);
- if (!isMhash && !isPath) {
- return callback(new Error('Invalid Key'));
- }
- if (isMhash) {
- this.getWith(multihash, callback);
- }
- if (isPath) {
- var ipfsKey = multihash.replace('/ipfs/', '');
- this.getWith(ipfsKey, callback);
- }
- }
- }, {
- key: 'getWith',
- value: function getWith(key, callback) {
- var formatted = typeof key === 'string' ? new Buffer(base58.decode(key)) : key;
- this.bs.getBlock(formatted, function (err, block) {
- if (err) {
- return callback(err);
- }
- var node = new DAGNode();
- node.unMarshal(block.data);
- return callback(null, node);
- });
- }
- // getRecursive fetches a node and all of the nodes on its links recursively
- // TODO add depth param
- }, {
- key: 'getRecursive',
- value: function getRecursive(multihash, callback, linkStack, nodeStack) {
- var _this = this;
- this.get(multihash, function (err, node) {
- if (err && nodeStack.length > 0) {
- return callback(new Error('Could not complete the recursive get'), nodeStack);
- }
- if (err) {
- return callback(err);
- }
- if (!linkStack) {
- linkStack = [];
- }
- if (!nodeStack) {
- nodeStack = [];
- }
- nodeStack.push(node);
- var keys = node.links.map(function (link) {
- return link.hash;
- });
- linkStack = linkStack.concat(keys);
- var next = linkStack.pop();
- if (next) {
- _this.getRecursive(next, callback, linkStack, nodeStack);
- } else {
- var compare = function compare(hash) {
- return function (node) {
- node.multihash().equals(hash);
- };
- };
- var link = void 0;
- for (var k = 0; k < nodeStack.length; k++) {
- var current = nodeStack[k];
- for (var j = 0; j < current.links.length; j++) {
- link = current.links[j];
- var index = nodeStack.findIndex(compare(link.hash));
- if (index !== -1) {
- link.node = nodeStack[index];
- }
- }
- }
- return callback(null, nodeStack);
- }
- });
- }
- // remove deletes a node with given multihash from the blockService
- }, {
- key: 'remove',
- value: function remove(multihash, cb) {
- if (!multihash) {
- return cb(new Error('Invalid multihash'));
- }
- this.bs.deleteBlock(multihash, cb);
- }
- // DEPRECATED - https://github.com/ipfs/go-ipfs/issues/2262
- // this.removeRecursive = (key, callback) => { }
- }]);
- return DAGService;
- }();
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 247 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var Stringify = __webpack_require__(249);
- var Parse = __webpack_require__(248);
- module.exports = {
- stringify: Stringify,
- parse: Parse
- };
- /***/ },
- /* 248 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var Utils = __webpack_require__(151);
- var defaults = {
- delimiter: '&',
- depth: 5,
- arrayLimit: 20,
- parameterLimit: 1000,
- strictNullHandling: false,
- plainObjects: false,
- allowPrototypes: false,
- allowDots: false,
- decoder: Utils.decode
- };
- var parseValues = function parseValues(str, options) {
- var obj = {};
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
- for (var i = 0; i < parts.length; ++i) {
- var part = parts[i];
- var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
- if (pos === -1) {
- obj[options.decoder(part)] = '';
- if (options.strictNullHandling) {
- obj[options.decoder(part)] = null;
- }
- } else {
- var key = options.decoder(part.slice(0, pos));
- var val = options.decoder(part.slice(pos + 1));
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- obj[key] = [].concat(obj[key]).concat(val);
- } else {
- obj[key] = val;
- }
- }
- }
- return obj;
- };
- var parseObject = function parseObject(chain, val, options) {
- if (!chain.length) {
- return val;
- }
- var root = chain.shift();
- var obj;
- if (root === '[]') {
- obj = [];
- obj = obj.concat(parseObject(chain, val, options));
- } else {
- obj = options.plainObjects ? Object.create(null) : {};
- var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
- var index = parseInt(cleanRoot, 10);
- if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
- obj = [];
- obj[index] = parseObject(chain, val, options);
- } else {
- obj[cleanRoot] = parseObject(chain, val, options);
- }
- }
- return obj;
- };
- var parseKeys = function parseKeys(givenKey, val, options) {
- if (!givenKey) {
- return;
- }
- // Transform dot notation to bracket notation
- var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
- // The regex chunks
- var parent = /^([^\[\]]*)/;
- var child = /(\[[^\[\]]*\])/g;
- // Get the parent
- var segment = parent.exec(key);
- // Stash the parent if it exists
- var keys = [];
- if (segment[1]) {
- // If we aren't using plain objects, optionally prefix keys
- // that would overwrite object prototype properties
- if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
- if (!options.allowPrototypes) {
- return;
- }
- }
- keys.push(segment[1]);
- }
- // Loop through children appending to the array until we hit depth
- var i = 0;
- while ((segment = child.exec(key)) !== null && i < options.depth) {
- i += 1;
- if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
- if (!options.allowPrototypes) {
- continue;
- }
- }
- keys.push(segment[1]);
- }
- // If there's a remainder, just add whatever is left
- if (segment) {
- keys.push('[' + key.slice(segment.index) + ']');
- }
- return parseObject(keys, val, options);
- };
- module.exports = function (str, opts) {
- var options = opts || {};
- if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
- throw new TypeError('Decoder has to be a function.');
- }
- options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
- options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
- options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
- options.parseArrays = options.parseArrays !== false;
- options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
- options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
- options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
- options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
- options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
- options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
- if (str === '' || str === null || typeof str === 'undefined') {
- return options.plainObjects ? Object.create(null) : {};
- }
- var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
- var obj = options.plainObjects ? Object.create(null) : {};
- // Iterate over the keys and setup the new object
- var keys = Object.keys(tempObj);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- var newObj = parseKeys(key, tempObj[key], options);
- obj = Utils.merge(obj, newObj, options);
- }
- return Utils.compact(obj);
- };
- /***/ },
- /* 249 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var Utils = __webpack_require__(151);
- var arrayPrefixGenerators = {
- brackets: function brackets(prefix) {
- return prefix + '[]';
- },
- indices: function indices(prefix, key) {
- return prefix + '[' + key + ']';
- },
- repeat: function repeat(prefix) {
- return prefix;
- }
- };
- var defaults = {
- delimiter: '&',
- strictNullHandling: false,
- skipNulls: false,
- encode: true,
- encoder: Utils.encode
- };
- var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) {
- var obj = object;
- if (typeof filter === 'function') {
- obj = filter(prefix, obj);
- } else if (obj instanceof Date) {
- obj = obj.toISOString();
- } else if (obj === null) {
- if (strictNullHandling) {
- return encoder ? encoder(prefix) : prefix;
- }
- obj = '';
- }
- if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) {
- if (encoder) {
- return [encoder(prefix) + '=' + encoder(obj)];
- }
- return [prefix + '=' + String(obj)];
- }
- var values = [];
- if (typeof obj === 'undefined') {
- return values;
- }
- var objKeys;
- if (Array.isArray(filter)) {
- objKeys = filter;
- } else {
- var keys = Object.keys(obj);
- objKeys = sort ? keys.sort(sort) : keys;
- }
- for (var i = 0; i < objKeys.length; ++i) {
- var key = objKeys[i];
- if (skipNulls && obj[key] === null) {
- continue;
- }
- if (Array.isArray(obj)) {
- values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
- } else {
- values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
- }
- }
- return values;
- };
- module.exports = function (object, opts) {
- var obj = object;
- var options = opts || {};
- var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
- var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
- var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
- var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
- var encoder = encode ? typeof options.encoder === 'function' ? options.encoder : defaults.encoder : null;
- var sort = typeof options.sort === 'function' ? options.sort : null;
- var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
- var objKeys;
- var filter;
- if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
- throw new TypeError('Encoder has to be a function.');
- }
- if (typeof options.filter === 'function') {
- filter = options.filter;
- obj = filter('', obj);
- } else if (Array.isArray(options.filter)) {
- objKeys = filter = options.filter;
- }
- var keys = [];
- if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
- return '';
- }
- var arrayFormat;
- if (options.arrayFormat in arrayPrefixGenerators) {
- arrayFormat = options.arrayFormat;
- } else if ('indices' in options) {
- arrayFormat = options.indices ? 'indices' : 'repeat';
- } else {
- arrayFormat = 'indices';
- }
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
- if (!objKeys) {
- objKeys = Object.keys(obj);
- }
- if (sort) {
- objKeys.sort(sort);
- }
- for (var i = 0; i < objKeys.length; ++i) {
- var key = objKeys[i];
- if (skipNulls && obj[key] === null) {
- continue;
- }
- keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
- }
- return keys.join(delimiter);
- };
- /***/ },
- /* 250 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- // Load modules
- var Boom = __webpack_require__(146);
- var Hoek = __webpack_require__(68);
- var Stream = __webpack_require__(9);
- // Declare internals
- var internals = {};
- module.exports = internals.Recorder = function (options) {
- Stream.Writable.call(this);
- this.settings = options; // No need to clone since called internally with new object
- this.buffers = [];
- this.length = 0;
- };
- Hoek.inherits(internals.Recorder, Stream.Writable);
- internals.Recorder.prototype._write = function (chunk, encoding, next) {
- if (this.settings.maxBytes && this.length + chunk.length > this.settings.maxBytes) {
- return this.emit('error', Boom.badRequest('Payload content length greater than maximum allowed: ' + this.settings.maxBytes));
- }
- this.length = this.length + chunk.length;
- this.buffers.push(chunk);
- next();
- };
- internals.Recorder.prototype.collect = function () {
- var buffer = this.buffers.length === 0 ? new Buffer(0) : this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length);
- return buffer;
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 251 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // Load modules
- var Hoek = __webpack_require__(68);
- var Stream = __webpack_require__(9);
- var Payload = __webpack_require__(153);
- // Declare internals
- var internals = {};
- module.exports = internals.Tap = function () {
- Stream.Transform.call(this);
- this.buffers = [];
- };
- Hoek.inherits(internals.Tap, Stream.Transform);
- internals.Tap.prototype._transform = function (chunk, encoding, next) {
- this.buffers.push(chunk);
- next(null, chunk);
- };
- internals.Tap.prototype.collect = function () {
- return new Payload(this.buffers);
- };
- /***/ },
- /* 252 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var addToDagNodesTransform = __webpack_require__(100);
- module.exports = function (send) {
- return function add(path, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- if (typeof path !== 'string') {
- return cb(new Error('"path" must be a string'));
- }
- var sendWithTransform = send.withTransform(addToDagNodesTransform);
- return sendWithTransform('add', null, opts, path, cb);
- };
- };
- /***/ },
- /* 253 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var Wreck = __webpack_require__(152);
- var addToDagNodesTransform = __webpack_require__(100);
- module.exports = function (send) {
- return function add(url, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- if (typeof url !== 'string' || !url.startsWith('http')) {
- return cb(new Error('"url" param must be an http(s) url'));
- }
- var sendWithTransform = send.withTransform(addToDagNodesTransform);
- Wreck.request('GET', url, null, function (err, res) {
- if (err) return cb(err);
- sendWithTransform('add', null, opts, res, cb);
- });
- };
- };
- /***/ },
- /* 254 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- wantlist: function wantlist(cb) {
- return send('bitswap/wantlist', {}, null, null, cb);
- },
- stat: function stat(cb) {
- return send('bitswap/stat', {}, null, null, cb);
- },
- unwant: argCommand(send, 'bitswap/unwant')
- };
- };
- /***/ },
- /* 255 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- get: argCommand(send, 'block/get'),
- stat: argCommand(send, 'block/stat'),
- put: function put(file, cb) {
- if (Array.isArray(file)) {
- var _ret = function () {
- var err = new Error('block.put() only accepts 1 file');
- if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
- return {
- v: new Promise(function (resolve, reject) {
- return reject(err);
- })
- };
- }
- return {
- v: cb(err)
- };
- }();
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
- return send('block/put', null, null, file, cb);
- }
- };
- };
- /***/ },
- /* 256 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var command = __webpack_require__(18).command;
- module.exports = function (send) {
- return {
- add: function add(arg, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- return send('bootstrap/add', arg, opts, null, cb);
- },
- rm: function rm(arg, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- return send('bootstrap/rm', arg, opts, null, cb);
- },
- list: command(send, 'bootstrap/list')
- };
- };
- /***/ },
- /* 257 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var bs58 = __webpack_require__(56);
- var isIPFS = __webpack_require__(201);
- var promisify = __webpack_require__(78);
- module.exports = function (send) {
- var cat = promisify(function (multihash, callback) {
- try {
- multihash = cleanMultihash(multihash);
- } catch (err) {
- return callback(err);
- }
- send('cat', multihash, null, null, callback);
- });
- return cat;
- };
- function cleanMultihash(multihash) {
- if (!isIPFS.multihash(multihash)) {
- throw new Error('not valid multihash');
- }
- if (Buffer.isBuffer(multihash)) {
- return bs58.encode(multihash);
- }
- return multihash;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 258 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var command = __webpack_require__(18).command;
- module.exports = function (send) {
- return command(send, 'commands');
- };
- /***/ },
- /* 259 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- get: argCommand(send, 'config'),
- set: function set(key, value, opts, cb) {
- if (typeof opts === 'function') {
- cb = opts;
- opts = {};
- }
- if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
- value = JSON.stringify(value);
- opts = { json: true };
- } else if (typeof value === 'boolean') {
- value = value.toString();
- opts = { bool: true };
- }
- return send('config', [key, value], opts, null, cb);
- },
- show: function show(cb) {
- return send('config/show', null, null, null, true, cb);
- },
- replace: function replace(file, cb) {
- return send('config/replace', null, null, file, cb);
- }
- };
- };
- /***/ },
- /* 260 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- findprovs: argCommand(send, 'dht/findprovs'),
- get: function get(key, opts, cb) {
- if (typeof opts === 'function' && !cb) {
- cb = opts;
- opts = null;
- }
- var handleResult = function handleResult(done, err, res) {
- if (err) return done(err);
- if (!res) return done(new Error('empty response'));
- if (res.length === 0) return done(new Error('no value returned for key'));
- // Inconsistent return values in the browser vs node
- if (Array.isArray(res)) {
- res = res[0];
- }
- if (res.Type === 5) {
- done(null, res.Extra);
- } else {
- var error = new Error('key was not found (type 6)');
- done(error);
- }
- };
- if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
- var _ret = function () {
- var done = function done(err, res) {
- if (err) throw err;
- return res;
- };
- return {
- v: send('dht/get', key, opts).then(function (res) {
- return handleResult(done, null, res);
- }, function (err) {
- return handleResult(done, err);
- })
- };
- }();
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
- return send('dht/get', key, opts, null, handleResult.bind(null, cb));
- },
- put: function put(key, value, opts, cb) {
- if (typeof opts === 'function' && !cb) {
- cb = opts;
- opts = null;
- }
- return send('dht/put', [key, value], opts, null, cb);
- }
- };
- };
- /***/ },
- /* 261 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var command = __webpack_require__(18).command;
- module.exports = function (send) {
- return {
- net: command(send, 'diag/net'),
- sys: command(send, 'diag/sys'),
- cmds: command(send, 'diag/sys')
- };
- };
- /***/ },
- /* 262 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- cp: argCommand(send, 'files/cp'),
- ls: argCommand(send, 'files/ls'),
- mkdir: argCommand(send, 'files/mkdir'),
- stat: argCommand(send, 'files/stat'),
- rm: function rm(path, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- return send('files/rm', path, opts, null, cb);
- },
- read: argCommand(send, 'files/read'),
- write: function write(pathDst, files, opts, cb) {
- if (typeof opts === 'function' && cb === undefined) {
- cb = opts;
- opts = {};
- }
- return send('files/write', pathDst, opts, files, cb);
- },
- mv: argCommand(send, 'files/mv')
- };
- };
- /***/ },
- /* 263 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- module.exports = function (send) {
- return function id(idParam, cb) {
- if (typeof idParam === 'function') {
- cb = idParam;
- idParam = null;
- }
- return send('id', idParam, null, null, cb);
- };
- };
- /***/ },
- /* 264 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var ndjson = __webpack_require__(206);
- module.exports = function (send) {
- return {
- tail: function tail(cb) {
- if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
- return send('log/tail', null, {}, null, false).then(function (res) {
- return res.pipe(ndjson.parse());
- });
- }
- return send('log/tail', null, {}, null, false, function (err, res) {
- if (err) return cb(err);
- cb(null, res.pipe(ndjson.parse()));
- });
- }
- };
- };
- /***/ },
- /* 265 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return argCommand(send, 'ls');
- };
- /***/ },
- /* 266 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- module.exports = function (send) {
- return function mount(ipfs, ipns, cb) {
- if (typeof ipfs === 'function') {
- cb = ipfs;
- ipfs = null;
- } else if (typeof ipns === 'function') {
- cb = ipns;
- ipns = null;
- }
- var opts = {};
- if (ipfs) opts.f = ipfs;
- if (ipns) opts.n = ipns;
- return send('mount', null, opts, null, cb);
- };
- };
- /***/ },
- /* 267 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var argCommand = __webpack_require__(18).argCommand;
- module.exports = function (send) {
- return {
- publish: argCommand(send, 'name/publish'),
- resolve: argCommand(send, 'name/resolve')
- };
- };
- /***/ },
- /* 268 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- 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; };
- var DAGNode = __webpack_require__(99).DAGNode;
- var DAGLink = __webpack_require__(99).DAGLink;
- var promisify = __webpack_require__(78);
- var bs58 = __webpack_require__(56);
- var bl = __webpack_require__(155);
- module.exports = function (send) {
- var api = {
- get: promisify(function (multihash, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/get', multihash, null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- var node = new DAGNode(result.Data, result.Links.map(function (l) {
- return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)));
- }));
- callback(null, node);
- });
- }),
- put: promisify(function (obj, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- var tmpObj = {
- Data: null,
- Links: []
- };
- if (Buffer.isBuffer(obj)) {
- if (!options.enc) {
- tmpObj = { Data: obj.toString(), Links: [] };
- }
- } else if (obj.multihash) {
- tmpObj = {
- Data: obj.data.toString(),
- Links: obj.links.map(function (l) {
- return l.toJSON();
- })
- };
- } else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {
- tmpObj.Data = obj.Data.toString();
- } else {
- return callback(new Error('obj not recognized'));
- }
- var buf = void 0;
- if (Buffer.isBuffer(obj) && options.enc) {
- buf = obj;
- } else {
- buf = new Buffer(JSON.stringify(tmpObj));
- }
- var enc = options.enc || 'json';
- send('object/put', null, { inputenc: enc }, buf, function (err, result) {
- if (err) {
- return callback(err);
- }
- if (Buffer.isBuffer(obj)) {
- if (!options.enc) {
- obj = { Data: obj, Links: [] };
- } else if (options.enc === 'json') {
- obj = JSON.parse(obj.toString());
- }
- }
- var node = void 0;
- if (obj.multihash) {
- node = obj;
- } else if (options.enc === 'protobuf') {
- node = new DAGNode();
- node.unMarshal(obj);
- } else {
- node = new DAGNode(obj.Data, obj.Links);
- }
- if (node.toJSON().Hash !== result.Hash) {
- return callback(new Error('Stored object was different from constructed object'));
- }
- callback(null, node);
- });
- }),
- data: promisify(function (multihash, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/data', multihash, null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- if (typeof result.pipe === 'function') {
- result.pipe(bl(callback));
- } else {
- callback(null, result);
- }
- });
- }),
- links: promisify(function (multihash, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/links', multihash, null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- var links = [];
- if (result.Links) {
- links = result.Links.map(function (l) {
- return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)));
- });
- }
- callback(null, links);
- });
- }),
- stat: promisify(function (multihash, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/stat', multihash, null, null, callback);
- }),
- new: promisify(function (callback) {
- send('object/new', null, null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- var node = new DAGNode();
- if (node.toJSON().Hash !== result.Hash) {
- return callback(new Error('Stored object was different from constructed object'));
- }
- callback(null, node);
- });
- }),
- patch: {
- addLink: promisify(function (multihash, dLink, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/patch/add-link', [multihash, dLink.name, bs58.encode(dLink.hash).toString()], null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- api.get(result.Hash, { enc: 'base58' }, callback);
- });
- }),
- rmLink: promisify(function (multihash, dLink, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/patch/rm-link', [multihash, dLink.name], null, null, function (err, result) {
- if (err) {
- return callback(err);
- }
- api.get(result.Hash, { enc: 'base58' }, callback);
- });
- }),
- setData: promisify(function (multihash, data, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/patch/set-data', [multihash], null, data, function (err, result) {
- if (err) {
- return callback(err);
- }
- api.get(result.Hash, { enc: 'base58' }, callback);
- });
- }),
- appendData: promisify(function (multihash, data, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (!options) {
- options = {};
- }
- try {
- multihash = cleanMultihash(multihash, options);
- } catch (err) {
- return callback(err);
- }
- send('object/patch/append-data', [multihash], null, data, function (err, result) {
- if (err) {
- return callback(err);
- }
- api.get(result.Hash, { enc: 'base58' }, callback);
- });
- })
- }
- };
- return api;
- };
- function cleanMultihash(multihash, options) {
- if (Buffer.isBuffer(multihash)) {
- if (options.enc) {
- switch (options.enc) {
- case 'base58':
- {
- multihash = multihash.toString();
- break;
- }
- default:
- throw new Error('invalid multihash');
- }
- } else {
- multihash = bs58.encode(multihash).toString();
- }
- } else if (typeof multihash === 'string') {
- if (options.enc) {
- // For the future, when we support more than one enc
- // switch (options.enc) {
- // case 'base58': // It is good
- // }
- } else {
- throw new Error('not valid multihash');
- }
- } else if (!multihash) {
- throw new Error('missing valid multihash');
- }
- return multihash;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 269 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- module.exports = function (send) {
- return {
- add: function add(hash, opts, cb) {
- if (typeof opts === 'function') {
- cb = opts;
- opts = null;
- }
- return send('pin/add', hash, opts, null, cb);
- },
- remove: function remove(hash, opts, cb) {
- if (typeof opts === 'function') {
- cb = opts;
- opts = null;
- }
- return send('pin/rm', hash, opts, null, cb);
- },
- list: function list(type, cb) {
- if (typeof type === 'function') {
- cb = type;
- type = null;
- }
- var opts = null;
- var hash = null;
- if (typeof type === 'string') {
- opts = { type: type };
- } else if (type && type.hash) {
- hash = type.hash;
- type.hash = null;
- opts = type;
- }
- return send('pin/ls', hash, opts, null, cb);
- }
- };
- };
- /***/ },
- /* 270 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- module.exports = function (send) {
- return function ping(id, cb) {
- if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
- return send('ping', id, { n: 1 }, null).then(function (res) {
- return res[1];
- });
- }
- return send('ping', id, { n: 1 }, null, function (err, res) {
- if (err) return cb(err, null);
- cb(null, res[1]);
- });
- };
- };
- /***/ },
- /* 271 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var cmds = __webpack_require__(18);
- module.exports = function (send) {
- var refs = cmds.argCommand(send, 'refs');
- refs.local = cmds.command(send, 'refs/local');
- return refs;
- };
- /***/ },
- /* 272 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var cmds = __webpack_require__(18);
- module.exports = function (send) {
- return {
- peers: cmds.command(send, 'swarm/peers'),
- connect: cmds.argCommand(send, 'swarm/connect'),
- disconnect: cmds.argCommand(send, 'swarm/disconnect'),
- addrs: cmds.command(send, 'swarm/addrs'),
- localAddrs: cmds.command(send, 'swarm/addrs/local')
- };
- };
- /***/ },
- /* 273 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var command = __webpack_require__(18).command;
- module.exports = function (send) {
- return {
- apply: command(send, 'update'),
- check: command(send, 'update/check'),
- log: command(send, 'update/log')
- };
- };
- /***/ },
- /* 274 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var command = __webpack_require__(18).command;
- module.exports = function (send) {
- return command(send, 'version');
- };
- /***/ },
- /* 275 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var pkg = __webpack_require__(234);
- exports = module.exports = function () {
- return {
- 'api-path': '/api/v0/',
- 'user-agent': '/node-' + pkg.name + '/' + pkg.version + '/',
- host: 'localhost',
- port: '5001',
- protocol: 'http'
- };
- };
- /***/ },
- /* 276 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var DAGNode = __webpack_require__(99).DAGNode;
- var bl = __webpack_require__(155);
- var async = __webpack_require__(145);
- module.exports = function (send, hash, cb) {
- // Retrieve the object and its data in parallel, then produce a DAGNode
- // instance using this information.
- async.parallel([function get(done) {
- send('object/get', hash, null, null, done);
- }, function data(done) {
- // WORKAROUND: request the object's data separately, since raw bits in JSON
- // are interpreted as UTF-8 and corrupt the data.
- // See https://github.com/ipfs/go-ipfs/issues/1582 for more details.
- send('object/data', hash, null, null, done);
- }], function done(err, res) {
- if (err) {
- return cb(err);
- }
- var object = res[0];
- var stream = res[1];
- stream.pipe(bl(function (err, data) {
- if (err) {
- return cb(err);
- }
- cb(err, new DAGNode(data, object.Links));
- }));
- });
- };
- /***/ },
- /* 277 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var isNode = __webpack_require__(196);
- var Multipart = __webpack_require__(526);
- var flatmap = __webpack_require__(500);
- function headers(file) {
- var name = file.path || '';
- var header = {
- 'Content-Disposition': 'file; filename="' + name + '"'
- };
- if (file.dir || !file.content) {
- header['Content-Type'] = 'application/x-directory';
- } else if (file.symlink) {
- header['Content-Type'] = 'application/symlink';
- } else {
- header['Content-Type'] = 'application/octet-stream';
- }
- return header;
- }
- function strip(name, base) {
- var smallBase = base.split('/').slice(0, -1).join('/') + '/';
- return name.replace(smallBase, '');
- }
- function loadPaths(opts, file) {
- var path = __webpack_require__(43);
-
- var glob = __webpack_require__(200);
- var followSymlinks = opts.followSymlinks != null ? opts.followSymlinks : true;
- file = path.resolve(file);
- var stats = fs.statSync(file);
- if (stats.isDirectory() && !opts.recursive) {
- throw new Error('Can only add directories using --recursive');
- }
- if (stats.isDirectory() && opts.recursive) {
- var _ret = function () {
- var mg = new glob.sync.GlobSync(file + '/**/*', {
- follow: followSymlinks
- });
- return {
- v: mg.found.map(function (name) {
- // symlinks
- if (mg.symlinks[name] === true) {
- return {
- path: strip(name, file),
- symlink: true,
- dir: false,
- content: fs.readlinkSync(name)
- };
- }
- // files
- if (mg.cache[name] === 'FILE') {
- return {
- path: strip(name, file),
- symlink: false,
- dir: false,
- content: fs.createReadStream(name)
- };
- }
- // directories
- if (mg.cache[name] === 'DIR' || mg.cache[name] instanceof Array) {
- return {
- path: strip(name, file),
- symlink: false,
- dir: true
- };
- }
- // files inside symlinks and others
- return;
- })
- // filter out null files
- .filter(Boolean)
- };
- }();
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
- return {
- path: file,
- content: fs.createReadStream(file)
- };
- }
- function getFilesStream(files, opts) {
- if (!files) return null;
- var mp = new Multipart();
- flatmap(files, function (file) {
- if (typeof file === 'string') {
- if (!isNode) {
- throw new Error('Can not add paths in node');
- }
- return loadPaths(opts, file);
- }
- if (file.path && !file.content) {
- file.dir = true;
- return file;
- }
- if (file.path && (file.content || file.dir)) {
- return file;
- }
- return {
- path: '',
- symlink: false,
- dir: false,
- content: file
- };
- }).forEach(function (file) {
- mp.addPart({
- headers: headers(file),
- body: file.content
- });
- });
- return mp;
- }
- exports = module.exports = getFilesStream;
- /***/ },
- /* 278 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- function requireCommands() {
- var cmds = {
- add: __webpack_require__(101), // add alias
- createAddStream: __webpack_require__(154), // add stream alias
- bitswap: __webpack_require__(254),
- block: __webpack_require__(255),
- bootstrap: __webpack_require__(256),
- cat: __webpack_require__(257),
- commands: __webpack_require__(258),
- config: __webpack_require__(259),
- dht: __webpack_require__(260),
- diag: __webpack_require__(261),
- id: __webpack_require__(263),
- log: __webpack_require__(264),
- ls: __webpack_require__(265),
- mount: __webpack_require__(266),
- name: __webpack_require__(267),
- object: __webpack_require__(268),
- pin: __webpack_require__(269),
- ping: __webpack_require__(270),
- refs: __webpack_require__(271),
- swarm: __webpack_require__(272),
- update: __webpack_require__(273),
- version: __webpack_require__(274)
- };
- // TODO: crowding the 'files' namespace temporarily for interface-ipfs-core
- // compatibility, until 'files vs mfs' naming decision is resolved.
- cmds.files = function (send) {
- var files = __webpack_require__(262)(send);
- files.add = __webpack_require__(101)(send);
- files.createAddStream = __webpack_require__(154)(send);
- return files;
- };
- cmds.util = function (send) {
- var util = {
- addFiles: __webpack_require__(252)(send),
- addUrl: __webpack_require__(253)(send)
- };
- return util;
- };
- return cmds;
- }
- function loadCommands(send) {
- var files = requireCommands();
- var cmds = {};
- Object.keys(files).forEach(function (file) {
- cmds[file] = files[file](send);
- });
- return cmds;
- }
- module.exports = loadCommands;
- /***/ },
- /* 279 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- 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; };
- var Wreck = __webpack_require__(152);
- var Qs = __webpack_require__(247);
- var ndjson = __webpack_require__(206);
- var getFilesStream = __webpack_require__(277);
- var isNode = __webpack_require__(196);
- // -- Internal
- function parseChunkedJson(res, cb) {
- var parsed = [];
- res.pipe(ndjson.parse()).on('data', parsed.push.bind(parsed)).on('end', function () {
- return cb(null, parsed);
- });
- }
- function onRes(buffer, cb) {
- return function (err, res) {
- if (err) {
- return cb(err);
- }
- var stream = Boolean(res.headers['x-stream-output']);
- var chunkedObjects = Boolean(res.headers['x-chunked-output']);
- var isJson = res.headers['content-type'] && res.headers['content-type'].indexOf('application/json') === 0;
- if (res.statusCode >= 400 || !res.statusCode) {
- var _ret = function () {
- var error = new Error('Server responded with ' + res.statusCode);
- return {
- v: Wreck.read(res, { json: true }, function (err, payload) {
- if (err) {
- return cb(err);
- }
- if (payload) {
- error.code = payload.Code;
- error.message = payload.Message || payload.toString();
- }
- cb(error);
- })
- };
- }();
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
- if (stream && !buffer) return cb(null, res);
- if (chunkedObjects) {
- if (isJson) return parseChunkedJson(res, cb);
- return Wreck.read(res, null, cb);
- }
- Wreck.read(res, { json: isJson }, cb);
- };
- }
- function requestAPI(config, path, args, qs, files, buffer, cb) {
- qs = qs || {};
- if (Array.isArray(path)) path = path.join('/');
- if (args && !Array.isArray(args)) args = [args];
- if (args) qs.arg = args;
- if (files && !Array.isArray(files)) files = [files];
- if (qs.r) {
- qs.recursive = qs.r;
- // From IPFS 0.4.0, it throws an error when both r and recursive are passed
- delete qs.r;
- }
- if (!isNode && qs.recursive && path === 'add') {
- return cb(new Error('Recursive uploads are not supported in the browser'));
- }
- qs['stream-channels'] = true;
- var stream = void 0;
- if (files) {
- stream = getFilesStream(files, qs);
- }
- // this option is only used internally, not passed to daemon
- delete qs.followSymlinks;
- var port = config.port ? ':' + config.port : '';
- var opts = {
- method: files ? 'POST' : 'GET',
- uri: config.protocol + '://' + config.host + port + config['api-path'] + path + '?' + Qs.stringify(qs, { arrayFormat: 'repeat' }),
- headers: {}
- };
- if (isNode) {
- // Browsers do not allow you to modify the user agent
- opts.headers['User-Agent'] = config['user-agent'];
- }
- if (files) {
- if (!stream.boundary) {
- return cb(new Error('No boundary in multipart stream'));
- }
- opts.headers['Content-Type'] = 'multipart/form-data; boundary=' + stream.boundary;
- opts.downstreamRes = stream;
- opts.payload = stream;
- }
- return Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb));
- }
- // -- Interface
- exports = module.exports = function getRequestAPI(config) {
- var send = function send(path, args, qs, files, buffer, cb) {
- if (typeof buffer === 'function') {
- cb = buffer;
- buffer = false;
- }
- if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
- return new Promise(function (resolve, reject) {
- requestAPI(config, path, args, qs, files, buffer, function (err, res) {
- if (err) return reject(err);
- resolve(res);
- });
- });
- }
- return requestAPI(config, path, args, qs, files, buffer, cb);
- };
- // Wraps the 'send' function such that an asynchronous transform may be
- // applied to its result before passing it on to either its callback or
- // promise.
- send.withTransform = function (transform) {
- return function (path, args, qs, files, buffer, cb) {
- if (typeof buffer === 'function') {
- cb = buffer;
- buffer = false;
- }
- var p = send(path, args, qs, files, buffer, wrap(cb));
- if (p instanceof Promise) {
- return p.then(function (res) {
- return new Promise(function (resolve, reject) {
- transform(null, res, send, function (err, res) {
- if (err) {
- reject(err);
- } else {
- resolve(res);
- }
- });
- });
- });
- } else {
- return p;
- }
- function wrap(done) {
- if (done) {
- return function (err, res) {
- transform(err, res, send, done);
- };
- }
- }
- };
- };
- return send;
- };
- /***/ },
- /* 280 */
- /***/ function(module, exports) {
- module.exports = balanced;
- function balanced(a, b, str) {
- if (a instanceof RegExp) a = maybeMatch(a, str);
- if (b instanceof RegExp) b = maybeMatch(b, str);
- var r = range(a, b, str);
- return r && {
- start: r[0],
- end: r[1],
- pre: str.slice(0, r[0]),
- body: str.slice(r[0] + a.length, r[1]),
- post: str.slice(r[1] + b.length)
- };
- }
- function maybeMatch(reg, str) {
- var m = str.match(reg);
- return m ? m[0] : null;
- }
- balanced.range = range;
- function range(a, b, str) {
- var begs, beg, left, right, result;
- var ai = str.indexOf(a);
- var bi = str.indexOf(b, ai + 1);
- var i = ai;
- if (ai >= 0 && bi > 0) {
- begs = [];
- left = str.length;
- while (i < str.length && i >= 0 && ! result) {
- if (i == ai) {
- begs.push(i);
- ai = str.indexOf(a, i + 1);
- } else if (begs.length == 1) {
- result = [ begs.pop(), bi ];
- } else {
- beg = begs.pop();
- if (beg < left) {
- left = beg;
- right = bi;
- }
- bi = str.indexOf(b, i + 1);
- }
- i = ai < bi && ai >= 0 ? ai : bi;
- }
- if (begs.length) {
- result = [ left, right ];
- }
- }
- return result;
- }
- /***/ },
- /* 281 */
- /***/ function(module, exports) {
- // base-x encoding
- // Forked from https://github.com/cryptocoinjs/bs58
- // Originally written by Mike Hearn for BitcoinJ
- // Copyright (c) 2011 Google Inc
- // Ported to JavaScript by Stefan Thomas
- // Merged Buffer refactorings from base58-native by Stephen Pair
- // Copyright (c) 2013 BitPay Inc
- module.exports = function base (ALPHABET) {
- var ALPHABET_MAP = {}
- var BASE = ALPHABET.length
- var LEADER = ALPHABET.charAt(0)
- // pre-compute lookup table
- for (var i = 0; i < ALPHABET.length; i++) {
- ALPHABET_MAP[ALPHABET.charAt(i)] = i
- }
- function encode (source) {
- if (source.length === 0) return ''
- var digits = [0]
- for (var i = 0; i < source.length; ++i) {
- for (var j = 0, carry = source[i]; j < digits.length; ++j) {
- carry += digits[j] << 8
- digits[j] = carry % BASE
- carry = (carry / BASE) | 0
- }
- while (carry > 0) {
- digits.push(carry % BASE)
- carry = (carry / BASE) | 0
- }
- }
- // deal with leading zeros
- for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) {
- digits.push(0)
- }
- // convert digits to a string
- for (var ii = 0, jj = digits.length - 1; ii <= jj; ++ii, --jj) {
- var tmp = ALPHABET[digits[ii]]
- digits[ii] = ALPHABET[digits[jj]]
- digits[jj] = tmp
- }
- return digits.join('')
- }
- function decode (string) {
- if (string.length === 0) return []
- var bytes = [0]
- for (var i = 0; i < string.length; i++) {
- var value = ALPHABET_MAP[string[i]]
- if (value === undefined) throw new Error('Non-base' + BASE + ' character')
- for (var j = 0, carry = value; j < bytes.length; ++j) {
- carry += bytes[j] * BASE
- bytes[j] = carry & 0xff
- carry >>= 8
- }
- while (carry > 0) {
- bytes.push(carry & 0xff)
- carry >>= 8
- }
- }
- // deal with leading zeros
- for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) {
- bytes.push(0)
- }
- return bytes.reverse()
- }
- return {
- encode: encode,
- decode: decode
- }
- }
- /***/ },
- /* 282 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict'
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
- function init () {
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
- }
- init()
- function toByteArray (b64) {
- var i, j, l, tmp, placeHolders, arr
- var len = b64.length
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
- // base64 is 4/3 + up to two characters of the original data
- arr = new Arr(len * 3 / 4 - placeHolders)
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? len - 4 : len
- var L = 0
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
- arr[L++] = (tmp >> 16) & 0xFF
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
- if (placeHolders === 2) {
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[L++] = tmp & 0xFF
- } else if (placeHolders === 1) {
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
- return arr
- }
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
- }
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var output = ''
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- output += lookup[tmp >> 2]
- output += lookup[(tmp << 4) & 0x3F]
- output += '=='
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
- output += lookup[tmp >> 10]
- output += lookup[(tmp >> 4) & 0x3F]
- output += lookup[(tmp << 2) & 0x3F]
- output += '='
- }
- parts.push(output)
- return parts.join('')
- }
- /***/ },
- /* 283 */
- /***/ function(module, exports, __webpack_require__) {
- var concatMap = __webpack_require__(294);
- var balanced = __webpack_require__(280);
- module.exports = expandTop;
- var escSlash = '\0SLASH'+Math.random()+'\0';
- var escOpen = '\0OPEN'+Math.random()+'\0';
- var escClose = '\0CLOSE'+Math.random()+'\0';
- var escComma = '\0COMMA'+Math.random()+'\0';
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
- function numeric(str) {
- return parseInt(str, 10) == str
- ? parseInt(str, 10)
- : str.charCodeAt(0);
- }
- function escapeBraces(str) {
- return str.split('\\\\').join(escSlash)
- .split('\\{').join(escOpen)
- .split('\\}').join(escClose)
- .split('\\,').join(escComma)
- .split('\\.').join(escPeriod);
- }
- function unescapeBraces(str) {
- return str.split(escSlash).join('\\')
- .split(escOpen).join('{')
- .split(escClose).join('}')
- .split(escComma).join(',')
- .split(escPeriod).join('.');
- }
- // Basically just str.split(","), but handling cases
- // where we have nested braced sections, which should be
- // treated as individual members, like {a,{b,c},d}
- function parseCommaParts(str) {
- if (!str)
- return [''];
- var parts = [];
- var m = balanced('{', '}', str);
- if (!m)
- return str.split(',');
- var pre = m.pre;
- var body = m.body;
- var post = m.post;
- var p = pre.split(',');
- p[p.length-1] += '{' + body + '}';
- var postParts = parseCommaParts(post);
- if (post.length) {
- p[p.length-1] += postParts.shift();
- p.push.apply(p, postParts);
- }
- parts.push.apply(parts, p);
- return parts;
- }
- function expandTop(str) {
- if (!str)
- return [];
- return expand(escapeBraces(str), true).map(unescapeBraces);
- }
- function identity(e) {
- return e;
- }
- function embrace(str) {
- return '{' + str + '}';
- }
- function isPadded(el) {
- return /^-?0\d/.test(el);
- }
- function lte(i, y) {
- return i <= y;
- }
- function gte(i, y) {
- return i >= y;
- }
- function expand(str, isTop) {
- var expansions = [];
- var m = balanced('{', '}', str);
- if (!m || /\$$/.test(m.pre)) return [str];
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
- var isSequence = isNumericSequence || isAlphaSequence;
- var isOptions = /^(.*,)+(.+)?$/.test(m.body);
- if (!isSequence && !isOptions) {
- // {a},b}
- if (m.post.match(/,.*\}/)) {
- str = m.pre + '{' + m.body + escClose + m.post;
- return expand(str);
- }
- return [str];
- }
- var n;
- if (isSequence) {
- n = m.body.split(/\.\./);
- } else {
- n = parseCommaParts(m.body);
- if (n.length === 1) {
- // x{{a,b}}y ==> x{a}y x{b}y
- n = expand(n[0], false).map(embrace);
- if (n.length === 1) {
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
- return post.map(function(p) {
- return m.pre + n[0] + p;
- });
- }
- }
- }
- // at this point, n is the parts, and we know it's not a comma set
- // with a single entry.
- // no need to expand pre, since it is guaranteed to be free of brace-sets
- var pre = m.pre;
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
- var N;
- if (isSequence) {
- var x = numeric(n[0]);
- var y = numeric(n[1]);
- var width = Math.max(n[0].length, n[1].length)
- var incr = n.length == 3
- ? Math.abs(numeric(n[2]))
- : 1;
- var test = lte;
- var reverse = y < x;
- if (reverse) {
- incr *= -1;
- test = gte;
- }
- var pad = n.some(isPadded);
- N = [];
- for (var i = x; test(i, y); i += incr) {
- var c;
- if (isAlphaSequence) {
- c = String.fromCharCode(i);
- if (c === '\\')
- c = '';
- } else {
- c = String(i);
- if (pad) {
- var need = width - c.length;
- if (need > 0) {
- var z = new Array(need + 1).join('0');
- if (i < 0)
- c = '-' + z + c.slice(1);
- else
- c = z + c;
- }
- }
- }
- N.push(c);
- }
- } else {
- N = concatMap(n, function(el) { return expand(el, false) });
- }
- for (var j = 0; j < N.length; j++) {
- for (var k = 0; k < post.length; k++) {
- var expansion = pre + N[j] + post[k];
- if (!isTop || isSequence || expansion)
- expansions.push(expansion);
- }
- }
- return expansions;
- }
- /***/ },
- /* 284 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
- var Transform = __webpack_require__(57)
- var inherits = __webpack_require__(2)
- var modes = __webpack_require__(80)
- var StreamCipher = __webpack_require__(164)
- var AuthCipher = __webpack_require__(157)
- var ebtk = __webpack_require__(95)
- inherits(Decipher, Transform)
- function Decipher (mode, key, iv) {
- if (!(this instanceof Decipher)) {
- return new Decipher(mode, key, iv)
- }
- Transform.call(this)
- this._cache = new Splitter()
- this._last = void 0
- this._cipher = new aes.AES(key)
- this._prev = new Buffer(iv.length)
- iv.copy(this._prev)
- this._mode = mode
- this._autopadding = true
- }
- Decipher.prototype._update = function (data) {
- this._cache.add(data)
- var chunk
- var thing
- var out = []
- while ((chunk = this._cache.get(this._autopadding))) {
- thing = this._mode.decrypt(this, chunk)
- out.push(thing)
- }
- return Buffer.concat(out)
- }
- Decipher.prototype._final = function () {
- var chunk = this._cache.flush()
- if (this._autopadding) {
- return unpad(this._mode.decrypt(this, chunk))
- } else if (chunk) {
- throw new Error('data not multiple of block length')
- }
- }
- Decipher.prototype.setAutoPadding = function (setTo) {
- this._autopadding = !!setTo
- return this
- }
- function Splitter () {
- if (!(this instanceof Splitter)) {
- return new Splitter()
- }
- this.cache = new Buffer('')
- }
- Splitter.prototype.add = function (data) {
- this.cache = Buffer.concat([this.cache, data])
- }
- Splitter.prototype.get = function (autoPadding) {
- var out
- if (autoPadding) {
- if (this.cache.length > 16) {
- out = this.cache.slice(0, 16)
- this.cache = this.cache.slice(16)
- return out
- }
- } else {
- if (this.cache.length >= 16) {
- out = this.cache.slice(0, 16)
- this.cache = this.cache.slice(16)
- return out
- }
- }
- return null
- }
- Splitter.prototype.flush = function () {
- if (this.cache.length) {
- return this.cache
- }
- }
- function unpad (last) {
- var padded = last[15]
- var i = -1
- while (++i < padded) {
- if (last[(i + (16 - padded))] !== padded) {
- throw new Error('unable to decrypt data')
- }
- }
- if (padded === 16) {
- return
- }
- return last.slice(0, 16 - padded)
- }
- var modelist = {
- ECB: __webpack_require__(162),
- CBC: __webpack_require__(158),
- CFB: __webpack_require__(159),
- CFB8: __webpack_require__(161),
- CFB1: __webpack_require__(160),
- OFB: __webpack_require__(163),
- CTR: __webpack_require__(81),
- GCM: __webpack_require__(81)
- }
- function createDecipheriv (suite, password, iv) {
- var config = modes[suite.toLowerCase()]
- if (!config) {
- throw new TypeError('invalid suite type')
- }
- if (typeof iv === 'string') {
- iv = new Buffer(iv)
- }
- if (typeof password === 'string') {
- password = new Buffer(password)
- }
- if (password.length !== config.key / 8) {
- throw new TypeError('invalid key length ' + password.length)
- }
- if (iv.length !== config.iv) {
- throw new TypeError('invalid iv length ' + iv.length)
- }
- if (config.type === 'stream') {
- return new StreamCipher(modelist[config.mode], password, iv, true)
- } else if (config.type === 'auth') {
- return new AuthCipher(modelist[config.mode], password, iv, true)
- }
- return new Decipher(modelist[config.mode], password, iv)
- }
- function createDecipher (suite, password) {
- var config = modes[suite.toLowerCase()]
- if (!config) {
- throw new TypeError('invalid suite type')
- }
- var keys = ebtk(password, false, config.key, config.iv)
- return createDecipheriv(suite, keys.key, keys.iv)
- }
- exports.createDecipher = createDecipher
- exports.createDecipheriv = createDecipheriv
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 285 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
- var Transform = __webpack_require__(57)
- var inherits = __webpack_require__(2)
- var modes = __webpack_require__(80)
- var ebtk = __webpack_require__(95)
- var StreamCipher = __webpack_require__(164)
- var AuthCipher = __webpack_require__(157)
- inherits(Cipher, Transform)
- function Cipher (mode, key, iv) {
- if (!(this instanceof Cipher)) {
- return new Cipher(mode, key, iv)
- }
- Transform.call(this)
- this._cache = new Splitter()
- this._cipher = new aes.AES(key)
- this._prev = new Buffer(iv.length)
- iv.copy(this._prev)
- this._mode = mode
- this._autopadding = true
- }
- Cipher.prototype._update = function (data) {
- this._cache.add(data)
- var chunk
- var thing
- var out = []
- while ((chunk = this._cache.get())) {
- thing = this._mode.encrypt(this, chunk)
- out.push(thing)
- }
- return Buffer.concat(out)
- }
- Cipher.prototype._final = function () {
- var chunk = this._cache.flush()
- if (this._autopadding) {
- chunk = this._mode.encrypt(this, chunk)
- this._cipher.scrub()
- return chunk
- } else if (chunk.toString('hex') !== '10101010101010101010101010101010') {
- this._cipher.scrub()
- throw new Error('data not multiple of block length')
- }
- }
- Cipher.prototype.setAutoPadding = function (setTo) {
- this._autopadding = !!setTo
- return this
- }
- function Splitter () {
- if (!(this instanceof Splitter)) {
- return new Splitter()
- }
- this.cache = new Buffer('')
- }
- Splitter.prototype.add = function (data) {
- this.cache = Buffer.concat([this.cache, data])
- }
- Splitter.prototype.get = function () {
- if (this.cache.length > 15) {
- var out = this.cache.slice(0, 16)
- this.cache = this.cache.slice(16)
- return out
- }
- return null
- }
- Splitter.prototype.flush = function () {
- var len = 16 - this.cache.length
- var padBuff = new Buffer(len)
- var i = -1
- while (++i < len) {
- padBuff.writeUInt8(len, i)
- }
- var out = Buffer.concat([this.cache, padBuff])
- return out
- }
- var modelist = {
- ECB: __webpack_require__(162),
- CBC: __webpack_require__(158),
- CFB: __webpack_require__(159),
- CFB8: __webpack_require__(161),
- CFB1: __webpack_require__(160),
- OFB: __webpack_require__(163),
- CTR: __webpack_require__(81),
- GCM: __webpack_require__(81)
- }
- function createCipheriv (suite, password, iv) {
- var config = modes[suite.toLowerCase()]
- if (!config) {
- throw new TypeError('invalid suite type')
- }
- if (typeof iv === 'string') {
- iv = new Buffer(iv)
- }
- if (typeof password === 'string') {
- password = new Buffer(password)
- }
- if (password.length !== config.key / 8) {
- throw new TypeError('invalid key length ' + password.length)
- }
- if (iv.length !== config.iv) {
- throw new TypeError('invalid iv length ' + iv.length)
- }
- if (config.type === 'stream') {
- return new StreamCipher(modelist[config.mode], password, iv)
- } else if (config.type === 'auth') {
- return new AuthCipher(modelist[config.mode], password, iv)
- }
- return new Cipher(modelist[config.mode], password, iv)
- }
- function createCipher (suite, password) {
- var config = modes[suite.toLowerCase()]
- if (!config) {
- throw new TypeError('invalid suite type')
- }
- var keys = ebtk(password, false, config.key, config.iv)
- return createCipheriv(suite, keys.key, keys.iv)
- }
- exports.createCipheriv = createCipheriv
- exports.createCipher = createCipher
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 286 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var zeros = new Buffer(16)
- zeros.fill(0)
- module.exports = GHASH
- function GHASH (key) {
- this.h = key
- this.state = new Buffer(16)
- this.state.fill(0)
- this.cache = new Buffer('')
- }
- // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
- // by Juho Vähä-Herttua
- GHASH.prototype.ghash = function (block) {
- var i = -1
- while (++i < block.length) {
- this.state[i] ^= block[i]
- }
- this._multiply()
- }
- GHASH.prototype._multiply = function () {
- var Vi = toArray(this.h)
- var Zi = [0, 0, 0, 0]
- var j, xi, lsb_Vi
- var i = -1
- while (++i < 128) {
- xi = (this.state[~~(i / 8)] & (1 << (7 - i % 8))) !== 0
- if (xi) {
- // Z_i+1 = Z_i ^ V_i
- Zi = xor(Zi, Vi)
- }
- // Store the value of LSB(V_i)
- lsb_Vi = (Vi[3] & 1) !== 0
- // V_i+1 = V_i >> 1
- for (j = 3; j > 0; j--) {
- Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
- }
- Vi[0] = Vi[0] >>> 1
- // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
- if (lsb_Vi) {
- Vi[0] = Vi[0] ^ (0xe1 << 24)
- }
- }
- this.state = fromArray(Zi)
- }
- GHASH.prototype.update = function (buf) {
- this.cache = Buffer.concat([this.cache, buf])
- var chunk
- while (this.cache.length >= 16) {
- chunk = this.cache.slice(0, 16)
- this.cache = this.cache.slice(16)
- this.ghash(chunk)
- }
- }
- GHASH.prototype.final = function (abl, bl) {
- if (this.cache.length) {
- this.ghash(Buffer.concat([this.cache, zeros], 16))
- }
- this.ghash(fromArray([
- 0, abl,
- 0, bl
- ]))
- return this.state
- }
- function toArray (buf) {
- return [
- buf.readUInt32BE(0),
- buf.readUInt32BE(4),
- buf.readUInt32BE(8),
- buf.readUInt32BE(12)
- ]
- }
- function fromArray (out) {
- out = out.map(fixup_uint32)
- var buf = new Buffer(16)
- buf.writeUInt32BE(out[0], 0)
- buf.writeUInt32BE(out[1], 4)
- buf.writeUInt32BE(out[2], 8)
- buf.writeUInt32BE(out[3], 12)
- return buf
- }
- var uint_max = Math.pow(2, 32)
- function fixup_uint32 (x) {
- var ret, x_pos
- ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
- return ret
- }
- function xor (a, b) {
- return [
- a[0] ^ b[0],
- a[1] ^ b[1],
- a[2] ^ b[2],
- a[3] ^ b[3]
- ]
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 287 */
- /***/ function(module, exports, __webpack_require__) {
- var ebtk = __webpack_require__(95)
- var aes = __webpack_require__(102)
- var DES = __webpack_require__(288)
- var desModes = __webpack_require__(289)
- var aesModes = __webpack_require__(80)
- function createCipher (suite, password) {
- var keyLen, ivLen
- suite = suite.toLowerCase()
- if (aesModes[suite]) {
- keyLen = aesModes[suite].key
- ivLen = aesModes[suite].iv
- } else if (desModes[suite]) {
- keyLen = desModes[suite].key * 8
- ivLen = desModes[suite].iv
- } else {
- throw new TypeError('invalid suite type')
- }
- var keys = ebtk(password, false, keyLen, ivLen)
- return createCipheriv(suite, keys.key, keys.iv)
- }
- function createDecipher (suite, password) {
- var keyLen, ivLen
- suite = suite.toLowerCase()
- if (aesModes[suite]) {
- keyLen = aesModes[suite].key
- ivLen = aesModes[suite].iv
- } else if (desModes[suite]) {
- keyLen = desModes[suite].key * 8
- ivLen = desModes[suite].iv
- } else {
- throw new TypeError('invalid suite type')
- }
- var keys = ebtk(password, false, keyLen, ivLen)
- return createDecipheriv(suite, keys.key, keys.iv)
- }
- function createCipheriv (suite, key, iv) {
- suite = suite.toLowerCase()
- if (aesModes[suite]) {
- return aes.createCipheriv(suite, key, iv)
- } else if (desModes[suite]) {
- return new DES({
- key: key,
- iv: iv,
- mode: suite
- })
- } else {
- throw new TypeError('invalid suite type')
- }
- }
- function createDecipheriv (suite, key, iv) {
- suite = suite.toLowerCase()
- if (aesModes[suite]) {
- return aes.createDecipheriv(suite, key, iv)
- } else if (desModes[suite]) {
- return new DES({
- key: key,
- iv: iv,
- mode: suite,
- decrypt: true
- })
- } else {
- throw new TypeError('invalid suite type')
- }
- }
- exports.createCipher = exports.Cipher = createCipher
- exports.createCipheriv = exports.Cipheriv = createCipheriv
- exports.createDecipher = exports.Decipher = createDecipher
- exports.createDecipheriv = exports.Decipheriv = createDecipheriv
- function getCiphers () {
- return Object.keys(desModes).concat(aes.getCiphers())
- }
- exports.listCiphers = exports.getCiphers = getCiphers
- /***/ },
- /* 288 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var CipherBase = __webpack_require__(57)
- var des = __webpack_require__(132)
- var inherits = __webpack_require__(2)
- var modes = {
- 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
- 'des-ede3': des.EDE,
- 'des-ede-cbc': des.CBC.instantiate(des.EDE),
- 'des-ede': des.EDE,
- 'des-cbc': des.CBC.instantiate(des.DES),
- 'des-ecb': des.DES
- }
- modes.des = modes['des-cbc']
- modes.des3 = modes['des-ede3-cbc']
- module.exports = DES
- inherits(DES, CipherBase)
- function DES (opts) {
- CipherBase.call(this)
- var modeName = opts.mode.toLowerCase()
- var mode = modes[modeName]
- var type
- if (opts.decrypt) {
- type = 'decrypt'
- } else {
- type = 'encrypt'
- }
- var key = opts.key
- if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
- key = Buffer.concat([key, key.slice(0, 8)])
- }
- var iv = opts.iv
- this._des = mode.create({
- key: key,
- iv: iv,
- type: type
- })
- }
- DES.prototype._update = function (data) {
- return new Buffer(this._des.update(data))
- }
- DES.prototype._final = function () {
- return new Buffer(this._des.final())
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 289 */
- /***/ function(module, exports) {
- exports['des-ecb'] = {
- key: 8,
- iv: 0
- }
- exports['des-cbc'] = exports.des = {
- key: 8,
- iv: 8
- }
- exports['des-ede3-cbc'] = exports.des3 = {
- key: 24,
- iv: 8
- }
- exports['des-ede3'] = {
- key: 24,
- iv: 0
- }
- exports['des-ede-cbc'] = {
- key: 16,
- iv: 8
- }
- exports['des-ede'] = {
- key: 16,
- iv: 0
- }
- /***/ },
- /* 290 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var _algos = __webpack_require__(165)
- var createHash = __webpack_require__(63)
- var inherits = __webpack_require__(2)
- var sign = __webpack_require__(291)
- var stream = __webpack_require__(9)
- var verify = __webpack_require__(292)
- var algos = {}
- Object.keys(_algos).forEach(function (key) {
- algos[key] = algos[key.toLowerCase()] = _algos[key]
- })
- function Sign (algorithm) {
- stream.Writable.call(this)
- var data = algos[algorithm]
- if (!data) {
- throw new Error('Unknown message digest')
- }
- this._hashType = data.hash
- this._hash = createHash(data.hash)
- this._tag = data.id
- this._signType = data.sign
- }
- inherits(Sign, stream.Writable)
- Sign.prototype._write = function _write (data, _, done) {
- this._hash.update(data)
- done()
- }
- Sign.prototype.update = function update (data, enc) {
- if (typeof data === 'string') {
- data = new Buffer(data, enc)
- }
- this._hash.update(data)
- return this
- }
- Sign.prototype.sign = function signMethod (key, enc) {
- this.end()
- var hash = this._hash.digest()
- var sig = sign(Buffer.concat([this._tag, hash]), key, this._hashType, this._signType)
- return enc ? sig.toString(enc) : sig
- }
- function Verify (algorithm) {
- stream.Writable.call(this)
- var data = algos[algorithm]
- if (!data) {
- throw new Error('Unknown message digest')
- }
- this._hash = createHash(data.hash)
- this._tag = data.id
- this._signType = data.sign
- }
- inherits(Verify, stream.Writable)
- Verify.prototype._write = function _write (data, _, done) {
- this._hash.update(data)
- done()
- }
- Verify.prototype.update = function update (data, enc) {
- if (typeof data === 'string') {
- data = new Buffer(data, enc)
- }
- this._hash.update(data)
- return this
- }
- Verify.prototype.verify = function verifyMethod (key, sig, enc) {
- if (typeof sig === 'string') {
- sig = new Buffer(sig, enc)
- }
- this.end()
- var hash = this._hash.digest()
- return verify(sig, Buffer.concat([this._tag, hash]), key, this._signType)
- }
- function createSign (algorithm) {
- return new Sign(algorithm)
- }
- function createVerify (algorithm) {
- return new Verify(algorithm)
- }
- module.exports = {
- Sign: createSign,
- Verify: createVerify,
- createSign: createSign,
- createVerify: createVerify
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 291 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
- var createHmac = __webpack_require__(130)
- var crt = __webpack_require__(103)
- var curves = __webpack_require__(166)
- var elliptic = __webpack_require__(20)
- var parseKeys = __webpack_require__(97)
- var BN = __webpack_require__(12)
- var EC = elliptic.ec
- function sign (hash, key, hashType, signType) {
- var priv = parseKeys(key)
- if (priv.curve) {
- if (signType !== 'ecdsa') throw new Error('wrong private key type')
- return ecSign(hash, priv)
- } else if (priv.type === 'dsa') {
- if (signType !== 'dsa') {
- throw new Error('wrong private key type')
- }
- return dsaSign(hash, priv, hashType)
- } else {
- if (signType !== 'rsa') throw new Error('wrong private key type')
- }
- var len = priv.modulus.byteLength()
- var pad = [ 0, 1 ]
- while (hash.length + pad.length + 1 < len) {
- pad.push(0xff)
- }
- pad.push(0x00)
- var i = -1
- while (++i < hash.length) {
- pad.push(hash[i])
- }
- var out = crt(pad, priv)
- return out
- }
- function ecSign (hash, priv) {
- var curveId = curves[priv.curve.join('.')]
- if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
- var curve = new EC(curveId)
- var key = curve.genKeyPair()
- key._importPrivate(priv.privateKey)
- var out = key.sign(hash)
- return new Buffer(out.toDER())
- }
- function dsaSign (hash, priv, algo) {
- var x = priv.params.priv_key
- var p = priv.params.p
- var q = priv.params.q
- var g = priv.params.g
- var r = new BN(0)
- var k
- var H = bits2int(hash, q).mod(q)
- var s = false
- var kv = getKey(x, q, hash, algo)
- while (s === false) {
- k = makeKey(q, kv, algo)
- r = makeR(g, k, p, q)
- s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
- if (!s.cmpn(0)) {
- s = false
- r = new BN(0)
- }
- }
- return toDER(r, s)
- }
- function toDER (r, s) {
- r = r.toArray()
- s = s.toArray()
- // Pad values
- if (r[0] & 0x80) {
- r = [ 0 ].concat(r)
- }
- // Pad values
- if (s[0] & 0x80) {
- s = [0].concat(s)
- }
- var total = r.length + s.length + 4
- var res = [ 0x30, total, 0x02, r.length ]
- res = res.concat(r, [ 0x02, s.length ], s)
- return new Buffer(res)
- }
- function getKey (x, q, hash, algo) {
- x = new Buffer(x.toArray())
- if (x.length < q.byteLength()) {
- var zeros = new Buffer(q.byteLength() - x.length)
- zeros.fill(0)
- x = Buffer.concat([zeros, x])
- }
- var hlen = hash.length
- var hbits = bits2octets(hash, q)
- var v = new Buffer(hlen)
- v.fill(1)
- var k = new Buffer(hlen)
- k.fill(0)
- k = createHmac(algo, k)
- .update(v)
- .update(new Buffer([0]))
- .update(x)
- .update(hbits)
- .digest()
- v = createHmac(algo, k)
- .update(v)
- .digest()
- k = createHmac(algo, k)
- .update(v)
- .update(new Buffer([1]))
- .update(x)
- .update(hbits)
- .digest()
- v = createHmac(algo, k)
- .update(v)
- .digest()
- return {
- k: k,
- v: v
- }
- }
- function bits2int (obits, q) {
- var bits = new BN(obits)
- var shift = (obits.length << 3) - q.bitLength()
- if (shift > 0) {
- bits.ishrn(shift)
- }
- return bits
- }
- function bits2octets (bits, q) {
- bits = bits2int(bits, q)
- bits = bits.mod(q)
- var out = new Buffer(bits.toArray())
- if (out.length < q.byteLength()) {
- var zeros = new Buffer(q.byteLength() - out.length)
- zeros.fill(0)
- out = Buffer.concat([zeros, out])
- }
- return out
- }
- function makeKey (q, kv, algo) {
- var t, k
- do {
- t = new Buffer('')
- while (t.length * 8 < q.bitLength()) {
- kv.v = createHmac(algo, kv.k)
- .update(kv.v)
- .digest()
- t = Buffer.concat([t, kv.v])
- }
- k = bits2int(t, q)
- kv.k = createHmac(algo, kv.k)
- .update(kv.v)
- .update(new Buffer([0]))
- .digest()
- kv.v = createHmac(algo, kv.k)
- .update(kv.v)
- .digest()
- } while (k.cmp(q) !== -1)
- return k
- }
- function makeR (g, k, p, q) {
- return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
- }
- module.exports = sign
- module.exports.getKey = getKey
- module.exports.makeKey = makeKey
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 292 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
- var curves = __webpack_require__(166)
- var elliptic = __webpack_require__(20)
- var parseKeys = __webpack_require__(97)
- var BN = __webpack_require__(12)
- var EC = elliptic.ec
- function verify (sig, hash, key, signType) {
- var pub = parseKeys(key)
- if (pub.type === 'ec') {
- if (signType !== 'ecdsa') {
- throw new Error('wrong public key type')
- }
- return ecVerify(sig, hash, pub)
- } else if (pub.type === 'dsa') {
- if (signType !== 'dsa') {
- throw new Error('wrong public key type')
- }
- return dsaVerify(sig, hash, pub)
- } else {
- if (signType !== 'rsa') {
- throw new Error('wrong public key type')
- }
- }
- var len = pub.modulus.byteLength()
- var pad = [ 1 ]
- var padNum = 0
- while (hash.length + pad.length + 2 < len) {
- pad.push(0xff)
- padNum++
- }
- pad.push(0x00)
- var i = -1
- while (++i < hash.length) {
- pad.push(hash[i])
- }
- pad = new Buffer(pad)
- var red = BN.mont(pub.modulus)
- sig = new BN(sig).toRed(red)
- sig = sig.redPow(new BN(pub.publicExponent))
- sig = new Buffer(sig.fromRed().toArray())
- var out = 0
- if (padNum < 8) {
- out = 1
- }
- len = Math.min(sig.length, pad.length)
- if (sig.length !== pad.length) {
- out = 1
- }
- i = -1
- while (++i < len) {
- out |= (sig[i] ^ pad[i])
- }
- return out === 0
- }
- function ecVerify (sig, hash, pub) {
- var curveId = curves[pub.data.algorithm.curve.join('.')]
- if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
- var curve = new EC(curveId)
- var pubkey = pub.data.subjectPrivateKey.data
- return curve.verify(hash, sig, pubkey)
- }
- function dsaVerify (sig, hash, pub) {
- var p = pub.data.p
- var q = pub.data.q
- var g = pub.data.g
- var y = pub.data.pub_key
- var unpacked = parseKeys.signature.decode(sig, 'der')
- var s = unpacked.s
- var r = unpacked.r
- checkValue(s, q)
- checkValue(r, q)
- var montp = BN.mont(p)
- var w = s.invm(q)
- var v = g.toRed(montp)
- .redPow(new BN(hash).mul(w).mod(q))
- .fromRed()
- .mul(
- y.toRed(montp)
- .redPow(r.mul(w).mod(q))
- .fromRed()
- ).mod(p).mod(q)
- return !v.cmp(r)
- }
- function checkValue (b, q) {
- if (b.cmpn(0) <= 0) {
- throw new Error('invalid sig')
- }
- if (b.cmp(q) >= q) {
- throw new Error('invalid sig')
- }
- }
- module.exports = verify
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 293 */
- /***/ function(module, exports) {
- module.exports = {
- "100": "Continue",
- "101": "Switching Protocols",
- "102": "Processing",
- "200": "OK",
- "201": "Created",
- "202": "Accepted",
- "203": "Non-Authoritative Information",
- "204": "No Content",
- "205": "Reset Content",
- "206": "Partial Content",
- "207": "Multi-Status",
- "208": "Already Reported",
- "226": "IM Used",
- "300": "Multiple Choices",
- "301": "Moved Permanently",
- "302": "Found",
- "303": "See Other",
- "304": "Not Modified",
- "305": "Use Proxy",
- "307": "Temporary Redirect",
- "308": "Permanent Redirect",
- "400": "Bad Request",
- "401": "Unauthorized",
- "402": "Payment Required",
- "403": "Forbidden",
- "404": "Not Found",
- "405": "Method Not Allowed",
- "406": "Not Acceptable",
- "407": "Proxy Authentication Required",
- "408": "Request Timeout",
- "409": "Conflict",
- "410": "Gone",
- "411": "Length Required",
- "412": "Precondition Failed",
- "413": "Payload Too Large",
- "414": "URI Too Long",
- "415": "Unsupported Media Type",
- "416": "Range Not Satisfiable",
- "417": "Expectation Failed",
- "418": "I'm a teapot",
- "421": "Misdirected Request",
- "422": "Unprocessable Entity",
- "423": "Locked",
- "424": "Failed Dependency",
- "425": "Unordered Collection",
- "426": "Upgrade Required",
- "428": "Precondition Required",
- "429": "Too Many Requests",
- "431": "Request Header Fields Too Large",
- "500": "Internal Server Error",
- "501": "Not Implemented",
- "502": "Bad Gateway",
- "503": "Service Unavailable",
- "504": "Gateway Timeout",
- "505": "HTTP Version Not Supported",
- "506": "Variant Also Negotiates",
- "507": "Insufficient Storage",
- "508": "Loop Detected",
- "509": "Bandwidth Limit Exceeded",
- "510": "Not Extended",
- "511": "Network Authentication Required"
- }
- /***/ },
- /* 294 */
- /***/ function(module, exports) {
- module.exports = function (xs, fn) {
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- var x = fn(xs[i], i);
- if (isArray(x)) res.push.apply(res, x);
- else res.push(x);
- }
- return res;
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- /***/ },
- /* 295 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(305);
- module.exports = __webpack_require__(32).RegExp.escape;
- /***/ },
- /* 296 */
- /***/ function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(7)
- , isArray = __webpack_require__(112)
- , SPECIES = __webpack_require__(8)('species');
- module.exports = function(original){
- var C;
- if(isArray(original)){
- C = original.constructor;
- // cross-realm fallback
- if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
- if(isObject(C)){
- C = C[SPECIES];
- if(C === null)C = undefined;
- }
- } return C === undefined ? Array : C;
- };
- /***/ },
- /* 297 */
- /***/ function(module, exports, __webpack_require__) {
- // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
- var speciesConstructor = __webpack_require__(296);
- module.exports = function(original, length){
- return new (speciesConstructor(original))(length);
- };
- /***/ },
- /* 298 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var anObject = __webpack_require__(3)
- , toPrimitive = __webpack_require__(34)
- , NUMBER = 'number';
- module.exports = function(hint){
- if(hint !== 'string' && hint !== NUMBER && hint !== 'default')throw TypeError('Incorrect hint');
- return toPrimitive(anObject(this), hint != NUMBER);
- };
- /***/ },
- /* 299 */
- /***/ function(module, exports, __webpack_require__) {
- // all enumerable object keys, includes symbols
- var getKeys = __webpack_require__(49)
- , gOPS = __webpack_require__(90)
- , pIE = __webpack_require__(71);
- module.exports = function(it){
- var result = getKeys(it)
- , getSymbols = gOPS.f;
- if(getSymbols){
- var symbols = getSymbols(it)
- , isEnum = pIE.f
- , i = 0
- , key;
- while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
- } return result;
- };
- /***/ },
- /* 300 */
- /***/ function(module, exports, __webpack_require__) {
- var getKeys = __webpack_require__(49)
- , toIObject = __webpack_require__(24);
- module.exports = function(object, el){
- var O = toIObject(object)
- , keys = getKeys(O)
- , length = keys.length
- , index = 0
- , key;
- while(length > index)if(O[key = keys[index++]] === el)return key;
- };
- /***/ },
- /* 301 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var path = __webpack_require__(302)
- , invoke = __webpack_require__(86)
- , aFunction = __webpack_require__(21);
- module.exports = function(/* ...pargs */){
- var fn = aFunction(this)
- , length = arguments.length
- , pargs = Array(length)
- , i = 0
- , _ = path._
- , holder = false;
- while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
- return function(/* ...args */){
- var that = this
- , aLen = arguments.length
- , j = 0, k = 0, args;
- if(!holder && !aLen)return invoke(fn, pargs, that);
- args = pargs.slice();
- if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
- while(aLen > k)args.push(arguments[k++]);
- return invoke(fn, args, that);
- };
- };
- /***/ },
- /* 302 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(5);
- /***/ },
- /* 303 */
- /***/ function(module, exports) {
- module.exports = function(regExp, replace){
- var replacer = replace === Object(replace) ? function(part){
- return replace[part];
- } : replace;
- return function(it){
- return String(it).replace(regExp, replacer);
- };
- };
- /***/ },
- /* 304 */
- /***/ function(module, exports, __webpack_require__) {
- var classof = __webpack_require__(59)
- , ITERATOR = __webpack_require__(8)('iterator')
- , Iterators = __webpack_require__(45);
- module.exports = __webpack_require__(32).isIterable = function(it){
- var O = Object(it);
- return O[ITERATOR] !== undefined
- || '@@iterator' in O
- || Iterators.hasOwnProperty(classof(O));
- };
- /***/ },
- /* 305 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/benjamingr/RexExp.escape
- var $export = __webpack_require__(0)
- , $re = __webpack_require__(303)(/[\\^$*+?.()|[\]{}]/g, '\\$&');
- $export($export.S, 'RegExp', {escape: function escape(it){ return $re(it); }});
- /***/ },
- /* 306 */
- /***/ function(module, exports, __webpack_require__) {
- // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
- var $export = __webpack_require__(0);
- $export($export.P, 'Array', {copyWithin: __webpack_require__(169)});
- __webpack_require__(58)('copyWithin');
- /***/ },
- /* 307 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $every = __webpack_require__(31)(4);
- $export($export.P + $export.F * !__webpack_require__(29)([].every, true), 'Array', {
- // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
- every: function every(callbackfn /* , thisArg */){
- return $every(this, callbackfn, arguments[1]);
- }
- });
- /***/ },
- /* 308 */
- /***/ function(module, exports, __webpack_require__) {
- // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
- var $export = __webpack_require__(0);
- $export($export.P, 'Array', {fill: __webpack_require__(104)});
- __webpack_require__(58)('fill');
- /***/ },
- /* 309 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $filter = __webpack_require__(31)(2);
- $export($export.P + $export.F * !__webpack_require__(29)([].filter, true), 'Array', {
- // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
- filter: function filter(callbackfn /* , thisArg */){
- return $filter(this, callbackfn, arguments[1]);
- }
- });
- /***/ },
- /* 310 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
- var $export = __webpack_require__(0)
- , $find = __webpack_require__(31)(6)
- , KEY = 'findIndex'
- , forced = true;
- // Shouldn't skip holes
- if(KEY in [])Array(1)[KEY](function(){ forced = false; });
- $export($export.P + $export.F * forced, 'Array', {
- findIndex: function findIndex(callbackfn/*, that = undefined */){
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(58)(KEY);
- /***/ },
- /* 311 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
- var $export = __webpack_require__(0)
- , $find = __webpack_require__(31)(5)
- , KEY = 'find'
- , forced = true;
- // Shouldn't skip holes
- if(KEY in [])Array(1)[KEY](function(){ forced = false; });
- $export($export.P + $export.F * forced, 'Array', {
- find: function find(callbackfn/*, that = undefined */){
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(58)(KEY);
- /***/ },
- /* 312 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $forEach = __webpack_require__(31)(0)
- , STRICT = __webpack_require__(29)([].forEach, true);
- $export($export.P + $export.F * !STRICT, 'Array', {
- // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
- forEach: function forEach(callbackfn /* , thisArg */){
- return $forEach(this, callbackfn, arguments[1]);
- }
- });
- /***/ },
- /* 313 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var ctx = __webpack_require__(35)
- , $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , call = __webpack_require__(177)
- , isArrayIter = __webpack_require__(111)
- , toLength = __webpack_require__(15)
- , createProperty = __webpack_require__(105)
- , getIterFn = __webpack_require__(128);
- $export($export.S + $export.F * !__webpack_require__(88)(function(iter){ Array.from(iter); }), 'Array', {
- // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
- from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
- var O = toObject(arrayLike)
- , C = typeof this == 'function' ? this : Array
- , aLen = arguments.length
- , mapfn = aLen > 1 ? arguments[1] : undefined
- , mapping = mapfn !== undefined
- , index = 0
- , iterFn = getIterFn(O)
- , length, result, step, iterator;
- if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
- // if object isn't iterable or it's array with default iterator - use simple case
- if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
- for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
- createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
- }
- } else {
- length = toLength(O.length);
- for(result = new C(length); length > index; index++){
- createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
- }
- }
- result.length = index;
- return result;
- }
- });
- /***/ },
- /* 314 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $indexOf = __webpack_require__(82)(false)
- , $native = [].indexOf
- , NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
- $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(29)($native)), 'Array', {
- // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
- indexOf: function indexOf(searchElement /*, fromIndex = 0 */){
- return NEGATIVE_ZERO
- // convert -0 to +0
- ? $native.apply(this, arguments) || 0
- : $indexOf(this, searchElement, arguments[1]);
- }
- });
- /***/ },
- /* 315 */
- /***/ function(module, exports, __webpack_require__) {
- // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
- var $export = __webpack_require__(0);
- $export($export.S, 'Array', {isArray: __webpack_require__(112)});
- /***/ },
- /* 316 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 22.1.3.13 Array.prototype.join(separator)
- var $export = __webpack_require__(0)
- , toIObject = __webpack_require__(24)
- , arrayJoin = [].join;
- // fallback for not array-like strings
- $export($export.P + $export.F * (__webpack_require__(70) != Object || !__webpack_require__(29)(arrayJoin)), 'Array', {
- join: function join(separator){
- return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);
- }
- });
- /***/ },
- /* 317 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toIObject = __webpack_require__(24)
- , toInteger = __webpack_require__(42)
- , toLength = __webpack_require__(15)
- , $native = [].lastIndexOf
- , NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
- $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(29)($native)), 'Array', {
- // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
- lastIndexOf: function lastIndexOf(searchElement /*, fromIndex = @[*-1] */){
- // convert -0 to +0
- if(NEGATIVE_ZERO)return $native.apply(this, arguments) || 0;
- var O = toIObject(this)
- , length = toLength(O.length)
- , index = length - 1;
- if(arguments.length > 1)index = Math.min(index, toInteger(arguments[1]));
- if(index < 0)index = length + index;
- for(;index >= 0; index--)if(index in O)if(O[index] === searchElement)return index || 0;
- return -1;
- }
- });
- /***/ },
- /* 318 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $map = __webpack_require__(31)(1);
- $export($export.P + $export.F * !__webpack_require__(29)([].map, true), 'Array', {
- // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
- map: function map(callbackfn /* , thisArg */){
- return $map(this, callbackfn, arguments[1]);
- }
- });
- /***/ },
- /* 319 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , createProperty = __webpack_require__(105);
- // WebKit Array.of isn't generic
- $export($export.S + $export.F * __webpack_require__(6)(function(){
- function F(){}
- return !(Array.of.call(F) instanceof F);
- }), 'Array', {
- // 22.1.2.3 Array.of( ...items)
- of: function of(/* ...args */){
- var index = 0
- , aLen = arguments.length
- , result = new (typeof this == 'function' ? this : Array)(aLen);
- while(aLen > index)createProperty(result, index, arguments[index++]);
- result.length = aLen;
- return result;
- }
- });
- /***/ },
- /* 320 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $reduce = __webpack_require__(171);
- $export($export.P + $export.F * !__webpack_require__(29)([].reduceRight, true), 'Array', {
- // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
- reduceRight: function reduceRight(callbackfn /* , initialValue */){
- return $reduce(this, callbackfn, arguments.length, arguments[1], true);
- }
- });
- /***/ },
- /* 321 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $reduce = __webpack_require__(171);
- $export($export.P + $export.F * !__webpack_require__(29)([].reduce, true), 'Array', {
- // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
- reduce: function reduce(callbackfn /* , initialValue */){
- return $reduce(this, callbackfn, arguments.length, arguments[1], false);
- }
- });
- /***/ },
- /* 322 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , html = __webpack_require__(109)
- , cof = __webpack_require__(27)
- , toIndex = __webpack_require__(52)
- , toLength = __webpack_require__(15)
- , arraySlice = [].slice;
- // fallback for not array-like ES3 strings and DOM objects
- $export($export.P + $export.F * __webpack_require__(6)(function(){
- if(html)arraySlice.call(html);
- }), 'Array', {
- slice: function slice(begin, end){
- var len = toLength(this.length)
- , klass = cof(this);
- end = end === undefined ? len : end;
- if(klass == 'Array')return arraySlice.call(this, begin, end);
- var start = toIndex(begin, len)
- , upTo = toIndex(end, len)
- , size = toLength(upTo - start)
- , cloned = Array(size)
- , i = 0;
- for(; i < size; i++)cloned[i] = klass == 'String'
- ? this.charAt(start + i)
- : this[start + i];
- return cloned;
- }
- });
- /***/ },
- /* 323 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $some = __webpack_require__(31)(3);
- $export($export.P + $export.F * !__webpack_require__(29)([].some, true), 'Array', {
- // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
- some: function some(callbackfn /* , thisArg */){
- return $some(this, callbackfn, arguments[1]);
- }
- });
- /***/ },
- /* 324 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , aFunction = __webpack_require__(21)
- , toObject = __webpack_require__(16)
- , fails = __webpack_require__(6)
- , $sort = [].sort
- , test = [1, 2, 3];
- $export($export.P + $export.F * (fails(function(){
- // IE8-
- test.sort(undefined);
- }) || !fails(function(){
- // V8 bug
- test.sort(null);
- // Old WebKit
- }) || !__webpack_require__(29)($sort)), 'Array', {
- // 22.1.3.25 Array.prototype.sort(comparefn)
- sort: function sort(comparefn){
- return comparefn === undefined
- ? $sort.call(toObject(this))
- : $sort.call(toObject(this), aFunction(comparefn));
- }
- });
- /***/ },
- /* 325 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(51)('Array');
- /***/ },
- /* 326 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.3.3.1 / 15.9.4.4 Date.now()
- var $export = __webpack_require__(0);
- $export($export.S, 'Date', {now: function(){ return new Date().getTime(); }});
- /***/ },
- /* 327 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
- var $export = __webpack_require__(0)
- , fails = __webpack_require__(6)
- , getTime = Date.prototype.getTime;
- var lz = function(num){
- return num > 9 ? num : '0' + num;
- };
- // PhantomJS / old WebKit has a broken implementations
- $export($export.P + $export.F * (fails(function(){
- return new Date(-5e13 - 1).toISOString() != '0385-07-25T07:06:39.999Z';
- }) || !fails(function(){
- new Date(NaN).toISOString();
- })), 'Date', {
- toISOString: function toISOString(){
- if(!isFinite(getTime.call(this)))throw RangeError('Invalid time value');
- var d = this
- , y = d.getUTCFullYear()
- , m = d.getUTCMilliseconds()
- , s = y < 0 ? '-' : y > 9999 ? '+' : '';
- return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
- '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
- 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
- ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
- }
- });
- /***/ },
- /* 328 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , toPrimitive = __webpack_require__(34);
- $export($export.P + $export.F * __webpack_require__(6)(function(){
- return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1;
- }), 'Date', {
- toJSON: function toJSON(key){
- var O = toObject(this)
- , pv = toPrimitive(O);
- return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
- }
- });
- /***/ },
- /* 329 */
- /***/ function(module, exports, __webpack_require__) {
- var TO_PRIMITIVE = __webpack_require__(8)('toPrimitive')
- , proto = Date.prototype;
- if(!(TO_PRIMITIVE in proto))__webpack_require__(19)(proto, TO_PRIMITIVE, __webpack_require__(298));
- /***/ },
- /* 330 */
- /***/ function(module, exports, __webpack_require__) {
- var DateProto = Date.prototype
- , INVALID_DATE = 'Invalid Date'
- , TO_STRING = 'toString'
- , $toString = DateProto[TO_STRING]
- , getTime = DateProto.getTime;
- if(new Date(NaN) + '' != INVALID_DATE){
- __webpack_require__(22)(DateProto, TO_STRING, function toString(){
- var value = getTime.call(this);
- return value === value ? $toString.call(this) : INVALID_DATE;
- });
- }
- /***/ },
- /* 331 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
- var $export = __webpack_require__(0);
- $export($export.P, 'Function', {bind: __webpack_require__(172)});
- /***/ },
- /* 332 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var isObject = __webpack_require__(7)
- , getPrototypeOf = __webpack_require__(26)
- , HAS_INSTANCE = __webpack_require__(8)('hasInstance')
- , FunctionProto = Function.prototype;
- // 19.2.3.6 Function.prototype[@@hasInstance](V)
- if(!(HAS_INSTANCE in FunctionProto))__webpack_require__(11).f(FunctionProto, HAS_INSTANCE, {value: function(O){
- if(typeof this != 'function' || !isObject(O))return false;
- if(!isObject(this.prototype))return O instanceof this;
- // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
- while(O = getPrototypeOf(O))if(this.prototype === O)return true;
- return false;
- }});
- /***/ },
- /* 333 */
- /***/ function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(11).f
- , createDesc = __webpack_require__(41)
- , has = __webpack_require__(17)
- , FProto = Function.prototype
- , nameRE = /^\s*function ([^ (]*)/
- , NAME = 'name';
- var isExtensible = Object.isExtensible || function(){
- return true;
- };
- // 19.2.4.2 name
- NAME in FProto || __webpack_require__(10) && dP(FProto, NAME, {
- configurable: true,
- get: function(){
- try {
- var that = this
- , name = ('' + that).match(nameRE)[1];
- has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
- return name;
- } catch(e){
- return '';
- }
- }
- });
- /***/ },
- /* 334 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.3 Math.acosh(x)
- var $export = __webpack_require__(0)
- , log1p = __webpack_require__(179)
- , sqrt = Math.sqrt
- , $acosh = Math.acosh;
- $export($export.S + $export.F * !($acosh
- // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
- && Math.floor($acosh(Number.MAX_VALUE)) == 710
- // Tor Browser bug: Math.acosh(Infinity) -> NaN
- && $acosh(Infinity) == Infinity
- ), 'Math', {
- acosh: function acosh(x){
- return (x = +x) < 1 ? NaN : x > 94906265.62425156
- ? Math.log(x) + Math.LN2
- : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
- }
- });
- /***/ },
- /* 335 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.5 Math.asinh(x)
- var $export = __webpack_require__(0)
- , $asinh = Math.asinh;
- function asinh(x){
- return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
- }
- // Tor Browser bug: Math.asinh(0) -> -0
- $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', {asinh: asinh});
- /***/ },
- /* 336 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.7 Math.atanh(x)
- var $export = __webpack_require__(0)
- , $atanh = Math.atanh;
- // Tor Browser bug: Math.atanh(-0) -> 0
- $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {
- atanh: function atanh(x){
- return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
- }
- });
- /***/ },
- /* 337 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.9 Math.cbrt(x)
- var $export = __webpack_require__(0)
- , sign = __webpack_require__(117);
- $export($export.S, 'Math', {
- cbrt: function cbrt(x){
- return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
- }
- });
- /***/ },
- /* 338 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.11 Math.clz32(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- clz32: function clz32(x){
- return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
- }
- });
- /***/ },
- /* 339 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.12 Math.cosh(x)
- var $export = __webpack_require__(0)
- , exp = Math.exp;
- $export($export.S, 'Math', {
- cosh: function cosh(x){
- return (exp(x = +x) + exp(-x)) / 2;
- }
- });
- /***/ },
- /* 340 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.14 Math.expm1(x)
- var $export = __webpack_require__(0)
- , $expm1 = __webpack_require__(116);
- $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', {expm1: $expm1});
- /***/ },
- /* 341 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.16 Math.fround(x)
- var $export = __webpack_require__(0)
- , sign = __webpack_require__(117)
- , pow = Math.pow
- , EPSILON = pow(2, -52)
- , EPSILON32 = pow(2, -23)
- , MAX32 = pow(2, 127) * (2 - EPSILON32)
- , MIN32 = pow(2, -126);
- var roundTiesToEven = function(n){
- return n + 1 / EPSILON - 1 / EPSILON;
- };
- $export($export.S, 'Math', {
- fround: function fround(x){
- var $abs = Math.abs(x)
- , $sign = sign(x)
- , a, result;
- if($abs < MIN32)return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
- a = (1 + EPSILON32 / EPSILON) * $abs;
- result = a - (a - $abs);
- if(result > MAX32 || result != result)return $sign * Infinity;
- return $sign * result;
- }
- });
- /***/ },
- /* 342 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
- var $export = __webpack_require__(0)
- , abs = Math.abs;
- $export($export.S, 'Math', {
- hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
- var sum = 0
- , i = 0
- , aLen = arguments.length
- , larg = 0
- , arg, div;
- while(i < aLen){
- arg = abs(arguments[i++]);
- if(larg < arg){
- div = larg / arg;
- sum = sum * div * div + 1;
- larg = arg;
- } else if(arg > 0){
- div = arg / larg;
- sum += div * div;
- } else sum += arg;
- }
- return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
- }
- });
- /***/ },
- /* 343 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.18 Math.imul(x, y)
- var $export = __webpack_require__(0)
- , $imul = Math.imul;
- // some WebKit versions fails with big numbers, some has wrong arity
- $export($export.S + $export.F * __webpack_require__(6)(function(){
- return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
- }), 'Math', {
- imul: function imul(x, y){
- var UINT16 = 0xffff
- , xn = +x
- , yn = +y
- , xl = UINT16 & xn
- , yl = UINT16 & yn;
- return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
- }
- });
- /***/ },
- /* 344 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.21 Math.log10(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- log10: function log10(x){
- return Math.log(x) / Math.LN10;
- }
- });
- /***/ },
- /* 345 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.20 Math.log1p(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {log1p: __webpack_require__(179)});
- /***/ },
- /* 346 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.22 Math.log2(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- log2: function log2(x){
- return Math.log(x) / Math.LN2;
- }
- });
- /***/ },
- /* 347 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.28 Math.sign(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {sign: __webpack_require__(117)});
- /***/ },
- /* 348 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.30 Math.sinh(x)
- var $export = __webpack_require__(0)
- , expm1 = __webpack_require__(116)
- , exp = Math.exp;
- // V8 near Chromium 38 has a problem with very small numbers
- $export($export.S + $export.F * __webpack_require__(6)(function(){
- return !Math.sinh(-2e-17) != -2e-17;
- }), 'Math', {
- sinh: function sinh(x){
- return Math.abs(x = +x) < 1
- ? (expm1(x) - expm1(-x)) / 2
- : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
- }
- });
- /***/ },
- /* 349 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.33 Math.tanh(x)
- var $export = __webpack_require__(0)
- , expm1 = __webpack_require__(116)
- , exp = Math.exp;
- $export($export.S, 'Math', {
- tanh: function tanh(x){
- var a = expm1(x = +x)
- , b = expm1(-x);
- return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
- }
- });
- /***/ },
- /* 350 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.2.2.34 Math.trunc(x)
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- trunc: function trunc(it){
- return (it > 0 ? Math.floor : Math.ceil)(it);
- }
- });
- /***/ },
- /* 351 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var global = __webpack_require__(5)
- , has = __webpack_require__(17)
- , cof = __webpack_require__(27)
- , inheritIfRequired = __webpack_require__(110)
- , toPrimitive = __webpack_require__(34)
- , fails = __webpack_require__(6)
- , gOPN = __webpack_require__(48).f
- , gOPD = __webpack_require__(25).f
- , dP = __webpack_require__(11).f
- , $trim = __webpack_require__(62).trim
- , NUMBER = 'Number'
- , $Number = global[NUMBER]
- , Base = $Number
- , proto = $Number.prototype
- // Opera ~12 has broken Object#toString
- , BROKEN_COF = cof(__webpack_require__(47)(proto)) == NUMBER
- , TRIM = 'trim' in String.prototype;
- // 7.1.3 ToNumber(argument)
- var toNumber = function(argument){
- var it = toPrimitive(argument, false);
- if(typeof it == 'string' && it.length > 2){
- it = TRIM ? it.trim() : $trim(it, 3);
- var first = it.charCodeAt(0)
- , third, radix, maxCode;
- if(first === 43 || first === 45){
- third = it.charCodeAt(2);
- if(third === 88 || third === 120)return NaN; // Number('+0x1') should be NaN, old V8 fix
- } else if(first === 48){
- switch(it.charCodeAt(1)){
- case 66 : case 98 : radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i
- case 79 : case 111 : radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i
- default : return +it;
- }
- for(var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++){
- code = digits.charCodeAt(i);
- // parseInt parses a string to a first unavailable symbol
- // but ToNumber should return NaN if a string contains unavailable symbols
- if(code < 48 || code > maxCode)return NaN;
- } return parseInt(digits, radix);
- }
- } return +it;
- };
- if(!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')){
- $Number = function Number(value){
- var it = arguments.length < 1 ? 0 : value
- , that = this;
- return that instanceof $Number
- // check on 1..constructor(foo) case
- && (BROKEN_COF ? fails(function(){ proto.valueOf.call(that); }) : cof(that) != NUMBER)
- ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
- };
- for(var keys = __webpack_require__(10) ? gOPN(Base) : (
- // ES3:
- 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
- // ES6 (in case, if modules with ES6 Number statics required before):
- 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
- 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
- ).split(','), j = 0, key; keys.length > j; j++){
- if(has(Base, key = keys[j]) && !has($Number, key)){
- dP($Number, key, gOPD(Base, key));
- }
- }
- $Number.prototype = proto;
- proto.constructor = $Number;
- __webpack_require__(22)(global, NUMBER, $Number);
- }
- /***/ },
- /* 352 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.1 Number.EPSILON
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {EPSILON: Math.pow(2, -52)});
- /***/ },
- /* 353 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.2 Number.isFinite(number)
- var $export = __webpack_require__(0)
- , _isFinite = __webpack_require__(5).isFinite;
- $export($export.S, 'Number', {
- isFinite: function isFinite(it){
- return typeof it == 'number' && _isFinite(it);
- }
- });
- /***/ },
- /* 354 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.3 Number.isInteger(number)
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {isInteger: __webpack_require__(113)});
- /***/ },
- /* 355 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.4 Number.isNaN(number)
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {
- isNaN: function isNaN(number){
- return number != number;
- }
- });
- /***/ },
- /* 356 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.5 Number.isSafeInteger(number)
- var $export = __webpack_require__(0)
- , isInteger = __webpack_require__(113)
- , abs = Math.abs;
- $export($export.S, 'Number', {
- isSafeInteger: function isSafeInteger(number){
- return isInteger(number) && abs(number) <= 0x1fffffffffffff;
- }
- });
- /***/ },
- /* 357 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.6 Number.MAX_SAFE_INTEGER
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
- /***/ },
- /* 358 */
- /***/ function(module, exports, __webpack_require__) {
- // 20.1.2.10 Number.MIN_SAFE_INTEGER
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
- /***/ },
- /* 359 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $parseFloat = __webpack_require__(186);
- // 20.1.2.12 Number.parseFloat(string)
- $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', {parseFloat: $parseFloat});
- /***/ },
- /* 360 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $parseInt = __webpack_require__(187);
- // 20.1.2.13 Number.parseInt(string, radix)
- $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', {parseInt: $parseInt});
- /***/ },
- /* 361 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , anInstance = __webpack_require__(39)
- , toInteger = __webpack_require__(42)
- , aNumberValue = __webpack_require__(168)
- , repeat = __webpack_require__(123)
- , $toFixed = 1..toFixed
- , floor = Math.floor
- , data = [0, 0, 0, 0, 0, 0]
- , ERROR = 'Number.toFixed: incorrect invocation!'
- , ZERO = '0';
- var multiply = function(n, c){
- var i = -1
- , c2 = c;
- while(++i < 6){
- c2 += n * data[i];
- data[i] = c2 % 1e7;
- c2 = floor(c2 / 1e7);
- }
- };
- var divide = function(n){
- var i = 6
- , c = 0;
- while(--i >= 0){
- c += data[i];
- data[i] = floor(c / n);
- c = (c % n) * 1e7;
- }
- };
- var numToString = function(){
- var i = 6
- , s = '';
- while(--i >= 0){
- if(s !== '' || i === 0 || data[i] !== 0){
- var t = String(data[i]);
- s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;
- }
- } return s;
- };
- var pow = function(x, n, acc){
- return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
- };
- var log = function(x){
- var n = 0
- , x2 = x;
- while(x2 >= 4096){
- n += 12;
- x2 /= 4096;
- }
- while(x2 >= 2){
- n += 1;
- x2 /= 2;
- } return n;
- };
- $export($export.P + $export.F * (!!$toFixed && (
- 0.00008.toFixed(3) !== '0.000' ||
- 0.9.toFixed(0) !== '1' ||
- 1.255.toFixed(2) !== '1.25' ||
- 1000000000000000128..toFixed(0) !== '1000000000000000128'
- ) || !__webpack_require__(6)(function(){
- // V8 ~ Android 4.3-
- $toFixed.call({});
- })), 'Number', {
- toFixed: function toFixed(fractionDigits){
- var x = aNumberValue(this, ERROR)
- , f = toInteger(fractionDigits)
- , s = ''
- , m = ZERO
- , e, z, j, k;
- if(f < 0 || f > 20)throw RangeError(ERROR);
- if(x != x)return 'NaN';
- if(x <= -1e21 || x >= 1e21)return String(x);
- if(x < 0){
- s = '-';
- x = -x;
- }
- if(x > 1e-21){
- e = log(x * pow(2, 69, 1)) - 69;
- z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);
- z *= 0x10000000000000;
- e = 52 - e;
- if(e > 0){
- multiply(0, z);
- j = f;
- while(j >= 7){
- multiply(1e7, 0);
- j -= 7;
- }
- multiply(pow(10, j, 1), 0);
- j = e - 1;
- while(j >= 23){
- divide(1 << 23);
- j -= 23;
- }
- divide(1 << j);
- multiply(1, 1);
- divide(2);
- m = numToString();
- } else {
- multiply(0, z);
- multiply(1 << -e, 0);
- m = numToString() + repeat.call(ZERO, f);
- }
- }
- if(f > 0){
- k = m.length;
- m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));
- } else {
- m = s + m;
- } return m;
- }
- });
- /***/ },
- /* 362 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $fails = __webpack_require__(6)
- , aNumberValue = __webpack_require__(168)
- , $toPrecision = 1..toPrecision;
- $export($export.P + $export.F * ($fails(function(){
- // IE7-
- return $toPrecision.call(1, undefined) !== '1';
- }) || !$fails(function(){
- // V8 ~ Android 4.3-
- $toPrecision.call({});
- })), 'Number', {
- toPrecision: function toPrecision(precision){
- var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
- return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
- }
- });
- /***/ },
- /* 363 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.3.1 Object.assign(target, source)
- var $export = __webpack_require__(0);
- $export($export.S + $export.F, 'Object', {assign: __webpack_require__(180)});
- /***/ },
- /* 364 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- $export($export.S, 'Object', {create: __webpack_require__(47)});
- /***/ },
- /* 365 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0);
- // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
- $export($export.S + $export.F * !__webpack_require__(10), 'Object', {defineProperties: __webpack_require__(181)});
- /***/ },
- /* 366 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0);
- // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
- $export($export.S + $export.F * !__webpack_require__(10), 'Object', {defineProperty: __webpack_require__(11).f});
- /***/ },
- /* 367 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.5 Object.freeze(O)
- var isObject = __webpack_require__(7)
- , meta = __webpack_require__(40).onFreeze;
- __webpack_require__(33)('freeze', function($freeze){
- return function freeze(it){
- return $freeze && isObject(it) ? $freeze(meta(it)) : it;
- };
- });
- /***/ },
- /* 368 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- var toIObject = __webpack_require__(24)
- , $getOwnPropertyDescriptor = __webpack_require__(25).f;
- __webpack_require__(33)('getOwnPropertyDescriptor', function(){
- return function getOwnPropertyDescriptor(it, key){
- return $getOwnPropertyDescriptor(toIObject(it), key);
- };
- });
- /***/ },
- /* 369 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- __webpack_require__(33)('getOwnPropertyNames', function(){
- return __webpack_require__(182).f;
- });
- /***/ },
- /* 370 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.9 Object.getPrototypeOf(O)
- var toObject = __webpack_require__(16)
- , $getPrototypeOf = __webpack_require__(26);
- __webpack_require__(33)('getPrototypeOf', function(){
- return function getPrototypeOf(it){
- return $getPrototypeOf(toObject(it));
- };
- });
- /***/ },
- /* 371 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.11 Object.isExtensible(O)
- var isObject = __webpack_require__(7);
- __webpack_require__(33)('isExtensible', function($isExtensible){
- return function isExtensible(it){
- return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
- };
- });
- /***/ },
- /* 372 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.12 Object.isFrozen(O)
- var isObject = __webpack_require__(7);
- __webpack_require__(33)('isFrozen', function($isFrozen){
- return function isFrozen(it){
- return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
- };
- });
- /***/ },
- /* 373 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.13 Object.isSealed(O)
- var isObject = __webpack_require__(7);
- __webpack_require__(33)('isSealed', function($isSealed){
- return function isSealed(it){
- return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
- };
- });
- /***/ },
- /* 374 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.3.10 Object.is(value1, value2)
- var $export = __webpack_require__(0);
- $export($export.S, 'Object', {is: __webpack_require__(188)});
- /***/ },
- /* 375 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.14 Object.keys(O)
- var toObject = __webpack_require__(16)
- , $keys = __webpack_require__(49);
- __webpack_require__(33)('keys', function(){
- return function keys(it){
- return $keys(toObject(it));
- };
- });
- /***/ },
- /* 376 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.15 Object.preventExtensions(O)
- var isObject = __webpack_require__(7)
- , meta = __webpack_require__(40).onFreeze;
- __webpack_require__(33)('preventExtensions', function($preventExtensions){
- return function preventExtensions(it){
- return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
- };
- });
- /***/ },
- /* 377 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.2.17 Object.seal(O)
- var isObject = __webpack_require__(7)
- , meta = __webpack_require__(40).onFreeze;
- __webpack_require__(33)('seal', function($seal){
- return function seal(it){
- return $seal && isObject(it) ? $seal(meta(it)) : it;
- };
- });
- /***/ },
- /* 378 */
- /***/ function(module, exports, __webpack_require__) {
- // 19.1.3.19 Object.setPrototypeOf(O, proto)
- var $export = __webpack_require__(0);
- $export($export.S, 'Object', {setPrototypeOf: __webpack_require__(91).set});
- /***/ },
- /* 379 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 19.1.3.6 Object.prototype.toString()
- var classof = __webpack_require__(59)
- , test = {};
- test[__webpack_require__(8)('toStringTag')] = 'z';
- if(test + '' != '[object z]'){
- __webpack_require__(22)(Object.prototype, 'toString', function toString(){
- return '[object ' + classof(this) + ']';
- }, true);
- }
- /***/ },
- /* 380 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $parseFloat = __webpack_require__(186);
- // 18.2.4 parseFloat(string)
- $export($export.G + $export.F * (parseFloat != $parseFloat), {parseFloat: $parseFloat});
- /***/ },
- /* 381 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $parseInt = __webpack_require__(187);
- // 18.2.5 parseInt(string, radix)
- $export($export.G + $export.F * (parseInt != $parseInt), {parseInt: $parseInt});
- /***/ },
- /* 382 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var LIBRARY = __webpack_require__(46)
- , global = __webpack_require__(5)
- , ctx = __webpack_require__(35)
- , classof = __webpack_require__(59)
- , $export = __webpack_require__(0)
- , isObject = __webpack_require__(7)
- , anObject = __webpack_require__(3)
- , aFunction = __webpack_require__(21)
- , anInstance = __webpack_require__(39)
- , forOf = __webpack_require__(60)
- , setProto = __webpack_require__(91).set
- , speciesConstructor = __webpack_require__(120)
- , task = __webpack_require__(125).set
- , microtask = __webpack_require__(118)()
- , PROMISE = 'Promise'
- , TypeError = global.TypeError
- , process = global.process
- , $Promise = global[PROMISE]
- , process = global.process
- , isNode = classof(process) == 'process'
- , empty = function(){ /* empty */ }
- , Internal, GenericPromiseCapability, Wrapper;
- var USE_NATIVE = !!function(){
- try {
- // correct subclassing with @@species support
- var promise = $Promise.resolve(1)
- , FakePromise = (promise.constructor = {})[__webpack_require__(8)('species')] = function(exec){ exec(empty, empty); };
- // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
- return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
- } catch(e){ /* empty */ }
- }();
- // helpers
- var sameConstructor = function(a, b){
- // with library wrapper special case
- return a === b || a === $Promise && b === Wrapper;
- };
- var isThenable = function(it){
- var then;
- return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
- };
- var newPromiseCapability = function(C){
- return sameConstructor($Promise, C)
- ? new PromiseCapability(C)
- : new GenericPromiseCapability(C);
- };
- var PromiseCapability = GenericPromiseCapability = function(C){
- var resolve, reject;
- this.promise = new C(function($$resolve, $$reject){
- if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
- resolve = $$resolve;
- reject = $$reject;
- });
- this.resolve = aFunction(resolve);
- this.reject = aFunction(reject);
- };
- var perform = function(exec){
- try {
- exec();
- } catch(e){
- return {error: e};
- }
- };
- var notify = function(promise, isReject){
- if(promise._n)return;
- promise._n = true;
- var chain = promise._c;
- microtask(function(){
- var value = promise._v
- , ok = promise._s == 1
- , i = 0;
- var run = function(reaction){
- var handler = ok ? reaction.ok : reaction.fail
- , resolve = reaction.resolve
- , reject = reaction.reject
- , domain = reaction.domain
- , result, then;
- try {
- if(handler){
- if(!ok){
- if(promise._h == 2)onHandleUnhandled(promise);
- promise._h = 1;
- }
- if(handler === true)result = value;
- else {
- if(domain)domain.enter();
- result = handler(value);
- if(domain)domain.exit();
- }
- if(result === reaction.promise){
- reject(TypeError('Promise-chain cycle'));
- } else if(then = isThenable(result)){
- then.call(result, resolve, reject);
- } else resolve(result);
- } else reject(value);
- } catch(e){
- reject(e);
- }
- };
- while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
- promise._c = [];
- promise._n = false;
- if(isReject && !promise._h)onUnhandled(promise);
- });
- };
- var onUnhandled = function(promise){
- task.call(global, function(){
- var value = promise._v
- , abrupt, handler, console;
- if(isUnhandled(promise)){
- abrupt = perform(function(){
- if(isNode){
- process.emit('unhandledRejection', value, promise);
- } else if(handler = global.onunhandledrejection){
- handler({promise: promise, reason: value});
- } else if((console = global.console) && console.error){
- console.error('Unhandled promise rejection', value);
- }
- });
- // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
- promise._h = isNode || isUnhandled(promise) ? 2 : 1;
- } promise._a = undefined;
- if(abrupt)throw abrupt.error;
- });
- };
- var isUnhandled = function(promise){
- if(promise._h == 1)return false;
- var chain = promise._a || promise._c
- , i = 0
- , reaction;
- while(chain.length > i){
- reaction = chain[i++];
- if(reaction.fail || !isUnhandled(reaction.promise))return false;
- } return true;
- };
- var onHandleUnhandled = function(promise){
- task.call(global, function(){
- var handler;
- if(isNode){
- process.emit('rejectionHandled', promise);
- } else if(handler = global.onrejectionhandled){
- handler({promise: promise, reason: promise._v});
- }
- });
- };
- var $reject = function(value){
- var promise = this;
- if(promise._d)return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- promise._v = value;
- promise._s = 2;
- if(!promise._a)promise._a = promise._c.slice();
- notify(promise, true);
- };
- var $resolve = function(value){
- var promise = this
- , then;
- if(promise._d)return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- try {
- if(promise === value)throw TypeError("Promise can't be resolved itself");
- if(then = isThenable(value)){
- microtask(function(){
- var wrapper = {_w: promise, _d: false}; // wrap
- try {
- then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
- } catch(e){
- $reject.call(wrapper, e);
- }
- });
- } else {
- promise._v = value;
- promise._s = 1;
- notify(promise, false);
- }
- } catch(e){
- $reject.call({_w: promise, _d: false}, e); // wrap
- }
- };
- // constructor polyfill
- if(!USE_NATIVE){
- // 25.4.3.1 Promise(executor)
- $Promise = function Promise(executor){
- anInstance(this, $Promise, PROMISE, '_h');
- aFunction(executor);
- Internal.call(this);
- try {
- executor(ctx($resolve, this, 1), ctx($reject, this, 1));
- } catch(err){
- $reject.call(this, err);
- }
- };
- Internal = function Promise(executor){
- this._c = []; // <- awaiting reactions
- this._a = undefined; // <- checked in isUnhandled reactions
- this._s = 0; // <- state
- this._d = false; // <- done
- this._v = undefined; // <- value
- this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
- this._n = false; // <- notify
- };
- Internal.prototype = __webpack_require__(50)($Promise.prototype, {
- // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
- then: function then(onFulfilled, onRejected){
- var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
- reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
- reaction.fail = typeof onRejected == 'function' && onRejected;
- reaction.domain = isNode ? process.domain : undefined;
- this._c.push(reaction);
- if(this._a)this._a.push(reaction);
- if(this._s)notify(this, false);
- return reaction.promise;
- },
- // 25.4.5.1 Promise.prototype.catch(onRejected)
- 'catch': function(onRejected){
- return this.then(undefined, onRejected);
- }
- });
- PromiseCapability = function(){
- var promise = new Internal;
- this.promise = promise;
- this.resolve = ctx($resolve, promise, 1);
- this.reject = ctx($reject, promise, 1);
- };
- }
- $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
- __webpack_require__(61)($Promise, PROMISE);
- __webpack_require__(51)(PROMISE);
- Wrapper = __webpack_require__(32)[PROMISE];
- // statics
- $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
- // 25.4.4.5 Promise.reject(r)
- reject: function reject(r){
- var capability = newPromiseCapability(this)
- , $$reject = capability.reject;
- $$reject(r);
- return capability.promise;
- }
- });
- $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
- // 25.4.4.6 Promise.resolve(x)
- resolve: function resolve(x){
- // instanceof instead of internal slot check because we should fix it without replacement native Promise core
- if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
- var capability = newPromiseCapability(this)
- , $$resolve = capability.resolve;
- $$resolve(x);
- return capability.promise;
- }
- });
- $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(88)(function(iter){
- $Promise.all(iter)['catch'](empty);
- })), PROMISE, {
- // 25.4.4.1 Promise.all(iterable)
- all: function all(iterable){
- var C = this
- , capability = newPromiseCapability(C)
- , resolve = capability.resolve
- , reject = capability.reject;
- var abrupt = perform(function(){
- var values = []
- , index = 0
- , remaining = 1;
- forOf(iterable, false, function(promise){
- var $index = index++
- , alreadyCalled = false;
- values.push(undefined);
- remaining++;
- C.resolve(promise).then(function(value){
- if(alreadyCalled)return;
- alreadyCalled = true;
- values[$index] = value;
- --remaining || resolve(values);
- }, reject);
- });
- --remaining || resolve(values);
- });
- if(abrupt)reject(abrupt.error);
- return capability.promise;
- },
- // 25.4.4.4 Promise.race(iterable)
- race: function race(iterable){
- var C = this
- , capability = newPromiseCapability(C)
- , reject = capability.reject;
- var abrupt = perform(function(){
- forOf(iterable, false, function(promise){
- C.resolve(promise).then(capability.resolve, reject);
- });
- });
- if(abrupt)reject(abrupt.error);
- return capability.promise;
- }
- });
- /***/ },
- /* 383 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
- var $export = __webpack_require__(0)
- , aFunction = __webpack_require__(21)
- , anObject = __webpack_require__(3)
- , _apply = Function.apply;
- $export($export.S, 'Reflect', {
- apply: function apply(target, thisArgument, argumentsList){
- return _apply.call(aFunction(target), thisArgument, anObject(argumentsList));
- }
- });
- /***/ },
- /* 384 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
- var $export = __webpack_require__(0)
- , create = __webpack_require__(47)
- , aFunction = __webpack_require__(21)
- , anObject = __webpack_require__(3)
- , isObject = __webpack_require__(7)
- , bind = __webpack_require__(172);
- // MS Edge supports only 2 arguments
- // FF Nightly sets third argument as `new.target`, but does not create `this` from it
- $export($export.S + $export.F * __webpack_require__(6)(function(){
- function F(){}
- return !(Reflect.construct(function(){}, [], F) instanceof F);
- }), 'Reflect', {
- construct: function construct(Target, args /*, newTarget*/){
- aFunction(Target);
- anObject(args);
- var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
- if(Target == newTarget){
- // w/o altered newTarget, optimization for 0-4 arguments
- switch(args.length){
- case 0: return new Target;
- case 1: return new Target(args[0]);
- case 2: return new Target(args[0], args[1]);
- case 3: return new Target(args[0], args[1], args[2]);
- case 4: return new Target(args[0], args[1], args[2], args[3]);
- }
- // w/o altered newTarget, lot of arguments case
- var $args = [null];
- $args.push.apply($args, args);
- return new (bind.apply(Target, $args));
- }
- // with altered newTarget, not support built-in constructors
- var proto = newTarget.prototype
- , instance = create(isObject(proto) ? proto : Object.prototype)
- , result = Function.apply.call(Target, instance, args);
- return isObject(result) ? result : instance;
- }
- });
- /***/ },
- /* 385 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
- var dP = __webpack_require__(11)
- , $export = __webpack_require__(0)
- , anObject = __webpack_require__(3)
- , toPrimitive = __webpack_require__(34);
- // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
- $export($export.S + $export.F * __webpack_require__(6)(function(){
- Reflect.defineProperty(dP.f({}, 1, {value: 1}), 1, {value: 2});
- }), 'Reflect', {
- defineProperty: function defineProperty(target, propertyKey, attributes){
- anObject(target);
- propertyKey = toPrimitive(propertyKey, true);
- anObject(attributes);
- try {
- dP.f(target, propertyKey, attributes);
- return true;
- } catch(e){
- return false;
- }
- }
- });
- /***/ },
- /* 386 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.4 Reflect.deleteProperty(target, propertyKey)
- var $export = __webpack_require__(0)
- , gOPD = __webpack_require__(25).f
- , anObject = __webpack_require__(3);
- $export($export.S, 'Reflect', {
- deleteProperty: function deleteProperty(target, propertyKey){
- var desc = gOPD(anObject(target), propertyKey);
- return desc && !desc.configurable ? false : delete target[propertyKey];
- }
- });
- /***/ },
- /* 387 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 26.1.5 Reflect.enumerate(target)
- var $export = __webpack_require__(0)
- , anObject = __webpack_require__(3);
- var Enumerate = function(iterated){
- this._t = anObject(iterated); // target
- this._i = 0; // next index
- var keys = this._k = [] // keys
- , key;
- for(key in iterated)keys.push(key);
- };
- __webpack_require__(114)(Enumerate, 'Object', function(){
- var that = this
- , keys = that._k
- , key;
- do {
- if(that._i >= keys.length)return {value: undefined, done: true};
- } while(!((key = keys[that._i++]) in that._t));
- return {value: key, done: false};
- });
- $export($export.S, 'Reflect', {
- enumerate: function enumerate(target){
- return new Enumerate(target);
- }
- });
- /***/ },
- /* 388 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
- var gOPD = __webpack_require__(25)
- , $export = __webpack_require__(0)
- , anObject = __webpack_require__(3);
- $export($export.S, 'Reflect', {
- getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey){
- return gOPD.f(anObject(target), propertyKey);
- }
- });
- /***/ },
- /* 389 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.8 Reflect.getPrototypeOf(target)
- var $export = __webpack_require__(0)
- , getProto = __webpack_require__(26)
- , anObject = __webpack_require__(3);
- $export($export.S, 'Reflect', {
- getPrototypeOf: function getPrototypeOf(target){
- return getProto(anObject(target));
- }
- });
- /***/ },
- /* 390 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.6 Reflect.get(target, propertyKey [, receiver])
- var gOPD = __webpack_require__(25)
- , getPrototypeOf = __webpack_require__(26)
- , has = __webpack_require__(17)
- , $export = __webpack_require__(0)
- , isObject = __webpack_require__(7)
- , anObject = __webpack_require__(3);
- function get(target, propertyKey/*, receiver*/){
- var receiver = arguments.length < 3 ? target : arguments[2]
- , desc, proto;
- if(anObject(target) === receiver)return target[propertyKey];
- if(desc = gOPD.f(target, propertyKey))return has(desc, 'value')
- ? desc.value
- : desc.get !== undefined
- ? desc.get.call(receiver)
- : undefined;
- if(isObject(proto = getPrototypeOf(target)))return get(proto, propertyKey, receiver);
- }
- $export($export.S, 'Reflect', {get: get});
- /***/ },
- /* 391 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.9 Reflect.has(target, propertyKey)
- var $export = __webpack_require__(0);
- $export($export.S, 'Reflect', {
- has: function has(target, propertyKey){
- return propertyKey in target;
- }
- });
- /***/ },
- /* 392 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.10 Reflect.isExtensible(target)
- var $export = __webpack_require__(0)
- , anObject = __webpack_require__(3)
- , $isExtensible = Object.isExtensible;
- $export($export.S, 'Reflect', {
- isExtensible: function isExtensible(target){
- anObject(target);
- return $isExtensible ? $isExtensible(target) : true;
- }
- });
- /***/ },
- /* 393 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.11 Reflect.ownKeys(target)
- var $export = __webpack_require__(0);
- $export($export.S, 'Reflect', {ownKeys: __webpack_require__(185)});
- /***/ },
- /* 394 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.12 Reflect.preventExtensions(target)
- var $export = __webpack_require__(0)
- , anObject = __webpack_require__(3)
- , $preventExtensions = Object.preventExtensions;
- $export($export.S, 'Reflect', {
- preventExtensions: function preventExtensions(target){
- anObject(target);
- try {
- if($preventExtensions)$preventExtensions(target);
- return true;
- } catch(e){
- return false;
- }
- }
- });
- /***/ },
- /* 395 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.14 Reflect.setPrototypeOf(target, proto)
- var $export = __webpack_require__(0)
- , setProto = __webpack_require__(91);
- if(setProto)$export($export.S, 'Reflect', {
- setPrototypeOf: function setPrototypeOf(target, proto){
- setProto.check(target, proto);
- try {
- setProto.set(target, proto);
- return true;
- } catch(e){
- return false;
- }
- }
- });
- /***/ },
- /* 396 */
- /***/ function(module, exports, __webpack_require__) {
- // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
- var dP = __webpack_require__(11)
- , gOPD = __webpack_require__(25)
- , getPrototypeOf = __webpack_require__(26)
- , has = __webpack_require__(17)
- , $export = __webpack_require__(0)
- , createDesc = __webpack_require__(41)
- , anObject = __webpack_require__(3)
- , isObject = __webpack_require__(7);
- function set(target, propertyKey, V/*, receiver*/){
- var receiver = arguments.length < 4 ? target : arguments[3]
- , ownDesc = gOPD.f(anObject(target), propertyKey)
- , existingDescriptor, proto;
- if(!ownDesc){
- if(isObject(proto = getPrototypeOf(target))){
- return set(proto, propertyKey, V, receiver);
- }
- ownDesc = createDesc(0);
- }
- if(has(ownDesc, 'value')){
- if(ownDesc.writable === false || !isObject(receiver))return false;
- existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
- existingDescriptor.value = V;
- dP.f(receiver, propertyKey, existingDescriptor);
- return true;
- }
- return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
- }
- $export($export.S, 'Reflect', {set: set});
- /***/ },
- /* 397 */
- /***/ function(module, exports, __webpack_require__) {
- var global = __webpack_require__(5)
- , inheritIfRequired = __webpack_require__(110)
- , dP = __webpack_require__(11).f
- , gOPN = __webpack_require__(48).f
- , isRegExp = __webpack_require__(87)
- , $flags = __webpack_require__(85)
- , $RegExp = global.RegExp
- , Base = $RegExp
- , proto = $RegExp.prototype
- , re1 = /a/g
- , re2 = /a/g
- // "new" creates a new object, old webkit buggy here
- , CORRECT_NEW = new $RegExp(re1) !== re1;
- if(__webpack_require__(10) && (!CORRECT_NEW || __webpack_require__(6)(function(){
- re2[__webpack_require__(8)('match')] = false;
- // RegExp constructor can alter flags and IsRegExp works correct with @@match
- return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';
- }))){
- $RegExp = function RegExp(p, f){
- var tiRE = this instanceof $RegExp
- , piRE = isRegExp(p)
- , fiU = f === undefined;
- return !tiRE && piRE && p.constructor === $RegExp && fiU ? p
- : inheritIfRequired(CORRECT_NEW
- ? new Base(piRE && !fiU ? p.source : p, f)
- : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)
- , tiRE ? this : proto, $RegExp);
- };
- var proxy = function(key){
- key in $RegExp || dP($RegExp, key, {
- configurable: true,
- get: function(){ return Base[key]; },
- set: function(it){ Base[key] = it; }
- });
- };
- for(var keys = gOPN(Base), i = 0; keys.length > i; )proxy(keys[i++]);
- proto.constructor = $RegExp;
- $RegExp.prototype = proto;
- __webpack_require__(22)(global, 'RegExp', $RegExp);
- }
- __webpack_require__(51)('RegExp');
- /***/ },
- /* 398 */
- /***/ function(module, exports, __webpack_require__) {
- // @@match logic
- __webpack_require__(84)('match', 1, function(defined, MATCH, $match){
- // 21.1.3.11 String.prototype.match(regexp)
- return [function match(regexp){
- 'use strict';
- var O = defined(this)
- , fn = regexp == undefined ? undefined : regexp[MATCH];
- return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
- }, $match];
- });
- /***/ },
- /* 399 */
- /***/ function(module, exports, __webpack_require__) {
- // @@replace logic
- __webpack_require__(84)('replace', 2, function(defined, REPLACE, $replace){
- // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
- return [function replace(searchValue, replaceValue){
- 'use strict';
- var O = defined(this)
- , fn = searchValue == undefined ? undefined : searchValue[REPLACE];
- return fn !== undefined
- ? fn.call(searchValue, O, replaceValue)
- : $replace.call(String(O), searchValue, replaceValue);
- }, $replace];
- });
- /***/ },
- /* 400 */
- /***/ function(module, exports, __webpack_require__) {
- // @@search logic
- __webpack_require__(84)('search', 1, function(defined, SEARCH, $search){
- // 21.1.3.15 String.prototype.search(regexp)
- return [function search(regexp){
- 'use strict';
- var O = defined(this)
- , fn = regexp == undefined ? undefined : regexp[SEARCH];
- return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
- }, $search];
- });
- /***/ },
- /* 401 */
- /***/ function(module, exports, __webpack_require__) {
- // @@split logic
- __webpack_require__(84)('split', 2, function(defined, SPLIT, $split){
- 'use strict';
- var isRegExp = __webpack_require__(87)
- , _split = $split
- , $push = [].push
- , $SPLIT = 'split'
- , LENGTH = 'length'
- , LAST_INDEX = 'lastIndex';
- if(
- 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
- 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
- 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
- '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
- '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
- ''[$SPLIT](/.?/)[LENGTH]
- ){
- var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
- // based on es5-shim implementation, need to rework it
- $split = function(separator, limit){
- var string = String(this);
- if(separator === undefined && limit === 0)return [];
- // If `separator` is not a regex, use native split
- if(!isRegExp(separator))return _split.call(string, separator, limit);
- var output = [];
- var flags = (separator.ignoreCase ? 'i' : '') +
- (separator.multiline ? 'm' : '') +
- (separator.unicode ? 'u' : '') +
- (separator.sticky ? 'y' : '');
- var lastLastIndex = 0;
- var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
- // Make `global` and avoid `lastIndex` issues by working with a copy
- var separatorCopy = new RegExp(separator.source, flags + 'g');
- var separator2, match, lastIndex, lastLength, i;
- // Doesn't need flags gy, but they don't hurt
- if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
- while(match = separatorCopy.exec(string)){
- // `separatorCopy.lastIndex` is not reliable cross-browser
- lastIndex = match.index + match[0][LENGTH];
- if(lastIndex > lastLastIndex){
- output.push(string.slice(lastLastIndex, match.index));
- // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
- if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
- for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
- });
- if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
- lastLength = match[0][LENGTH];
- lastLastIndex = lastIndex;
- if(output[LENGTH] >= splitLimit)break;
- }
- if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
- }
- if(lastLastIndex === string[LENGTH]){
- if(lastLength || !separatorCopy.test(''))output.push('');
- } else output.push(string.slice(lastLastIndex));
- return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
- };
- // Chakra, V8
- } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
- $split = function(separator, limit){
- return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
- };
- }
- // 21.1.3.17 String.prototype.split(separator, limit)
- return [function split(separator, limit){
- var O = defined(this)
- , fn = separator == undefined ? undefined : separator[SPLIT];
- return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
- }, $split];
- });
- /***/ },
- /* 402 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- __webpack_require__(192);
- var anObject = __webpack_require__(3)
- , $flags = __webpack_require__(85)
- , DESCRIPTORS = __webpack_require__(10)
- , TO_STRING = 'toString'
- , $toString = /./[TO_STRING];
- var define = function(fn){
- __webpack_require__(22)(RegExp.prototype, TO_STRING, fn, true);
- };
- // 21.2.5.14 RegExp.prototype.toString()
- if(__webpack_require__(6)(function(){ return $toString.call({source: 'a', flags: 'b'}) != '/a/b'; })){
- define(function toString(){
- var R = anObject(this);
- return '/'.concat(R.source, '/',
- 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);
- });
- // FF44- RegExp#toString has a wrong name
- } else if($toString.name != TO_STRING){
- define(function toString(){
- return $toString.call(this);
- });
- }
- /***/ },
- /* 403 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.2 String.prototype.anchor(name)
- __webpack_require__(23)('anchor', function(createHTML){
- return function anchor(name){
- return createHTML(this, 'a', 'name', name);
- }
- });
- /***/ },
- /* 404 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.3 String.prototype.big()
- __webpack_require__(23)('big', function(createHTML){
- return function big(){
- return createHTML(this, 'big', '', '');
- }
- });
- /***/ },
- /* 405 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.4 String.prototype.blink()
- __webpack_require__(23)('blink', function(createHTML){
- return function blink(){
- return createHTML(this, 'blink', '', '');
- }
- });
- /***/ },
- /* 406 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.5 String.prototype.bold()
- __webpack_require__(23)('bold', function(createHTML){
- return function bold(){
- return createHTML(this, 'b', '', '');
- }
- });
- /***/ },
- /* 407 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $at = __webpack_require__(121)(false);
- $export($export.P, 'String', {
- // 21.1.3.3 String.prototype.codePointAt(pos)
- codePointAt: function codePointAt(pos){
- return $at(this, pos);
- }
- });
- /***/ },
- /* 408 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
- 'use strict';
- var $export = __webpack_require__(0)
- , toLength = __webpack_require__(15)
- , context = __webpack_require__(122)
- , ENDS_WITH = 'endsWith'
- , $endsWith = ''[ENDS_WITH];
- $export($export.P + $export.F * __webpack_require__(108)(ENDS_WITH), 'String', {
- endsWith: function endsWith(searchString /*, endPosition = @length */){
- var that = context(this, searchString, ENDS_WITH)
- , endPosition = arguments.length > 1 ? arguments[1] : undefined
- , len = toLength(that.length)
- , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
- , search = String(searchString);
- return $endsWith
- ? $endsWith.call(that, search, end)
- : that.slice(end - search.length, end) === search;
- }
- });
- /***/ },
- /* 409 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.6 String.prototype.fixed()
- __webpack_require__(23)('fixed', function(createHTML){
- return function fixed(){
- return createHTML(this, 'tt', '', '');
- }
- });
- /***/ },
- /* 410 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.7 String.prototype.fontcolor(color)
- __webpack_require__(23)('fontcolor', function(createHTML){
- return function fontcolor(color){
- return createHTML(this, 'font', 'color', color);
- }
- });
- /***/ },
- /* 411 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.8 String.prototype.fontsize(size)
- __webpack_require__(23)('fontsize', function(createHTML){
- return function fontsize(size){
- return createHTML(this, 'font', 'size', size);
- }
- });
- /***/ },
- /* 412 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , toIndex = __webpack_require__(52)
- , fromCharCode = String.fromCharCode
- , $fromCodePoint = String.fromCodePoint;
- // length should be 1, old FF problem
- $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
- // 21.1.2.2 String.fromCodePoint(...codePoints)
- fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
- var res = []
- , aLen = arguments.length
- , i = 0
- , code;
- while(aLen > i){
- code = +arguments[i++];
- if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
- res.push(code < 0x10000
- ? fromCharCode(code)
- : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
- );
- } return res.join('');
- }
- });
- /***/ },
- /* 413 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.7 String.prototype.includes(searchString, position = 0)
- 'use strict';
- var $export = __webpack_require__(0)
- , context = __webpack_require__(122)
- , INCLUDES = 'includes';
- $export($export.P + $export.F * __webpack_require__(108)(INCLUDES), 'String', {
- includes: function includes(searchString /*, position = 0 */){
- return !!~context(this, searchString, INCLUDES)
- .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- /***/ },
- /* 414 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.9 String.prototype.italics()
- __webpack_require__(23)('italics', function(createHTML){
- return function italics(){
- return createHTML(this, 'i', '', '');
- }
- });
- /***/ },
- /* 415 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $at = __webpack_require__(121)(true);
- // 21.1.3.27 String.prototype[@@iterator]()
- __webpack_require__(115)(String, 'String', function(iterated){
- this._t = String(iterated); // target
- this._i = 0; // next index
- // 21.1.5.2.1 %StringIteratorPrototype%.next()
- }, function(){
- var O = this._t
- , index = this._i
- , point;
- if(index >= O.length)return {value: undefined, done: true};
- point = $at(O, index);
- this._i += point.length;
- return {value: point, done: false};
- });
- /***/ },
- /* 416 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.10 String.prototype.link(url)
- __webpack_require__(23)('link', function(createHTML){
- return function link(url){
- return createHTML(this, 'a', 'href', url);
- }
- });
- /***/ },
- /* 417 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , toIObject = __webpack_require__(24)
- , toLength = __webpack_require__(15);
- $export($export.S, 'String', {
- // 21.1.2.4 String.raw(callSite, ...substitutions)
- raw: function raw(callSite){
- var tpl = toIObject(callSite.raw)
- , len = toLength(tpl.length)
- , aLen = arguments.length
- , res = []
- , i = 0;
- while(len > i){
- res.push(String(tpl[i++]));
- if(i < aLen)res.push(String(arguments[i]));
- } return res.join('');
- }
- });
- /***/ },
- /* 418 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0);
- $export($export.P, 'String', {
- // 21.1.3.13 String.prototype.repeat(count)
- repeat: __webpack_require__(123)
- });
- /***/ },
- /* 419 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.11 String.prototype.small()
- __webpack_require__(23)('small', function(createHTML){
- return function small(){
- return createHTML(this, 'small', '', '');
- }
- });
- /***/ },
- /* 420 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
- 'use strict';
- var $export = __webpack_require__(0)
- , toLength = __webpack_require__(15)
- , context = __webpack_require__(122)
- , STARTS_WITH = 'startsWith'
- , $startsWith = ''[STARTS_WITH];
- $export($export.P + $export.F * __webpack_require__(108)(STARTS_WITH), 'String', {
- startsWith: function startsWith(searchString /*, position = 0 */){
- var that = context(this, searchString, STARTS_WITH)
- , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
- , search = String(searchString);
- return $startsWith
- ? $startsWith.call(that, search, index)
- : that.slice(index, index + search.length) === search;
- }
- });
- /***/ },
- /* 421 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.12 String.prototype.strike()
- __webpack_require__(23)('strike', function(createHTML){
- return function strike(){
- return createHTML(this, 'strike', '', '');
- }
- });
- /***/ },
- /* 422 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.13 String.prototype.sub()
- __webpack_require__(23)('sub', function(createHTML){
- return function sub(){
- return createHTML(this, 'sub', '', '');
- }
- });
- /***/ },
- /* 423 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // B.2.3.14 String.prototype.sup()
- __webpack_require__(23)('sup', function(createHTML){
- return function sup(){
- return createHTML(this, 'sup', '', '');
- }
- });
- /***/ },
- /* 424 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // 21.1.3.25 String.prototype.trim()
- __webpack_require__(62)('trim', function($trim){
- return function trim(){
- return $trim(this, 3);
- };
- });
- /***/ },
- /* 425 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // ECMAScript 6 symbols shim
- var global = __webpack_require__(5)
- , has = __webpack_require__(17)
- , DESCRIPTORS = __webpack_require__(10)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(22)
- , META = __webpack_require__(40).KEY
- , $fails = __webpack_require__(6)
- , shared = __webpack_require__(92)
- , setToStringTag = __webpack_require__(61)
- , uid = __webpack_require__(53)
- , wks = __webpack_require__(8)
- , wksExt = __webpack_require__(190)
- , wksDefine = __webpack_require__(127)
- , keyOf = __webpack_require__(300)
- , enumKeys = __webpack_require__(299)
- , isArray = __webpack_require__(112)
- , anObject = __webpack_require__(3)
- , toIObject = __webpack_require__(24)
- , toPrimitive = __webpack_require__(34)
- , createDesc = __webpack_require__(41)
- , _create = __webpack_require__(47)
- , gOPNExt = __webpack_require__(182)
- , $GOPD = __webpack_require__(25)
- , $DP = __webpack_require__(11)
- , $keys = __webpack_require__(49)
- , gOPD = $GOPD.f
- , dP = $DP.f
- , gOPN = gOPNExt.f
- , $Symbol = global.Symbol
- , $JSON = global.JSON
- , _stringify = $JSON && $JSON.stringify
- , PROTOTYPE = 'prototype'
- , HIDDEN = wks('_hidden')
- , TO_PRIMITIVE = wks('toPrimitive')
- , isEnum = {}.propertyIsEnumerable
- , SymbolRegistry = shared('symbol-registry')
- , AllSymbols = shared('symbols')
- , OPSymbols = shared('op-symbols')
- , ObjectProto = Object[PROTOTYPE]
- , USE_NATIVE = typeof $Symbol == 'function'
- , QObject = global.QObject;
- // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
- var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
- // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
- var setSymbolDesc = DESCRIPTORS && $fails(function(){
- return _create(dP({}, 'a', {
- get: function(){ return dP(this, 'a', {value: 7}).a; }
- })).a != 7;
- }) ? function(it, key, D){
- var protoDesc = gOPD(ObjectProto, key);
- if(protoDesc)delete ObjectProto[key];
- dP(it, key, D);
- if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
- } : dP;
- var wrap = function(tag){
- var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
- sym._k = tag;
- return sym;
- };
- var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
- return typeof it == 'symbol';
- } : function(it){
- return it instanceof $Symbol;
- };
- var $defineProperty = function defineProperty(it, key, D){
- if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
- anObject(it);
- key = toPrimitive(key, true);
- anObject(D);
- if(has(AllSymbols, key)){
- if(!D.enumerable){
- if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
- it[HIDDEN][key] = true;
- } else {
- if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
- D = _create(D, {enumerable: createDesc(0, false)});
- } return setSymbolDesc(it, key, D);
- } return dP(it, key, D);
- };
- var $defineProperties = function defineProperties(it, P){
- anObject(it);
- var keys = enumKeys(P = toIObject(P))
- , i = 0
- , l = keys.length
- , key;
- while(l > i)$defineProperty(it, key = keys[i++], P[key]);
- return it;
- };
- var $create = function create(it, P){
- return P === undefined ? _create(it) : $defineProperties(_create(it), P);
- };
- var $propertyIsEnumerable = function propertyIsEnumerable(key){
- var E = isEnum.call(this, key = toPrimitive(key, true));
- if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
- return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
- };
- var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
- it = toIObject(it);
- key = toPrimitive(key, true);
- if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
- var D = gOPD(it, key);
- if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
- return D;
- };
- var $getOwnPropertyNames = function getOwnPropertyNames(it){
- var names = gOPN(toIObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i){
- if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
- } return result;
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
- var IS_OP = it === ObjectProto
- , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i){
- if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
- } return result;
- };
- // 19.4.1.1 Symbol([description])
- if(!USE_NATIVE){
- $Symbol = function Symbol(){
- if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
- var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
- var $set = function(value){
- if(this === ObjectProto)$set.call(OPSymbols, value);
- if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
- setSymbolDesc(this, tag, createDesc(1, value));
- };
- if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
- return wrap(tag);
- };
- redefine($Symbol[PROTOTYPE], 'toString', function toString(){
- return this._k;
- });
- $GOPD.f = $getOwnPropertyDescriptor;
- $DP.f = $defineProperty;
- __webpack_require__(48).f = gOPNExt.f = $getOwnPropertyNames;
- __webpack_require__(71).f = $propertyIsEnumerable;
- __webpack_require__(90).f = $getOwnPropertySymbols;
- if(DESCRIPTORS && !__webpack_require__(46)){
- redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
- }
- wksExt.f = function(name){
- return wrap(wks(name));
- }
- }
- $export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
- for(var symbols = (
- // 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
- 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
- ).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
- for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
- $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
- // 19.4.2.1 Symbol.for(key)
- 'for': function(key){
- return has(SymbolRegistry, key += '')
- ? SymbolRegistry[key]
- : SymbolRegistry[key] = $Symbol(key);
- },
- // 19.4.2.5 Symbol.keyFor(sym)
- keyFor: function keyFor(key){
- if(isSymbol(key))return keyOf(SymbolRegistry, key);
- throw TypeError(key + ' is not a symbol!');
- },
- useSetter: function(){ setter = true; },
- useSimple: function(){ setter = false; }
- });
- $export($export.S + $export.F * !USE_NATIVE, 'Object', {
- // 19.1.2.2 Object.create(O [, Properties])
- create: $create,
- // 19.1.2.4 Object.defineProperty(O, P, Attributes)
- defineProperty: $defineProperty,
- // 19.1.2.3 Object.defineProperties(O, Properties)
- defineProperties: $defineProperties,
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- getOwnPropertyNames: $getOwnPropertyNames,
- // 19.1.2.8 Object.getOwnPropertySymbols(O)
- getOwnPropertySymbols: $getOwnPropertySymbols
- });
- // 24.3.2 JSON.stringify(value [, replacer [, space]])
- $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
- var S = $Symbol();
- // MS Edge converts symbol values to JSON as {}
- // WebKit converts symbol values to JSON as null
- // V8 throws on boxed symbols
- return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
- })), 'JSON', {
- stringify: function stringify(it){
- if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
- var args = [it]
- , i = 1
- , replacer, $replacer;
- while(arguments.length > i)args.push(arguments[i++]);
- replacer = args[1];
- if(typeof replacer == 'function')$replacer = replacer;
- if($replacer || !isArray(replacer))replacer = function(key, value){
- if($replacer)value = $replacer.call(this, key, value);
- if(!isSymbol(value))return value;
- };
- args[1] = replacer;
- return _stringify.apply($JSON, args);
- }
- });
- // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
- $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(19)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
- // 19.4.3.5 Symbol.prototype[@@toStringTag]
- setToStringTag($Symbol, 'Symbol');
- // 20.2.1.9 Math[@@toStringTag]
- setToStringTag(Math, 'Math', true);
- // 24.3.3 JSON[@@toStringTag]
- setToStringTag(global.JSON, 'JSON', true);
- /***/ },
- /* 426 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , $typed = __webpack_require__(93)
- , buffer = __webpack_require__(126)
- , anObject = __webpack_require__(3)
- , toIndex = __webpack_require__(52)
- , toLength = __webpack_require__(15)
- , isObject = __webpack_require__(7)
- , TYPED_ARRAY = __webpack_require__(8)('typed_array')
- , ArrayBuffer = __webpack_require__(5).ArrayBuffer
- , speciesConstructor = __webpack_require__(120)
- , $ArrayBuffer = buffer.ArrayBuffer
- , $DataView = buffer.DataView
- , $isView = $typed.ABV && ArrayBuffer.isView
- , $slice = $ArrayBuffer.prototype.slice
- , VIEW = $typed.VIEW
- , ARRAY_BUFFER = 'ArrayBuffer';
- $export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), {ArrayBuffer: $ArrayBuffer});
- $export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {
- // 24.1.3.1 ArrayBuffer.isView(arg)
- isView: function isView(it){
- return $isView && $isView(it) || isObject(it) && VIEW in it;
- }
- });
- $export($export.P + $export.U + $export.F * __webpack_require__(6)(function(){
- return !new $ArrayBuffer(2).slice(1, undefined).byteLength;
- }), ARRAY_BUFFER, {
- // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)
- slice: function slice(start, end){
- if($slice !== undefined && end === undefined)return $slice.call(anObject(this), start); // FF fix
- var len = anObject(this).byteLength
- , first = toIndex(start, len)
- , final = toIndex(end === undefined ? len : end, len)
- , result = new (speciesConstructor(this, $ArrayBuffer))(toLength(final - first))
- , viewS = new $DataView(this)
- , viewT = new $DataView(result)
- , index = 0;
- while(first < final){
- viewT.setUint8(index++, viewS.getUint8(first++));
- } return result;
- }
- });
- __webpack_require__(51)(ARRAY_BUFFER);
- /***/ },
- /* 427 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0);
- $export($export.G + $export.W + $export.F * !__webpack_require__(93).ABV, {
- DataView: __webpack_require__(126).DataView
- });
- /***/ },
- /* 428 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Float32', 4, function(init){
- return function Float32Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 429 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Float64', 8, function(init){
- return function Float64Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 430 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Int16', 2, function(init){
- return function Int16Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 431 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Int32', 4, function(init){
- return function Int32Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 432 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Int8', 1, function(init){
- return function Int8Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 433 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Uint16', 2, function(init){
- return function Uint16Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 434 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Uint32', 4, function(init){
- return function Uint32Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 435 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Uint8', 1, function(init){
- return function Uint8Array(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- });
- /***/ },
- /* 436 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(37)('Uint8', 1, function(init){
- return function Uint8ClampedArray(data, byteOffset, length){
- return init(this, data, byteOffset, length);
- };
- }, true);
- /***/ },
- /* 437 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var weak = __webpack_require__(175);
- // 23.4 WeakSet Objects
- __webpack_require__(83)('WeakSet', function(get){
- return function WeakSet(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.4.3.1 WeakSet.prototype.add(value)
- add: function add(value){
- return weak.def(this, value, true);
- }
- }, weak, false, true);
- /***/ },
- /* 438 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/tc39/Array.prototype.includes
- var $export = __webpack_require__(0)
- , $includes = __webpack_require__(82)(true);
- $export($export.P, 'Array', {
- includes: function includes(el /*, fromIndex = 0 */){
- return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(58)('includes');
- /***/ },
- /* 439 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask
- var $export = __webpack_require__(0)
- , microtask = __webpack_require__(118)()
- , process = __webpack_require__(5).process
- , isNode = __webpack_require__(27)(process) == 'process';
- $export($export.G, {
- asap: function asap(fn){
- var domain = isNode && process.domain;
- microtask(domain ? domain.bind(fn) : fn);
- }
- });
- /***/ },
- /* 440 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/ljharb/proposal-is-error
- var $export = __webpack_require__(0)
- , cof = __webpack_require__(27);
- $export($export.S, 'Error', {
- isError: function isError(it){
- return cof(it) === 'Error';
- }
- });
- /***/ },
- /* 441 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- var $export = __webpack_require__(0);
- $export($export.P + $export.R, 'Map', {toJSON: __webpack_require__(174)('Map')});
- /***/ },
- /* 442 */
- /***/ function(module, exports, __webpack_require__) {
- // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- iaddh: function iaddh(x0, x1, y0, y1){
- var $x0 = x0 >>> 0
- , $x1 = x1 >>> 0
- , $y0 = y0 >>> 0;
- return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;
- }
- });
- /***/ },
- /* 443 */
- /***/ function(module, exports, __webpack_require__) {
- // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- imulh: function imulh(u, v){
- var UINT16 = 0xffff
- , $u = +u
- , $v = +v
- , u0 = $u & UINT16
- , v0 = $v & UINT16
- , u1 = $u >> 16
- , v1 = $v >> 16
- , t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
- return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);
- }
- });
- /***/ },
- /* 444 */
- /***/ function(module, exports, __webpack_require__) {
- // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- isubh: function isubh(x0, x1, y0, y1){
- var $x0 = x0 >>> 0
- , $x1 = x1 >>> 0
- , $y0 = y0 >>> 0;
- return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;
- }
- });
- /***/ },
- /* 445 */
- /***/ function(module, exports, __webpack_require__) {
- // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
- var $export = __webpack_require__(0);
- $export($export.S, 'Math', {
- umulh: function umulh(u, v){
- var UINT16 = 0xffff
- , $u = +u
- , $v = +v
- , u0 = $u & UINT16
- , v0 = $v & UINT16
- , u1 = $u >>> 16
- , v1 = $v >>> 16
- , t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
- return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
- }
- });
- /***/ },
- /* 446 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , aFunction = __webpack_require__(21)
- , $defineProperty = __webpack_require__(11);
- // B.2.2.2 Object.prototype.__defineGetter__(P, getter)
- __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
- __defineGetter__: function __defineGetter__(P, getter){
- $defineProperty.f(toObject(this), P, {get: aFunction(getter), enumerable: true, configurable: true});
- }
- });
- /***/ },
- /* 447 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , aFunction = __webpack_require__(21)
- , $defineProperty = __webpack_require__(11);
- // B.2.2.3 Object.prototype.__defineSetter__(P, setter)
- __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
- __defineSetter__: function __defineSetter__(P, setter){
- $defineProperty.f(toObject(this), P, {set: aFunction(setter), enumerable: true, configurable: true});
- }
- });
- /***/ },
- /* 448 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-values-entries
- var $export = __webpack_require__(0)
- , $entries = __webpack_require__(184)(true);
- $export($export.S, 'Object', {
- entries: function entries(it){
- return $entries(it);
- }
- });
- /***/ },
- /* 449 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-getownpropertydescriptors
- var $export = __webpack_require__(0)
- , ownKeys = __webpack_require__(185)
- , toIObject = __webpack_require__(24)
- , gOPD = __webpack_require__(25)
- , createProperty = __webpack_require__(105);
- $export($export.S, 'Object', {
- getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
- var O = toIObject(object)
- , getDesc = gOPD.f
- , keys = ownKeys(O)
- , result = {}
- , i = 0
- , key, D;
- while(keys.length > i)createProperty(result, key = keys[i++], getDesc(O, key));
- return result;
- }
- });
- /***/ },
- /* 450 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , toPrimitive = __webpack_require__(34)
- , getPrototypeOf = __webpack_require__(26)
- , getOwnPropertyDescriptor = __webpack_require__(25).f;
- // B.2.2.4 Object.prototype.__lookupGetter__(P)
- __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
- __lookupGetter__: function __lookupGetter__(P){
- var O = toObject(this)
- , K = toPrimitive(P, true)
- , D;
- do {
- if(D = getOwnPropertyDescriptor(O, K))return D.get;
- } while(O = getPrototypeOf(O));
- }
- });
- /***/ },
- /* 451 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var $export = __webpack_require__(0)
- , toObject = __webpack_require__(16)
- , toPrimitive = __webpack_require__(34)
- , getPrototypeOf = __webpack_require__(26)
- , getOwnPropertyDescriptor = __webpack_require__(25).f;
- // B.2.2.5 Object.prototype.__lookupSetter__(P)
- __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
- __lookupSetter__: function __lookupSetter__(P){
- var O = toObject(this)
- , K = toPrimitive(P, true)
- , D;
- do {
- if(D = getOwnPropertyDescriptor(O, K))return D.set;
- } while(O = getPrototypeOf(O));
- }
- });
- /***/ },
- /* 452 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-values-entries
- var $export = __webpack_require__(0)
- , $values = __webpack_require__(184)(false);
- $export($export.S, 'Object', {
- values: function values(it){
- return $values(it);
- }
- });
- /***/ },
- /* 453 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/zenparsing/es-observable
- var $export = __webpack_require__(0)
- , global = __webpack_require__(5)
- , core = __webpack_require__(32)
- , microtask = __webpack_require__(118)()
- , OBSERVABLE = __webpack_require__(8)('observable')
- , aFunction = __webpack_require__(21)
- , anObject = __webpack_require__(3)
- , anInstance = __webpack_require__(39)
- , redefineAll = __webpack_require__(50)
- , hide = __webpack_require__(19)
- , forOf = __webpack_require__(60)
- , RETURN = forOf.RETURN;
- var getMethod = function(fn){
- return fn == null ? undefined : aFunction(fn);
- };
- var cleanupSubscription = function(subscription){
- var cleanup = subscription._c;
- if(cleanup){
- subscription._c = undefined;
- cleanup();
- }
- };
- var subscriptionClosed = function(subscription){
- return subscription._o === undefined;
- };
- var closeSubscription = function(subscription){
- if(!subscriptionClosed(subscription)){
- subscription._o = undefined;
- cleanupSubscription(subscription);
- }
- };
- var Subscription = function(observer, subscriber){
- anObject(observer);
- this._c = undefined;
- this._o = observer;
- observer = new SubscriptionObserver(this);
- try {
- var cleanup = subscriber(observer)
- , subscription = cleanup;
- if(cleanup != null){
- if(typeof cleanup.unsubscribe === 'function')cleanup = function(){ subscription.unsubscribe(); };
- else aFunction(cleanup);
- this._c = cleanup;
- }
- } catch(e){
- observer.error(e);
- return;
- } if(subscriptionClosed(this))cleanupSubscription(this);
- };
- Subscription.prototype = redefineAll({}, {
- unsubscribe: function unsubscribe(){ closeSubscription(this); }
- });
- var SubscriptionObserver = function(subscription){
- this._s = subscription;
- };
- SubscriptionObserver.prototype = redefineAll({}, {
- next: function next(value){
- var subscription = this._s;
- if(!subscriptionClosed(subscription)){
- var observer = subscription._o;
- try {
- var m = getMethod(observer.next);
- if(m)return m.call(observer, value);
- } catch(e){
- try {
- closeSubscription(subscription);
- } finally {
- throw e;
- }
- }
- }
- },
- error: function error(value){
- var subscription = this._s;
- if(subscriptionClosed(subscription))throw value;
- var observer = subscription._o;
- subscription._o = undefined;
- try {
- var m = getMethod(observer.error);
- if(!m)throw value;
- value = m.call(observer, value);
- } catch(e){
- try {
- cleanupSubscription(subscription);
- } finally {
- throw e;
- }
- } cleanupSubscription(subscription);
- return value;
- },
- complete: function complete(value){
- var subscription = this._s;
- if(!subscriptionClosed(subscription)){
- var observer = subscription._o;
- subscription._o = undefined;
- try {
- var m = getMethod(observer.complete);
- value = m ? m.call(observer, value) : undefined;
- } catch(e){
- try {
- cleanupSubscription(subscription);
- } finally {
- throw e;
- }
- } cleanupSubscription(subscription);
- return value;
- }
- }
- });
- var $Observable = function Observable(subscriber){
- anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber);
- };
- redefineAll($Observable.prototype, {
- subscribe: function subscribe(observer){
- return new Subscription(observer, this._f);
- },
- forEach: function forEach(fn){
- var that = this;
- return new (core.Promise || global.Promise)(function(resolve, reject){
- aFunction(fn);
- var subscription = that.subscribe({
- next : function(value){
- try {
- return fn(value);
- } catch(e){
- reject(e);
- subscription.unsubscribe();
- }
- },
- error: reject,
- complete: resolve
- });
- });
- }
- });
- redefineAll($Observable, {
- from: function from(x){
- var C = typeof this === 'function' ? this : $Observable;
- var method = getMethod(anObject(x)[OBSERVABLE]);
- if(method){
- var observable = anObject(method.call(x));
- return observable.constructor === C ? observable : new C(function(observer){
- return observable.subscribe(observer);
- });
- }
- return new C(function(observer){
- var done = false;
- microtask(function(){
- if(!done){
- try {
- if(forOf(x, false, function(it){
- observer.next(it);
- if(done)return RETURN;
- }) === RETURN)return;
- } catch(e){
- if(done)throw e;
- observer.error(e);
- return;
- } observer.complete();
- }
- });
- return function(){ done = true; };
- });
- },
- of: function of(){
- for(var i = 0, l = arguments.length, items = Array(l); i < l;)items[i] = arguments[i++];
- return new (typeof this === 'function' ? this : $Observable)(function(observer){
- var done = false;
- microtask(function(){
- if(!done){
- for(var i = 0; i < items.length; ++i){
- observer.next(items[i]);
- if(done)return;
- } observer.complete();
- }
- });
- return function(){ done = true; };
- });
- }
- });
- hide($Observable.prototype, OBSERVABLE, function(){ return this; });
- $export($export.G, {Observable: $Observable});
- __webpack_require__(51)('Observable');
- /***/ },
- /* 454 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , toMetaKey = metadata.key
- , ordinaryDefineOwnMetadata = metadata.set;
- metadata.exp({defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey){
- ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey));
- }});
- /***/ },
- /* 455 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , toMetaKey = metadata.key
- , getOrCreateMetadataMap = metadata.map
- , store = metadata.store;
- metadata.exp({deleteMetadata: function deleteMetadata(metadataKey, target /*, targetKey */){
- var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2])
- , metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
- if(metadataMap === undefined || !metadataMap['delete'](metadataKey))return false;
- if(metadataMap.size)return true;
- var targetMetadata = store.get(target);
- targetMetadata['delete'](targetKey);
- return !!targetMetadata.size || store['delete'](target);
- }});
- /***/ },
- /* 456 */
- /***/ function(module, exports, __webpack_require__) {
- var Set = __webpack_require__(193)
- , from = __webpack_require__(170)
- , metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , getPrototypeOf = __webpack_require__(26)
- , ordinaryOwnMetadataKeys = metadata.keys
- , toMetaKey = metadata.key;
- var ordinaryMetadataKeys = function(O, P){
- var oKeys = ordinaryOwnMetadataKeys(O, P)
- , parent = getPrototypeOf(O);
- if(parent === null)return oKeys;
- var pKeys = ordinaryMetadataKeys(parent, P);
- return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
- };
- metadata.exp({getMetadataKeys: function getMetadataKeys(target /*, targetKey */){
- return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
- }});
- /***/ },
- /* 457 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , getPrototypeOf = __webpack_require__(26)
- , ordinaryHasOwnMetadata = metadata.has
- , ordinaryGetOwnMetadata = metadata.get
- , toMetaKey = metadata.key;
- var ordinaryGetMetadata = function(MetadataKey, O, P){
- var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
- if(hasOwn)return ordinaryGetOwnMetadata(MetadataKey, O, P);
- var parent = getPrototypeOf(O);
- return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
- };
- metadata.exp({getMetadata: function getMetadata(metadataKey, target /*, targetKey */){
- return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
- }});
- /***/ },
- /* 458 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , ordinaryOwnMetadataKeys = metadata.keys
- , toMetaKey = metadata.key;
- metadata.exp({getOwnMetadataKeys: function getOwnMetadataKeys(target /*, targetKey */){
- return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
- }});
- /***/ },
- /* 459 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , ordinaryGetOwnMetadata = metadata.get
- , toMetaKey = metadata.key;
- metadata.exp({getOwnMetadata: function getOwnMetadata(metadataKey, target /*, targetKey */){
- return ordinaryGetOwnMetadata(metadataKey, anObject(target)
- , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
- }});
- /***/ },
- /* 460 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , getPrototypeOf = __webpack_require__(26)
- , ordinaryHasOwnMetadata = metadata.has
- , toMetaKey = metadata.key;
- var ordinaryHasMetadata = function(MetadataKey, O, P){
- var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
- if(hasOwn)return true;
- var parent = getPrototypeOf(O);
- return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;
- };
- metadata.exp({hasMetadata: function hasMetadata(metadataKey, target /*, targetKey */){
- return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
- }});
- /***/ },
- /* 461 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , ordinaryHasOwnMetadata = metadata.has
- , toMetaKey = metadata.key;
- metadata.exp({hasOwnMetadata: function hasOwnMetadata(metadataKey, target /*, targetKey */){
- return ordinaryHasOwnMetadata(metadataKey, anObject(target)
- , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
- }});
- /***/ },
- /* 462 */
- /***/ function(module, exports, __webpack_require__) {
- var metadata = __webpack_require__(36)
- , anObject = __webpack_require__(3)
- , aFunction = __webpack_require__(21)
- , toMetaKey = metadata.key
- , ordinaryDefineOwnMetadata = metadata.set;
- metadata.exp({metadata: function metadata(metadataKey, metadataValue){
- return function decorator(target, targetKey){
- ordinaryDefineOwnMetadata(
- metadataKey, metadataValue,
- (targetKey !== undefined ? anObject : aFunction)(target),
- toMetaKey(targetKey)
- );
- };
- }});
- /***/ },
- /* 463 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/DavidBruant/Map-Set.prototype.toJSON
- var $export = __webpack_require__(0);
- $export($export.P + $export.R, 'Set', {toJSON: __webpack_require__(174)('Set')});
- /***/ },
- /* 464 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/mathiasbynens/String.prototype.at
- var $export = __webpack_require__(0)
- , $at = __webpack_require__(121)(true);
- $export($export.P, 'String', {
- at: function at(pos){
- return $at(this, pos);
- }
- });
- /***/ },
- /* 465 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://tc39.github.io/String.prototype.matchAll/
- var $export = __webpack_require__(0)
- , defined = __webpack_require__(28)
- , toLength = __webpack_require__(15)
- , isRegExp = __webpack_require__(87)
- , getFlags = __webpack_require__(85)
- , RegExpProto = RegExp.prototype;
- var $RegExpStringIterator = function(regexp, string){
- this._r = regexp;
- this._s = string;
- };
- __webpack_require__(114)($RegExpStringIterator, 'RegExp String', function next(){
- var match = this._r.exec(this._s);
- return {value: match, done: match === null};
- });
- $export($export.P, 'String', {
- matchAll: function matchAll(regexp){
- defined(this);
- if(!isRegExp(regexp))throw TypeError(regexp + ' is not a regexp!');
- var S = String(this)
- , flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp)
- , rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags);
- rx.lastIndex = toLength(regexp.lastIndex);
- return new $RegExpStringIterator(rx, S);
- }
- });
- /***/ },
- /* 466 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/tc39/proposal-string-pad-start-end
- var $export = __webpack_require__(0)
- , $pad = __webpack_require__(189);
- $export($export.P, 'String', {
- padEnd: function padEnd(maxLength /*, fillString = ' ' */){
- return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
- }
- });
- /***/ },
- /* 467 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/tc39/proposal-string-pad-start-end
- var $export = __webpack_require__(0)
- , $pad = __webpack_require__(189);
- $export($export.P, 'String', {
- padStart: function padStart(maxLength /*, fillString = ' ' */){
- return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
- }
- });
- /***/ },
- /* 468 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
- __webpack_require__(62)('trimLeft', function($trim){
- return function trimLeft(){
- return $trim(this, 1);
- };
- }, 'trimStart');
- /***/ },
- /* 469 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
- __webpack_require__(62)('trimRight', function($trim){
- return function trimRight(){
- return $trim(this, 2);
- };
- }, 'trimEnd');
- /***/ },
- /* 470 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(127)('asyncIterator');
- /***/ },
- /* 471 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(127)('observable');
- /***/ },
- /* 472 */
- /***/ function(module, exports, __webpack_require__) {
- // https://github.com/ljharb/proposal-global
- var $export = __webpack_require__(0);
- $export($export.S, 'System', {global: __webpack_require__(5)});
- /***/ },
- /* 473 */
- /***/ function(module, exports, __webpack_require__) {
- var $iterators = __webpack_require__(129)
- , redefine = __webpack_require__(22)
- , global = __webpack_require__(5)
- , hide = __webpack_require__(19)
- , Iterators = __webpack_require__(45)
- , wks = __webpack_require__(8)
- , ITERATOR = wks('iterator')
- , TO_STRING_TAG = wks('toStringTag')
- , ArrayValues = Iterators.Array;
- for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
- var NAME = collections[i]
- , Collection = global[NAME]
- , proto = Collection && Collection.prototype
- , key;
- if(proto){
- if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
- if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
- Iterators[NAME] = ArrayValues;
- for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
- }
- }
- /***/ },
- /* 474 */
- /***/ function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $task = __webpack_require__(125);
- $export($export.G + $export.B, {
- setImmediate: $task.set,
- clearImmediate: $task.clear
- });
- /***/ },
- /* 475 */
- /***/ function(module, exports, __webpack_require__) {
- // ie9- setTimeout & setInterval additional parameters fix
- var global = __webpack_require__(5)
- , $export = __webpack_require__(0)
- , invoke = __webpack_require__(86)
- , partial = __webpack_require__(301)
- , navigator = global.navigator
- , MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
- var wrap = function(set){
- return MSIE ? function(fn, time /*, ...args */){
- return set(invoke(
- partial,
- [].slice.call(arguments, 2),
- typeof fn == 'function' ? fn : Function(fn)
- ), time);
- } : set;
- };
- $export($export.G + $export.B + $export.F * MSIE, {
- setTimeout: wrap(global.setTimeout),
- setInterval: wrap(global.setInterval)
- });
- /***/ },
- /* 476 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(425);
- __webpack_require__(364);
- __webpack_require__(366);
- __webpack_require__(365);
- __webpack_require__(368);
- __webpack_require__(370);
- __webpack_require__(375);
- __webpack_require__(369);
- __webpack_require__(367);
- __webpack_require__(377);
- __webpack_require__(376);
- __webpack_require__(372);
- __webpack_require__(373);
- __webpack_require__(371);
- __webpack_require__(363);
- __webpack_require__(374);
- __webpack_require__(378);
- __webpack_require__(379);
- __webpack_require__(331);
- __webpack_require__(333);
- __webpack_require__(332);
- __webpack_require__(381);
- __webpack_require__(380);
- __webpack_require__(351);
- __webpack_require__(361);
- __webpack_require__(362);
- __webpack_require__(352);
- __webpack_require__(353);
- __webpack_require__(354);
- __webpack_require__(355);
- __webpack_require__(356);
- __webpack_require__(357);
- __webpack_require__(358);
- __webpack_require__(359);
- __webpack_require__(360);
- __webpack_require__(334);
- __webpack_require__(335);
- __webpack_require__(336);
- __webpack_require__(337);
- __webpack_require__(338);
- __webpack_require__(339);
- __webpack_require__(340);
- __webpack_require__(341);
- __webpack_require__(342);
- __webpack_require__(343);
- __webpack_require__(344);
- __webpack_require__(345);
- __webpack_require__(346);
- __webpack_require__(347);
- __webpack_require__(348);
- __webpack_require__(349);
- __webpack_require__(350);
- __webpack_require__(412);
- __webpack_require__(417);
- __webpack_require__(424);
- __webpack_require__(415);
- __webpack_require__(407);
- __webpack_require__(408);
- __webpack_require__(413);
- __webpack_require__(418);
- __webpack_require__(420);
- __webpack_require__(403);
- __webpack_require__(404);
- __webpack_require__(405);
- __webpack_require__(406);
- __webpack_require__(409);
- __webpack_require__(410);
- __webpack_require__(411);
- __webpack_require__(414);
- __webpack_require__(416);
- __webpack_require__(419);
- __webpack_require__(421);
- __webpack_require__(422);
- __webpack_require__(423);
- __webpack_require__(326);
- __webpack_require__(328);
- __webpack_require__(327);
- __webpack_require__(330);
- __webpack_require__(329);
- __webpack_require__(315);
- __webpack_require__(313);
- __webpack_require__(319);
- __webpack_require__(316);
- __webpack_require__(322);
- __webpack_require__(324);
- __webpack_require__(312);
- __webpack_require__(318);
- __webpack_require__(309);
- __webpack_require__(323);
- __webpack_require__(307);
- __webpack_require__(321);
- __webpack_require__(320);
- __webpack_require__(314);
- __webpack_require__(317);
- __webpack_require__(306);
- __webpack_require__(308);
- __webpack_require__(311);
- __webpack_require__(310);
- __webpack_require__(325);
- __webpack_require__(129);
- __webpack_require__(397);
- __webpack_require__(402);
- __webpack_require__(192);
- __webpack_require__(398);
- __webpack_require__(399);
- __webpack_require__(400);
- __webpack_require__(401);
- __webpack_require__(382);
- __webpack_require__(191);
- __webpack_require__(193);
- __webpack_require__(194);
- __webpack_require__(437);
- __webpack_require__(426);
- __webpack_require__(427);
- __webpack_require__(432);
- __webpack_require__(435);
- __webpack_require__(436);
- __webpack_require__(430);
- __webpack_require__(433);
- __webpack_require__(431);
- __webpack_require__(434);
- __webpack_require__(428);
- __webpack_require__(429);
- __webpack_require__(383);
- __webpack_require__(384);
- __webpack_require__(385);
- __webpack_require__(386);
- __webpack_require__(387);
- __webpack_require__(390);
- __webpack_require__(388);
- __webpack_require__(389);
- __webpack_require__(391);
- __webpack_require__(392);
- __webpack_require__(393);
- __webpack_require__(394);
- __webpack_require__(396);
- __webpack_require__(395);
- __webpack_require__(438);
- __webpack_require__(464);
- __webpack_require__(467);
- __webpack_require__(466);
- __webpack_require__(468);
- __webpack_require__(469);
- __webpack_require__(465);
- __webpack_require__(470);
- __webpack_require__(471);
- __webpack_require__(449);
- __webpack_require__(452);
- __webpack_require__(448);
- __webpack_require__(446);
- __webpack_require__(447);
- __webpack_require__(450);
- __webpack_require__(451);
- __webpack_require__(441);
- __webpack_require__(463);
- __webpack_require__(472);
- __webpack_require__(440);
- __webpack_require__(442);
- __webpack_require__(444);
- __webpack_require__(443);
- __webpack_require__(445);
- __webpack_require__(454);
- __webpack_require__(455);
- __webpack_require__(457);
- __webpack_require__(456);
- __webpack_require__(459);
- __webpack_require__(458);
- __webpack_require__(460);
- __webpack_require__(461);
- __webpack_require__(462);
- __webpack_require__(439);
- __webpack_require__(453);
- __webpack_require__(475);
- __webpack_require__(474);
- __webpack_require__(473);
- module.exports = __webpack_require__(32);
- /***/ },
- /* 477 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var elliptic = __webpack_require__(20);
- var BN = __webpack_require__(12);
- module.exports = function createECDH(curve) {
- return new ECDH(curve);
- };
- var aliases = {
- secp256k1: {
- name: 'secp256k1',
- byteLength: 32
- },
- secp224r1: {
- name: 'p224',
- byteLength: 28
- },
- prime256v1: {
- name: 'p256',
- byteLength: 32
- },
- prime192v1: {
- name: 'p192',
- byteLength: 24
- },
- ed25519: {
- name: 'ed25519',
- byteLength: 32
- },
- secp384r1: {
- name: 'p384',
- byteLength: 48
- },
- secp521r1: {
- name: 'p521',
- byteLength: 66
- }
- };
- aliases.p224 = aliases.secp224r1;
- aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
- aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
- aliases.p384 = aliases.secp384r1;
- aliases.p521 = aliases.secp521r1;
- function ECDH(curve) {
- this.curveType = aliases[curve];
- if (!this.curveType ) {
- this.curveType = {
- name: curve
- };
- }
- this.curve = new elliptic.ec(this.curveType.name);
- this.keys = void 0;
- }
- ECDH.prototype.generateKeys = function (enc, format) {
- this.keys = this.curve.genKeyPair();
- return this.getPublicKey(enc, format);
- };
- ECDH.prototype.computeSecret = function (other, inenc, enc) {
- inenc = inenc || 'utf8';
- if (!Buffer.isBuffer(other)) {
- other = new Buffer(other, inenc);
- }
- var otherPub = this.curve.keyFromPublic(other).getPublic();
- var out = otherPub.mul(this.keys.getPrivate()).getX();
- return formatReturnValue(out, enc, this.curveType.byteLength);
- };
- ECDH.prototype.getPublicKey = function (enc, format) {
- var key = this.keys.getPublic(format === 'compressed', true);
- if (format === 'hybrid') {
- if (key[key.length - 1] % 2) {
- key[0] = 7;
- } else {
- key [0] = 6;
- }
- }
- return formatReturnValue(key, enc);
- };
- ECDH.prototype.getPrivateKey = function (enc) {
- return formatReturnValue(this.keys.getPrivate(), enc);
- };
- ECDH.prototype.setPublicKey = function (pub, enc) {
- enc = enc || 'utf8';
- if (!Buffer.isBuffer(pub)) {
- pub = new Buffer(pub, enc);
- }
- this.keys._importPublic(pub);
- return this;
- };
- ECDH.prototype.setPrivateKey = function (priv, enc) {
- enc = enc || 'utf8';
- if (!Buffer.isBuffer(priv)) {
- priv = new Buffer(priv, enc);
- }
- var _priv = new BN(priv);
- _priv = _priv.toString(16);
- this.keys._importPrivate(_priv);
- return this;
- };
- function formatReturnValue(bn, enc, len) {
- if (!Array.isArray(bn)) {
- bn = bn.toArray();
- }
- var buf = new Buffer(bn);
- if (len && buf.length < len) {
- var zeros = new Buffer(len - buf.length);
- zeros.fill(0);
- buf = Buffer.concat([zeros, buf]);
- }
- if (!enc) {
- return buf;
- } else {
- return buf.toString(enc);
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 478 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var intSize = 4;
- var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
- var chrsz = 8;
- function toArray(buf, bigEndian) {
- if ((buf.length % intSize) !== 0) {
- var len = buf.length + (intSize - (buf.length % intSize));
- buf = Buffer.concat([buf, zeroBuffer], len);
- }
- var arr = [];
- var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
- for (var i = 0; i < buf.length; i += intSize) {
- arr.push(fn.call(buf, i));
- }
- return arr;
- }
- function toBuffer(arr, size, bigEndian) {
- var buf = new Buffer(size);
- var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
- for (var i = 0; i < arr.length; i++) {
- fn.call(buf, arr[i], i * 4, true);
- }
- return buf;
- }
- function hash(buf, fn, hashSize, bigEndian) {
- if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
- var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
- return toBuffer(arr, hashSize, bigEndian);
- }
- exports.hash = hash;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 479 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var assert = __webpack_require__(72);
- var inherits = __webpack_require__(2);
- var proto = {};
- function CBCState(iv) {
- assert.equal(iv.length, 8, 'Invalid IV length');
- this.iv = new Array(8);
- for (var i = 0; i < this.iv.length; i++)
- this.iv[i] = iv[i];
- }
- function instantiate(Base) {
- function CBC(options) {
- Base.call(this, options);
- this._cbcInit();
- }
- inherits(CBC, Base);
- var keys = Object.keys(proto);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- CBC.prototype[key] = proto[key];
- }
- CBC.create = function create(options) {
- return new CBC(options);
- };
- return CBC;
- }
- exports.instantiate = instantiate;
- proto._cbcInit = function _cbcInit() {
- var state = new CBCState(this.options.iv);
- this._cbcState = state;
- };
- proto._update = function _update(inp, inOff, out, outOff) {
- var state = this._cbcState;
- var superProto = this.constructor.super_.prototype;
- var iv = state.iv;
- if (this.type === 'encrypt') {
- for (var i = 0; i < this.blockSize; i++)
- iv[i] ^= inp[inOff + i];
- superProto._update.call(this, iv, 0, out, outOff);
- for (var i = 0; i < this.blockSize; i++)
- iv[i] = out[outOff + i];
- } else {
- superProto._update.call(this, inp, inOff, out, outOff);
- for (var i = 0; i < this.blockSize; i++)
- out[outOff + i] ^= iv[i];
- for (var i = 0; i < this.blockSize; i++)
- iv[i] = inp[inOff + i];
- }
- };
- /***/ },
- /* 480 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var assert = __webpack_require__(72);
- function Cipher(options) {
- this.options = options;
- this.type = this.options.type;
- this.blockSize = 8;
- this._init();
- this.buffer = new Array(this.blockSize);
- this.bufferOff = 0;
- }
- module.exports = Cipher;
- Cipher.prototype._init = function _init() {
- // Might be overrided
- };
- Cipher.prototype.update = function update(data) {
- if (data.length === 0)
- return [];
- if (this.type === 'decrypt')
- return this._updateDecrypt(data);
- else
- return this._updateEncrypt(data);
- };
- Cipher.prototype._buffer = function _buffer(data, off) {
- // Append data to buffer
- var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
- for (var i = 0; i < min; i++)
- this.buffer[this.bufferOff + i] = data[off + i];
- this.bufferOff += min;
- // Shift next
- return min;
- };
- Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
- this._update(this.buffer, 0, out, off);
- this.bufferOff = 0;
- return this.blockSize;
- };
- Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
- var inputOff = 0;
- var outputOff = 0;
- var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
- var out = new Array(count * this.blockSize);
- if (this.bufferOff !== 0) {
- inputOff += this._buffer(data, inputOff);
- if (this.bufferOff === this.buffer.length)
- outputOff += this._flushBuffer(out, outputOff);
- }
- // Write blocks
- var max = data.length - ((data.length - inputOff) % this.blockSize);
- for (; inputOff < max; inputOff += this.blockSize) {
- this._update(data, inputOff, out, outputOff);
- outputOff += this.blockSize;
- }
- // Queue rest
- for (; inputOff < data.length; inputOff++, this.bufferOff++)
- this.buffer[this.bufferOff] = data[inputOff];
- return out;
- };
- Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
- var inputOff = 0;
- var outputOff = 0;
- var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
- var out = new Array(count * this.blockSize);
- // TODO(indutny): optimize it, this is far from optimal
- for (; count > 0; count--) {
- inputOff += this._buffer(data, inputOff);
- outputOff += this._flushBuffer(out, outputOff);
- }
- // Buffer rest of the input
- inputOff += this._buffer(data, inputOff);
- return out;
- };
- Cipher.prototype.final = function final(buffer) {
- var first;
- if (buffer)
- first = this.update(buffer);
- var last;
- if (this.type === 'encrypt')
- last = this._finalEncrypt();
- else
- last = this._finalDecrypt();
- if (first)
- return first.concat(last);
- else
- return last;
- };
- Cipher.prototype._pad = function _pad(buffer, off) {
- if (off === 0)
- return false;
- while (off < buffer.length)
- buffer[off++] = 0;
- return true;
- };
- Cipher.prototype._finalEncrypt = function _finalEncrypt() {
- if (!this._pad(this.buffer, this.bufferOff))
- return [];
- var out = new Array(this.blockSize);
- this._update(this.buffer, 0, out, 0);
- return out;
- };
- Cipher.prototype._unpad = function _unpad(buffer) {
- return buffer;
- };
- Cipher.prototype._finalDecrypt = function _finalDecrypt() {
- assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
- var out = new Array(this.blockSize);
- this._flushBuffer(out, 0);
- return this._unpad(out);
- };
- /***/ },
- /* 481 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var assert = __webpack_require__(72);
- var inherits = __webpack_require__(2);
- var des = __webpack_require__(132);
- var utils = des.utils;
- var Cipher = des.Cipher;
- function DESState() {
- this.tmp = new Array(2);
- this.keys = null;
- }
- function DES(options) {
- Cipher.call(this, options);
- var state = new DESState();
- this._desState = state;
- this.deriveKeys(state, options.key);
- }
- inherits(DES, Cipher);
- module.exports = DES;
- DES.create = function create(options) {
- return new DES(options);
- };
- var shiftTable = [
- 1, 1, 2, 2, 2, 2, 2, 2,
- 1, 2, 2, 2, 2, 2, 2, 1
- ];
- DES.prototype.deriveKeys = function deriveKeys(state, key) {
- state.keys = new Array(16 * 2);
- assert.equal(key.length, this.blockSize, 'Invalid key length');
- var kL = utils.readUInt32BE(key, 0);
- var kR = utils.readUInt32BE(key, 4);
- utils.pc1(kL, kR, state.tmp, 0);
- kL = state.tmp[0];
- kR = state.tmp[1];
- for (var i = 0; i < state.keys.length; i += 2) {
- var shift = shiftTable[i >>> 1];
- kL = utils.r28shl(kL, shift);
- kR = utils.r28shl(kR, shift);
- utils.pc2(kL, kR, state.keys, i);
- }
- };
- DES.prototype._update = function _update(inp, inOff, out, outOff) {
- var state = this._desState;
- var l = utils.readUInt32BE(inp, inOff);
- var r = utils.readUInt32BE(inp, inOff + 4);
- // Initial Permutation
- utils.ip(l, r, state.tmp, 0);
- l = state.tmp[0];
- r = state.tmp[1];
- if (this.type === 'encrypt')
- this._encrypt(state, l, r, state.tmp, 0);
- else
- this._decrypt(state, l, r, state.tmp, 0);
- l = state.tmp[0];
- r = state.tmp[1];
- utils.writeUInt32BE(out, l, outOff);
- utils.writeUInt32BE(out, r, outOff + 4);
- };
- DES.prototype._pad = function _pad(buffer, off) {
- var value = buffer.length - off;
- for (var i = off; i < buffer.length; i++)
- buffer[i] = value;
- return true;
- };
- DES.prototype._unpad = function _unpad(buffer) {
- var pad = buffer[buffer.length - 1];
- for (var i = buffer.length - pad; i < buffer.length; i++)
- assert.equal(buffer[i], pad);
- return buffer.slice(0, buffer.length - pad);
- };
- DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
- var l = lStart;
- var r = rStart;
- // Apply f() x16 times
- for (var i = 0; i < state.keys.length; i += 2) {
- var keyL = state.keys[i];
- var keyR = state.keys[i + 1];
- // f(r, k)
- utils.expand(r, state.tmp, 0);
- keyL ^= state.tmp[0];
- keyR ^= state.tmp[1];
- var s = utils.substitute(keyL, keyR);
- var f = utils.permute(s);
- var t = r;
- r = (l ^ f) >>> 0;
- l = t;
- }
- // Reverse Initial Permutation
- utils.rip(r, l, out, off);
- };
- DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
- var l = rStart;
- var r = lStart;
- // Apply f() x16 times
- for (var i = state.keys.length - 2; i >= 0; i -= 2) {
- var keyL = state.keys[i];
- var keyR = state.keys[i + 1];
- // f(r, k)
- utils.expand(l, state.tmp, 0);
- keyL ^= state.tmp[0];
- keyR ^= state.tmp[1];
- var s = utils.substitute(keyL, keyR);
- var f = utils.permute(s);
- var t = l;
- l = (r ^ f) >>> 0;
- r = t;
- }
- // Reverse Initial Permutation
- utils.rip(l, r, out, off);
- };
- /***/ },
- /* 482 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var assert = __webpack_require__(72);
- var inherits = __webpack_require__(2);
- var des = __webpack_require__(132);
- var Cipher = des.Cipher;
- var DES = des.DES;
- function EDEState(type, key) {
- assert.equal(key.length, 24, 'Invalid key length');
- var k1 = key.slice(0, 8);
- var k2 = key.slice(8, 16);
- var k3 = key.slice(16, 24);
- if (type === 'encrypt') {
- this.ciphers = [
- DES.create({ type: 'encrypt', key: k1 }),
- DES.create({ type: 'decrypt', key: k2 }),
- DES.create({ type: 'encrypt', key: k3 })
- ];
- } else {
- this.ciphers = [
- DES.create({ type: 'decrypt', key: k3 }),
- DES.create({ type: 'encrypt', key: k2 }),
- DES.create({ type: 'decrypt', key: k1 })
- ];
- }
- }
- function EDE(options) {
- Cipher.call(this, options);
- var state = new EDEState(this.type, this.options.key);
- this._edeState = state;
- }
- inherits(EDE, Cipher);
- module.exports = EDE;
- EDE.create = function create(options) {
- return new EDE(options);
- };
- EDE.prototype._update = function _update(inp, inOff, out, outOff) {
- var state = this._edeState;
- state.ciphers[0]._update(inp, inOff, out, outOff);
- state.ciphers[1]._update(out, outOff, out, outOff);
- state.ciphers[2]._update(out, outOff, out, outOff);
- };
- EDE.prototype._pad = DES.prototype._pad;
- EDE.prototype._unpad = DES.prototype._unpad;
- /***/ },
- /* 483 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- exports.readUInt32BE = function readUInt32BE(bytes, off) {
- var res = (bytes[0 + off] << 24) |
- (bytes[1 + off] << 16) |
- (bytes[2 + off] << 8) |
- bytes[3 + off];
- return res >>> 0;
- };
- exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
- bytes[0 + off] = value >>> 24;
- bytes[1 + off] = (value >>> 16) & 0xff;
- bytes[2 + off] = (value >>> 8) & 0xff;
- bytes[3 + off] = value & 0xff;
- };
- exports.ip = function ip(inL, inR, out, off) {
- var outL = 0;
- var outR = 0;
- for (var i = 6; i >= 0; i -= 2) {
- for (var j = 0; j <= 24; j += 8) {
- outL <<= 1;
- outL |= (inR >>> (j + i)) & 1;
- }
- for (var j = 0; j <= 24; j += 8) {
- outL <<= 1;
- outL |= (inL >>> (j + i)) & 1;
- }
- }
- for (var i = 6; i >= 0; i -= 2) {
- for (var j = 1; j <= 25; j += 8) {
- outR <<= 1;
- outR |= (inR >>> (j + i)) & 1;
- }
- for (var j = 1; j <= 25; j += 8) {
- outR <<= 1;
- outR |= (inL >>> (j + i)) & 1;
- }
- }
- out[off + 0] = outL >>> 0;
- out[off + 1] = outR >>> 0;
- };
- exports.rip = function rip(inL, inR, out, off) {
- var outL = 0;
- var outR = 0;
- for (var i = 0; i < 4; i++) {
- for (var j = 24; j >= 0; j -= 8) {
- outL <<= 1;
- outL |= (inR >>> (j + i)) & 1;
- outL <<= 1;
- outL |= (inL >>> (j + i)) & 1;
- }
- }
- for (var i = 4; i < 8; i++) {
- for (var j = 24; j >= 0; j -= 8) {
- outR <<= 1;
- outR |= (inR >>> (j + i)) & 1;
- outR <<= 1;
- outR |= (inL >>> (j + i)) & 1;
- }
- }
- out[off + 0] = outL >>> 0;
- out[off + 1] = outR >>> 0;
- };
- exports.pc1 = function pc1(inL, inR, out, off) {
- var outL = 0;
- var outR = 0;
- // 7, 15, 23, 31, 39, 47, 55, 63
- // 6, 14, 22, 30, 39, 47, 55, 63
- // 5, 13, 21, 29, 39, 47, 55, 63
- // 4, 12, 20, 28
- for (var i = 7; i >= 5; i--) {
- for (var j = 0; j <= 24; j += 8) {
- outL <<= 1;
- outL |= (inR >> (j + i)) & 1;
- }
- for (var j = 0; j <= 24; j += 8) {
- outL <<= 1;
- outL |= (inL >> (j + i)) & 1;
- }
- }
- for (var j = 0; j <= 24; j += 8) {
- outL <<= 1;
- outL |= (inR >> (j + i)) & 1;
- }
- // 1, 9, 17, 25, 33, 41, 49, 57
- // 2, 10, 18, 26, 34, 42, 50, 58
- // 3, 11, 19, 27, 35, 43, 51, 59
- // 36, 44, 52, 60
- for (var i = 1; i <= 3; i++) {
- for (var j = 0; j <= 24; j += 8) {
- outR <<= 1;
- outR |= (inR >> (j + i)) & 1;
- }
- for (var j = 0; j <= 24; j += 8) {
- outR <<= 1;
- outR |= (inL >> (j + i)) & 1;
- }
- }
- for (var j = 0; j <= 24; j += 8) {
- outR <<= 1;
- outR |= (inL >> (j + i)) & 1;
- }
- out[off + 0] = outL >>> 0;
- out[off + 1] = outR >>> 0;
- };
- exports.r28shl = function r28shl(num, shift) {
- return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
- };
- var pc2table = [
- // inL => outL
- 14, 11, 17, 4, 27, 23, 25, 0,
- 13, 22, 7, 18, 5, 9, 16, 24,
- 2, 20, 12, 21, 1, 8, 15, 26,
- // inR => outR
- 15, 4, 25, 19, 9, 1, 26, 16,
- 5, 11, 23, 8, 12, 7, 17, 0,
- 22, 3, 10, 14, 6, 20, 27, 24
- ];
- exports.pc2 = function pc2(inL, inR, out, off) {
- var outL = 0;
- var outR = 0;
- var len = pc2table.length >>> 1;
- for (var i = 0; i < len; i++) {
- outL <<= 1;
- outL |= (inL >>> pc2table[i]) & 0x1;
- }
- for (var i = len; i < pc2table.length; i++) {
- outR <<= 1;
- outR |= (inR >>> pc2table[i]) & 0x1;
- }
- out[off + 0] = outL >>> 0;
- out[off + 1] = outR >>> 0;
- };
- exports.expand = function expand(r, out, off) {
- var outL = 0;
- var outR = 0;
- outL = ((r & 1) << 5) | (r >>> 27);
- for (var i = 23; i >= 15; i -= 4) {
- outL <<= 6;
- outL |= (r >>> i) & 0x3f;
- }
- for (var i = 11; i >= 3; i -= 4) {
- outR |= (r >>> i) & 0x3f;
- outR <<= 6;
- }
- outR |= ((r & 0x1f) << 1) | (r >>> 31);
- out[off + 0] = outL >>> 0;
- out[off + 1] = outR >>> 0;
- };
- var sTable = [
- 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
- 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
- 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
- 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
- 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
- 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
- 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
- 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
- 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
- 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
- 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
- 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
- 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
- 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
- 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
- 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
- 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
- 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
- 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
- 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
- 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
- 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
- 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
- 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
- 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
- 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
- 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
- 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
- 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
- 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
- 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
- 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
- ];
- exports.substitute = function substitute(inL, inR) {
- var out = 0;
- for (var i = 0; i < 4; i++) {
- var b = (inL >>> (18 - i * 6)) & 0x3f;
- var sb = sTable[i * 0x40 + b];
- out <<= 4;
- out |= sb;
- }
- for (var i = 0; i < 4; i++) {
- var b = (inR >>> (18 - i * 6)) & 0x3f;
- var sb = sTable[4 * 0x40 + i * 0x40 + b];
- out <<= 4;
- out |= sb;
- }
- return out >>> 0;
- };
- var permuteTable = [
- 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
- 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
- ];
- exports.permute = function permute(num) {
- var out = 0;
- for (var i = 0; i < permuteTable.length; i++) {
- out <<= 1;
- out |= (num >>> permuteTable[i]) & 0x1;
- }
- return out >>> 0;
- };
- exports.padSplit = function padSplit(num, size, group) {
- var str = num.toString(2);
- while (str.length < size)
- str = '0' + str;
- var out = [];
- for (var i = 0; i < size; i += group)
- out.push(str.slice(i, i + group));
- return out.join(' ');
- };
- /***/ },
- /* 484 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var generatePrime = __webpack_require__(197)
- var primes = __webpack_require__(231)
- var DH = __webpack_require__(485)
- function getDiffieHellman (mod) {
- var prime = new Buffer(primes[mod].prime, 'hex')
- var gen = new Buffer(primes[mod].gen, 'hex')
- return new DH(prime, gen)
- }
- var ENCODINGS = {
- 'binary': true, 'hex': true, 'base64': true
- }
- function createDiffieHellman (prime, enc, generator, genc) {
- if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
- return createDiffieHellman(prime, 'binary', enc, generator)
- }
- enc = enc || 'binary'
- genc = genc || 'binary'
- generator = generator || new Buffer([2])
- if (!Buffer.isBuffer(generator)) {
- generator = new Buffer(generator, genc)
- }
- if (typeof prime === 'number') {
- return new DH(generatePrime(prime, generator), generator, true)
- }
- if (!Buffer.isBuffer(prime)) {
- prime = new Buffer(prime, enc)
- }
- return new DH(prime, generator, true)
- }
- exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
- exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 485 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var BN = __webpack_require__(12);
- var MillerRabin = __webpack_require__(204);
- var millerRabin = new MillerRabin();
- var TWENTYFOUR = new BN(24);
- var ELEVEN = new BN(11);
- var TEN = new BN(10);
- var THREE = new BN(3);
- var SEVEN = new BN(7);
- var primes = __webpack_require__(197);
- var randomBytes = __webpack_require__(73);
- module.exports = DH;
- function setPublicKey(pub, enc) {
- enc = enc || 'utf8';
- if (!Buffer.isBuffer(pub)) {
- pub = new Buffer(pub, enc);
- }
- this._pub = new BN(pub);
- return this;
- }
- function setPrivateKey(priv, enc) {
- enc = enc || 'utf8';
- if (!Buffer.isBuffer(priv)) {
- priv = new Buffer(priv, enc);
- }
- this._priv = new BN(priv);
- return this;
- }
- var primeCache = {};
- function checkPrime(prime, generator) {
- var gen = generator.toString('hex');
- var hex = [gen, prime.toString(16)].join('_');
- if (hex in primeCache) {
- return primeCache[hex];
- }
- var error = 0;
- if (prime.isEven() ||
- !primes.simpleSieve ||
- !primes.fermatTest(prime) ||
- !millerRabin.test(prime)) {
- //not a prime so +1
- error += 1;
- if (gen === '02' || gen === '05') {
- // we'd be able to check the generator
- // it would fail so +8
- error += 8;
- } else {
- //we wouldn't be able to test the generator
- // so +4
- error += 4;
- }
- primeCache[hex] = error;
- return error;
- }
- if (!millerRabin.test(prime.shrn(1))) {
- //not a safe prime
- error += 2;
- }
- var rem;
- switch (gen) {
- case '02':
- if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
- // unsuidable generator
- error += 8;
- }
- break;
- case '05':
- rem = prime.mod(TEN);
- if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
- // prime mod 10 needs to equal 3 or 7
- error += 8;
- }
- break;
- default:
- error += 4;
- }
- primeCache[hex] = error;
- return error;
- }
- function DH(prime, generator, malleable) {
- this.setGenerator(generator);
- this.__prime = new BN(prime);
- this._prime = BN.mont(this.__prime);
- this._primeLen = prime.length;
- this._pub = undefined;
- this._priv = undefined;
- this._primeCode = undefined;
- if (malleable) {
- this.setPublicKey = setPublicKey;
- this.setPrivateKey = setPrivateKey;
- } else {
- this._primeCode = 8;
- }
- }
- Object.defineProperty(DH.prototype, 'verifyError', {
- enumerable: true,
- get: function () {
- if (typeof this._primeCode !== 'number') {
- this._primeCode = checkPrime(this.__prime, this.__gen);
- }
- return this._primeCode;
- }
- });
- DH.prototype.generateKeys = function () {
- if (!this._priv) {
- this._priv = new BN(randomBytes(this._primeLen));
- }
- this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
- return this.getPublicKey();
- };
- DH.prototype.computeSecret = function (other) {
- other = new BN(other);
- other = other.toRed(this._prime);
- var secret = other.redPow(this._priv).fromRed();
- var out = new Buffer(secret.toArray());
- var prime = this.getPrime();
- if (out.length < prime.length) {
- var front = new Buffer(prime.length - out.length);
- front.fill(0);
- out = Buffer.concat([front, out]);
- }
- return out;
- };
- DH.prototype.getPublicKey = function getPublicKey(enc) {
- return formatReturnValue(this._pub, enc);
- };
- DH.prototype.getPrivateKey = function getPrivateKey(enc) {
- return formatReturnValue(this._priv, enc);
- };
- DH.prototype.getPrime = function (enc) {
- return formatReturnValue(this.__prime, enc);
- };
- DH.prototype.getGenerator = function (enc) {
- return formatReturnValue(this._gen, enc);
- };
- DH.prototype.setGenerator = function (gen, enc) {
- enc = enc || 'utf8';
- if (!Buffer.isBuffer(gen)) {
- gen = new Buffer(gen, enc);
- }
- this.__gen = gen;
- this._gen = new BN(gen);
- return this;
- };
- function formatReturnValue(bn, enc) {
- var buf = new Buffer(bn.toArray());
- if (!enc) {
- return buf;
- } else {
- return buf.toString(enc);
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 486 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var BN = __webpack_require__(12);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var getNAF = utils.getNAF;
- var getJSF = utils.getJSF;
- var assert = utils.assert;
- function BaseCurve(type, conf) {
- this.type = type;
- this.p = new BN(conf.p, 16);
- // Use Montgomery, when there is no fast reduction for the prime
- this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
- // Useful for many curves
- this.zero = new BN(0).toRed(this.red);
- this.one = new BN(1).toRed(this.red);
- this.two = new BN(2).toRed(this.red);
- // Curve configuration, optional
- this.n = conf.n && new BN(conf.n, 16);
- this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
- // Temporary arrays
- this._wnafT1 = new Array(4);
- this._wnafT2 = new Array(4);
- this._wnafT3 = new Array(4);
- this._wnafT4 = new Array(4);
- // Generalized Greg Maxwell's trick
- var adjustCount = this.n && this.p.div(this.n);
- if (!adjustCount || adjustCount.cmpn(100) > 0) {
- this.redN = null;
- } else {
- this._maxwellTrick = true;
- this.redN = this.n.toRed(this.red);
- }
- }
- module.exports = BaseCurve;
- BaseCurve.prototype.point = function point() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype.validate = function validate() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
- assert(p.precomputed);
- var doubles = p._getDoubles();
- var naf = getNAF(k, 1);
- var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
- I /= 3;
- // Translate into more windowed form
- var repr = [];
- for (var j = 0; j < naf.length; j += doubles.step) {
- var nafW = 0;
- for (var k = j + doubles.step - 1; k >= j; k--)
- nafW = (nafW << 1) + naf[k];
- repr.push(nafW);
- }
- var a = this.jpoint(null, null, null);
- var b = this.jpoint(null, null, null);
- for (var i = I; i > 0; i--) {
- for (var j = 0; j < repr.length; j++) {
- var nafW = repr[j];
- if (nafW === i)
- b = b.mixedAdd(doubles.points[j]);
- else if (nafW === -i)
- b = b.mixedAdd(doubles.points[j].neg());
- }
- a = a.add(b);
- }
- return a.toP();
- };
- BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
- var w = 4;
- // Precompute window
- var nafPoints = p._getNAFPoints(w);
- w = nafPoints.wnd;
- var wnd = nafPoints.points;
- // Get NAF form
- var naf = getNAF(k, w);
- // Add `this`*(N+1) for every w-NAF index
- var acc = this.jpoint(null, null, null);
- for (var i = naf.length - 1; i >= 0; i--) {
- // Count zeroes
- for (var k = 0; i >= 0 && naf[i] === 0; i--)
- k++;
- if (i >= 0)
- k++;
- acc = acc.dblp(k);
- if (i < 0)
- break;
- var z = naf[i];
- assert(z !== 0);
- if (p.type === 'affine') {
- // J +- P
- if (z > 0)
- acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
- else
- acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
- } else {
- // J +- J
- if (z > 0)
- acc = acc.add(wnd[(z - 1) >> 1]);
- else
- acc = acc.add(wnd[(-z - 1) >> 1].neg());
- }
- }
- return p.type === 'affine' ? acc.toP() : acc;
- };
- BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
- points,
- coeffs,
- len,
- jacobianResult) {
- var wndWidth = this._wnafT1;
- var wnd = this._wnafT2;
- var naf = this._wnafT3;
- // Fill all arrays
- var max = 0;
- for (var i = 0; i < len; i++) {
- var p = points[i];
- var nafPoints = p._getNAFPoints(defW);
- wndWidth[i] = nafPoints.wnd;
- wnd[i] = nafPoints.points;
- }
- // Comb small window NAFs
- for (var i = len - 1; i >= 1; i -= 2) {
- var a = i - 1;
- var b = i;
- if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
- naf[a] = getNAF(coeffs[a], wndWidth[a]);
- naf[b] = getNAF(coeffs[b], wndWidth[b]);
- max = Math.max(naf[a].length, max);
- max = Math.max(naf[b].length, max);
- continue;
- }
- var comb = [
- points[a], /* 1 */
- null, /* 3 */
- null, /* 5 */
- points[b] /* 7 */
- ];
- // Try to avoid Projective points, if possible
- if (points[a].y.cmp(points[b].y) === 0) {
- comb[1] = points[a].add(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].add(points[b].neg());
- } else {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- }
- var index = [
- -3, /* -1 -1 */
- -1, /* -1 0 */
- -5, /* -1 1 */
- -7, /* 0 -1 */
- 0, /* 0 0 */
- 7, /* 0 1 */
- 5, /* 1 -1 */
- 1, /* 1 0 */
- 3 /* 1 1 */
- ];
- var jsf = getJSF(coeffs[a], coeffs[b]);
- max = Math.max(jsf[0].length, max);
- naf[a] = new Array(max);
- naf[b] = new Array(max);
- for (var j = 0; j < max; j++) {
- var ja = jsf[0][j] | 0;
- var jb = jsf[1][j] | 0;
- naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
- naf[b][j] = 0;
- wnd[a] = comb;
- }
- }
- var acc = this.jpoint(null, null, null);
- var tmp = this._wnafT4;
- for (var i = max; i >= 0; i--) {
- var k = 0;
- while (i >= 0) {
- var zero = true;
- for (var j = 0; j < len; j++) {
- tmp[j] = naf[j][i] | 0;
- if (tmp[j] !== 0)
- zero = false;
- }
- if (!zero)
- break;
- k++;
- i--;
- }
- if (i >= 0)
- k++;
- acc = acc.dblp(k);
- if (i < 0)
- break;
- for (var j = 0; j < len; j++) {
- var z = tmp[j];
- var p;
- if (z === 0)
- continue;
- else if (z > 0)
- p = wnd[j][(z - 1) >> 1];
- else if (z < 0)
- p = wnd[j][(-z - 1) >> 1].neg();
- if (p.type === 'affine')
- acc = acc.mixedAdd(p);
- else
- acc = acc.add(p);
- }
- }
- // Zeroify references
- for (var i = 0; i < len; i++)
- wnd[i] = null;
- if (jacobianResult)
- return acc;
- else
- return acc.toP();
- };
- function BasePoint(curve, type) {
- this.curve = curve;
- this.type = type;
- this.precomputed = null;
- }
- BaseCurve.BasePoint = BasePoint;
- BasePoint.prototype.eq = function eq(/*other*/) {
- throw new Error('Not implemented');
- };
- BasePoint.prototype.validate = function validate() {
- return this.curve.validate(this);
- };
- BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- bytes = utils.toArray(bytes, enc);
- var len = this.p.byteLength();
- // uncompressed, hybrid-odd, hybrid-even
- if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
- bytes.length - 1 === 2 * len) {
- if (bytes[0] === 0x06)
- assert(bytes[bytes.length - 1] % 2 === 0);
- else if (bytes[0] === 0x07)
- assert(bytes[bytes.length - 1] % 2 === 1);
- var res = this.point(bytes.slice(1, 1 + len),
- bytes.slice(1 + len, 1 + 2 * len));
- return res;
- } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
- bytes.length - 1 === len) {
- return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
- }
- throw new Error('Unknown point format');
- };
- BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
- return this.encode(enc, true);
- };
- BasePoint.prototype._encode = function _encode(compact) {
- var len = this.curve.p.byteLength();
- var x = this.getX().toArray('be', len);
- if (compact)
- return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
- return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
- };
- BasePoint.prototype.encode = function encode(enc, compact) {
- return utils.encode(this._encode(compact), enc);
- };
- BasePoint.prototype.precompute = function precompute(power) {
- if (this.precomputed)
- return this;
- var precomputed = {
- doubles: null,
- naf: null,
- beta: null
- };
- precomputed.naf = this._getNAFPoints(8);
- precomputed.doubles = this._getDoubles(4, power);
- precomputed.beta = this._getBeta();
- this.precomputed = precomputed;
- return this;
- };
- BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
- if (!this.precomputed)
- return false;
- var doubles = this.precomputed.doubles;
- if (!doubles)
- return false;
- return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
- };
- BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
- if (this.precomputed && this.precomputed.doubles)
- return this.precomputed.doubles;
- var doubles = [ this ];
- var acc = this;
- for (var i = 0; i < power; i += step) {
- for (var j = 0; j < step; j++)
- acc = acc.dbl();
- doubles.push(acc);
- }
- return {
- step: step,
- points: doubles
- };
- };
- BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
- if (this.precomputed && this.precomputed.naf)
- return this.precomputed.naf;
- var res = [ this ];
- var max = (1 << wnd) - 1;
- var dbl = max === 1 ? null : this.dbl();
- for (var i = 1; i < max; i++)
- res[i] = res[i - 1].add(dbl);
- return {
- wnd: wnd,
- points: res
- };
- };
- BasePoint.prototype._getBeta = function _getBeta() {
- return null;
- };
- BasePoint.prototype.dblp = function dblp(k) {
- var r = this;
- for (var i = 0; i < k; i++)
- r = r.dbl();
- return r;
- };
- /***/ },
- /* 487 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var curve = __webpack_require__(94);
- var elliptic = __webpack_require__(20);
- var BN = __webpack_require__(12);
- var inherits = __webpack_require__(2);
- var Base = curve.base;
- var assert = elliptic.utils.assert;
- function EdwardsCurve(conf) {
- // NOTE: Important as we are creating point in Base.call()
- this.twisted = (conf.a | 0) !== 1;
- this.mOneA = this.twisted && (conf.a | 0) === -1;
- this.extended = this.mOneA;
- Base.call(this, 'edwards', conf);
- this.a = new BN(conf.a, 16).umod(this.red.m);
- this.a = this.a.toRed(this.red);
- this.c = new BN(conf.c, 16).toRed(this.red);
- this.c2 = this.c.redSqr();
- this.d = new BN(conf.d, 16).toRed(this.red);
- this.dd = this.d.redAdd(this.d);
- assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
- this.oneC = (conf.c | 0) === 1;
- }
- inherits(EdwardsCurve, Base);
- module.exports = EdwardsCurve;
- EdwardsCurve.prototype._mulA = function _mulA(num) {
- if (this.mOneA)
- return num.redNeg();
- else
- return this.a.redMul(num);
- };
- EdwardsCurve.prototype._mulC = function _mulC(num) {
- if (this.oneC)
- return num;
- else
- return this.c.redMul(num);
- };
- // Just for compatibility with Short curve
- EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
- return this.point(x, y, z, t);
- };
- EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var x2 = x.redSqr();
- var rhs = this.c2.redSub(this.a.redMul(x2));
- var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
- var y2 = rhs.redMul(lhs.redInvm());
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
- y = new BN(y, 16);
- if (!y.red)
- y = y.toRed(this.red);
- // x^2 = (y^2 - 1) / (d y^2 + 1)
- var y2 = y.redSqr();
- var lhs = y2.redSub(this.one);
- var rhs = y2.redMul(this.d).redAdd(this.one);
- var x2 = lhs.redMul(rhs.redInvm());
- if (x2.cmp(this.zero) === 0) {
- if (odd)
- throw new Error('invalid point');
- else
- return this.point(this.zero, y);
- }
- var x = x2.redSqrt();
- if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- if (x.isOdd() !== odd)
- x = x.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.validate = function validate(point) {
- if (point.isInfinity())
- return true;
- // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
- point.normalize();
- var x2 = point.x.redSqr();
- var y2 = point.y.redSqr();
- var lhs = x2.redMul(this.a).redAdd(y2);
- var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
- return lhs.cmp(rhs) === 0;
- };
- function Point(curve, x, y, z, t) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && y === null && z === null) {
- this.x = this.curve.zero;
- this.y = this.curve.one;
- this.z = this.curve.one;
- this.t = this.curve.zero;
- this.zOne = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = z ? new BN(z, 16) : this.curve.one;
- this.t = t && new BN(t, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- if (this.t && !this.t.red)
- this.t = this.t.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- // Use extended coordinates
- if (this.curve.extended && !this.t) {
- this.t = this.x.redMul(this.y);
- if (!this.zOne)
- this.t = this.t.redMul(this.z.redInvm());
- }
- }
- }
- inherits(Point, Base.BasePoint);
- EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- EdwardsCurve.prototype.point = function point(x, y, z, t) {
- return new Point(this, x, y, z, t);
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1], obj[2]);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.x.cmpn(0) === 0 &&
- this.y.cmp(this.z) === 0;
- };
- Point.prototype._extDbl = function _extDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #doubling-dbl-2008-hwcd
- // 4M + 4S
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = 2 * Z1^2
- var c = this.z.redSqr();
- c = c.redIAdd(c);
- // D = a * A
- var d = this.curve._mulA(a);
- // E = (X1 + Y1)^2 - A - B
- var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
- // G = D + B
- var g = d.redAdd(b);
- // F = G - C
- var f = g.redSub(c);
- // H = D - B
- var h = d.redSub(b);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projDbl = function _projDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #doubling-dbl-2008-bbjlp
- // #doubling-dbl-2007-bl
- // and others
- // Generally 3M + 4S or 2M + 4S
- // B = (X1 + Y1)^2
- var b = this.x.redAdd(this.y).redSqr();
- // C = X1^2
- var c = this.x.redSqr();
- // D = Y1^2
- var d = this.y.redSqr();
- var nx;
- var ny;
- var nz;
- if (this.curve.twisted) {
- // E = a * C
- var e = this.curve._mulA(c);
- // F = E + D
- var f = e.redAdd(d);
- if (this.zOne) {
- // X3 = (B - C - D) * (F - 2)
- nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F^2 - 2 * F
- nz = f.redSqr().redSub(f).redSub(f);
- } else {
- // H = Z1^2
- var h = this.z.redSqr();
- // J = F - 2 * H
- var j = f.redSub(h).redISub(h);
- // X3 = (B-C-D)*J
- nx = b.redSub(c).redISub(d).redMul(j);
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F * J
- nz = f.redMul(j);
- }
- } else {
- // E = C + D
- var e = c.redAdd(d);
- // H = (c * Z1)^2
- var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
- // J = E - 2 * H
- var j = e.redSub(h).redSub(h);
- // X3 = c * (B - E) * J
- nx = this.curve._mulC(b.redISub(e)).redMul(j);
- // Y3 = c * E * (C - D)
- ny = this.curve._mulC(e).redMul(c.redISub(d));
- // Z3 = E * J
- nz = e.redMul(j);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- // Double in extended coordinates
- if (this.curve.extended)
- return this._extDbl();
- else
- return this._projDbl();
- };
- Point.prototype._extAdd = function _extAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #addition-add-2008-hwcd-3
- // 8M
- // A = (Y1 - X1) * (Y2 - X2)
- var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
- // B = (Y1 + X1) * (Y2 + X2)
- var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
- // C = T1 * k * T2
- var c = this.t.redMul(this.curve.dd).redMul(p.t);
- // D = Z1 * 2 * Z2
- var d = this.z.redMul(p.z.redAdd(p.z));
- // E = B - A
- var e = b.redSub(a);
- // F = D - C
- var f = d.redSub(c);
- // G = D + C
- var g = d.redAdd(c);
- // H = B + A
- var h = b.redAdd(a);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projAdd = function _projAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #addition-add-2008-bbjlp
- // #addition-add-2007-bl
- // 10M + 1S
- // A = Z1 * Z2
- var a = this.z.redMul(p.z);
- // B = A^2
- var b = a.redSqr();
- // C = X1 * X2
- var c = this.x.redMul(p.x);
- // D = Y1 * Y2
- var d = this.y.redMul(p.y);
- // E = d * C * D
- var e = this.curve.d.redMul(c).redMul(d);
- // F = B - E
- var f = b.redSub(e);
- // G = B + E
- var g = b.redAdd(e);
- // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
- var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
- var nx = a.redMul(f).redMul(tmp);
- var ny;
- var nz;
- if (this.curve.twisted) {
- // Y3 = A * G * (D - a * C)
- ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
- // Z3 = F * G
- nz = f.redMul(g);
- } else {
- // Y3 = A * G * (D - C)
- ny = a.redMul(g).redMul(d.redSub(c));
- // Z3 = c * F * G
- nz = this.curve._mulC(f).redMul(g);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.add = function add(p) {
- if (this.isInfinity())
- return p;
- if (p.isInfinity())
- return this;
- if (this.curve.extended)
- return this._extAdd(p);
- else
- return this._projAdd(p);
- };
- Point.prototype.mul = function mul(k) {
- if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
- };
- Point.prototype.normalize = function normalize() {
- if (this.zOne)
- return this;
- // Normalize coordinates
- var zi = this.z.redInvm();
- this.x = this.x.redMul(zi);
- this.y = this.y.redMul(zi);
- if (this.t)
- this.t = this.t.redMul(zi);
- this.z = this.curve.one;
- this.zOne = true;
- return this;
- };
- Point.prototype.neg = function neg() {
- return this.curve.point(this.x.redNeg(),
- this.y,
- this.z,
- this.t && this.t.redNeg());
- };
- Point.prototype.getX = function getX() {
- this.normalize();
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- this.normalize();
- return this.y.fromRed();
- };
- Point.prototype.eq = function eq(other) {
- return this === other ||
- this.getX().cmp(other.getX()) === 0 &&
- this.getY().cmp(other.getY()) === 0;
- };
- Point.prototype.eqXToP = function eqXToP(x) {
- var rx = x.toRed(this.curve.red).redMul(this.z);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(this.z);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- return false;
- };
- // Compatibility with BaseCurve
- Point.prototype.toP = Point.prototype.normalize;
- Point.prototype.mixedAdd = Point.prototype.add;
- /***/ },
- /* 488 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var curve = __webpack_require__(94);
- var BN = __webpack_require__(12);
- var inherits = __webpack_require__(2);
- var Base = curve.base;
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- function MontCurve(conf) {
- Base.call(this, 'mont', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.i4 = new BN(4).toRed(this.red).redInvm();
- this.two = new BN(2).toRed(this.red);
- this.a24 = this.i4.redMul(this.a.redAdd(this.two));
- }
- inherits(MontCurve, Base);
- module.exports = MontCurve;
- MontCurve.prototype.validate = function validate(point) {
- var x = point.normalize().x;
- var x2 = x.redSqr();
- var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
- var y = rhs.redSqrt();
- return y.redSqr().cmp(rhs) === 0;
- };
- function Point(curve, x, z) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && z === null) {
- this.x = this.curve.one;
- this.z = this.curve.zero;
- } else {
- this.x = new BN(x, 16);
- this.z = new BN(z, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- }
- }
- inherits(Point, Base.BasePoint);
- MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- return this.point(utils.toArray(bytes, enc), 1);
- };
- MontCurve.prototype.point = function point(x, z) {
- return new Point(this, x, z);
- };
- MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- Point.prototype.precompute = function precompute() {
- // No-op
- };
- Point.prototype._encode = function _encode() {
- return this.getX().toArray('be', this.curve.p.byteLength());
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1] || curve.one);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- Point.prototype.dbl = function dbl() {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
- // 2M + 2S + 4A
- // A = X1 + Z1
- var a = this.x.redAdd(this.z);
- // AA = A^2
- var aa = a.redSqr();
- // B = X1 - Z1
- var b = this.x.redSub(this.z);
- // BB = B^2
- var bb = b.redSqr();
- // C = AA - BB
- var c = aa.redSub(bb);
- // X3 = AA * BB
- var nx = aa.redMul(bb);
- // Z3 = C * (BB + A24 * C)
- var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
- return this.curve.point(nx, nz);
- };
- Point.prototype.add = function add() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.diffAdd = function diffAdd(p, diff) {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
- // 4M + 2S + 6A
- // A = X2 + Z2
- var a = this.x.redAdd(this.z);
- // B = X2 - Z2
- var b = this.x.redSub(this.z);
- // C = X3 + Z3
- var c = p.x.redAdd(p.z);
- // D = X3 - Z3
- var d = p.x.redSub(p.z);
- // DA = D * A
- var da = d.redMul(a);
- // CB = C * B
- var cb = c.redMul(b);
- // X5 = Z1 * (DA + CB)^2
- var nx = diff.z.redMul(da.redAdd(cb).redSqr());
- // Z5 = X1 * (DA - CB)^2
- var nz = diff.x.redMul(da.redISub(cb).redSqr());
- return this.curve.point(nx, nz);
- };
- Point.prototype.mul = function mul(k) {
- var t = k.clone();
- var a = this; // (N / 2) * Q + Q
- var b = this.curve.point(null, null); // (N / 2) * Q
- var c = this; // Q
- for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
- bits.push(t.andln(1));
- for (var i = bits.length - 1; i >= 0; i--) {
- if (bits[i] === 0) {
- // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
- a = a.diffAdd(b, c);
- // N * Q = 2 * ((N / 2) * Q + Q))
- b = b.dbl();
- } else {
- // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
- b = a.diffAdd(b, c);
- // N * Q + Q = 2 * ((N / 2) * Q + Q)
- a = a.dbl();
- }
- }
- return b;
- };
- Point.prototype.mulAdd = function mulAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.jumlAdd = function jumlAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.eq = function eq(other) {
- return this.getX().cmp(other.getX()) === 0;
- };
- Point.prototype.normalize = function normalize() {
- this.x = this.x.redMul(this.z.redInvm());
- this.z = this.curve.one;
- return this;
- };
- Point.prototype.getX = function getX() {
- // Normalize coordinates
- this.normalize();
- return this.x.fromRed();
- };
- /***/ },
- /* 489 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var curve = __webpack_require__(94);
- var elliptic = __webpack_require__(20);
- var BN = __webpack_require__(12);
- var inherits = __webpack_require__(2);
- var Base = curve.base;
- var assert = elliptic.utils.assert;
- function ShortCurve(conf) {
- Base.call(this, 'short', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.tinv = this.two.redInvm();
- this.zeroA = this.a.fromRed().cmpn(0) === 0;
- this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
- // If the curve is endomorphic, precalculate beta and lambda
- this.endo = this._getEndomorphism(conf);
- this._endoWnafT1 = new Array(4);
- this._endoWnafT2 = new Array(4);
- }
- inherits(ShortCurve, Base);
- module.exports = ShortCurve;
- ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
- // No efficient endomorphism
- if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
- return;
- // Compute beta and lambda, that lambda * P = (beta * Px; Py)
- var beta;
- var lambda;
- if (conf.beta) {
- beta = new BN(conf.beta, 16).toRed(this.red);
- } else {
- var betas = this._getEndoRoots(this.p);
- // Choose the smallest beta
- beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
- beta = beta.toRed(this.red);
- }
- if (conf.lambda) {
- lambda = new BN(conf.lambda, 16);
- } else {
- // Choose the lambda that is matching selected beta
- var lambdas = this._getEndoRoots(this.n);
- if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
- lambda = lambdas[0];
- } else {
- lambda = lambdas[1];
- assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
- }
- }
- // Get basis vectors, used for balanced length-two representation
- var basis;
- if (conf.basis) {
- basis = conf.basis.map(function(vec) {
- return {
- a: new BN(vec.a, 16),
- b: new BN(vec.b, 16)
- };
- });
- } else {
- basis = this._getEndoBasis(lambda);
- }
- return {
- beta: beta,
- lambda: lambda,
- basis: basis
- };
- };
- ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
- // Find roots of for x^2 + x + 1 in F
- // Root = (-1 +- Sqrt(-3)) / 2
- //
- var red = num === this.p ? this.red : BN.mont(num);
- var tinv = new BN(2).toRed(red).redInvm();
- var ntinv = tinv.redNeg();
- var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
- var l1 = ntinv.redAdd(s).fromRed();
- var l2 = ntinv.redSub(s).fromRed();
- return [ l1, l2 ];
- };
- ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
- // aprxSqrt >= sqrt(this.n)
- var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
- // 3.74
- // Run EGCD, until r(L + 1) < aprxSqrt
- var u = lambda;
- var v = this.n.clone();
- var x1 = new BN(1);
- var y1 = new BN(0);
- var x2 = new BN(0);
- var y2 = new BN(1);
- // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
- var a0;
- var b0;
- // First vector
- var a1;
- var b1;
- // Second vector
- var a2;
- var b2;
- var prevR;
- var i = 0;
- var r;
- var x;
- while (u.cmpn(0) !== 0) {
- var q = v.div(u);
- r = v.sub(q.mul(u));
- x = x2.sub(q.mul(x1));
- var y = y2.sub(q.mul(y1));
- if (!a1 && r.cmp(aprxSqrt) < 0) {
- a0 = prevR.neg();
- b0 = x1;
- a1 = r.neg();
- b1 = x;
- } else if (a1 && ++i === 2) {
- break;
- }
- prevR = r;
- v = u;
- u = r;
- x2 = x1;
- x1 = x;
- y2 = y1;
- y1 = y;
- }
- a2 = r.neg();
- b2 = x;
- var len1 = a1.sqr().add(b1.sqr());
- var len2 = a2.sqr().add(b2.sqr());
- if (len2.cmp(len1) >= 0) {
- a2 = a0;
- b2 = b0;
- }
- // Normalize signs
- if (a1.negative) {
- a1 = a1.neg();
- b1 = b1.neg();
- }
- if (a2.negative) {
- a2 = a2.neg();
- b2 = b2.neg();
- }
- return [
- { a: a1, b: b1 },
- { a: a2, b: b2 }
- ];
- };
- ShortCurve.prototype._endoSplit = function _endoSplit(k) {
- var basis = this.endo.basis;
- var v1 = basis[0];
- var v2 = basis[1];
- var c1 = v2.b.mul(k).divRound(this.n);
- var c2 = v1.b.neg().mul(k).divRound(this.n);
- var p1 = c1.mul(v1.a);
- var p2 = c2.mul(v2.a);
- var q1 = c1.mul(v1.b);
- var q2 = c2.mul(v2.b);
- // Calculate answer
- var k1 = k.sub(p1).sub(p2);
- var k2 = q1.add(q2).neg();
- return { k1: k1, k2: k2 };
- };
- ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- // XXX Is there any way to tell if the number is odd without converting it
- // to non-red form?
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- ShortCurve.prototype.validate = function validate(point) {
- if (point.inf)
- return true;
- var x = point.x;
- var y = point.y;
- var ax = this.a.redMul(x);
- var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
- return y.redSqr().redISub(rhs).cmpn(0) === 0;
- };
- ShortCurve.prototype._endoWnafMulAdd =
- function _endoWnafMulAdd(points, coeffs, jacobianResult) {
- var npoints = this._endoWnafT1;
- var ncoeffs = this._endoWnafT2;
- for (var i = 0; i < points.length; i++) {
- var split = this._endoSplit(coeffs[i]);
- var p = points[i];
- var beta = p._getBeta();
- if (split.k1.negative) {
- split.k1.ineg();
- p = p.neg(true);
- }
- if (split.k2.negative) {
- split.k2.ineg();
- beta = beta.neg(true);
- }
- npoints[i * 2] = p;
- npoints[i * 2 + 1] = beta;
- ncoeffs[i * 2] = split.k1;
- ncoeffs[i * 2 + 1] = split.k2;
- }
- var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
- // Clean-up references to points and coefficients
- for (var j = 0; j < i * 2; j++) {
- npoints[j] = null;
- ncoeffs[j] = null;
- }
- return res;
- };
- function Point(curve, x, y, isRed) {
- Base.BasePoint.call(this, curve, 'affine');
- if (x === null && y === null) {
- this.x = null;
- this.y = null;
- this.inf = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- // Force redgomery representation when loading from JSON
- if (isRed) {
- this.x.forceRed(this.curve.red);
- this.y.forceRed(this.curve.red);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- this.inf = false;
- }
- }
- inherits(Point, Base.BasePoint);
- ShortCurve.prototype.point = function point(x, y, isRed) {
- return new Point(this, x, y, isRed);
- };
- ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
- return Point.fromJSON(this, obj, red);
- };
- Point.prototype._getBeta = function _getBeta() {
- if (!this.curve.endo)
- return;
- var pre = this.precomputed;
- if (pre && pre.beta)
- return pre.beta;
- var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
- if (pre) {
- var curve = this.curve;
- var endoMul = function(p) {
- return curve.point(p.x.redMul(curve.endo.beta), p.y);
- };
- pre.beta = beta;
- beta.precomputed = {
- beta: null,
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(endoMul)
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(endoMul)
- }
- };
- }
- return beta;
- };
- Point.prototype.toJSON = function toJSON() {
- if (!this.precomputed)
- return [ this.x, this.y ];
- return [ this.x, this.y, this.precomputed && {
- doubles: this.precomputed.doubles && {
- step: this.precomputed.doubles.step,
- points: this.precomputed.doubles.points.slice(1)
- },
- naf: this.precomputed.naf && {
- wnd: this.precomputed.naf.wnd,
- points: this.precomputed.naf.points.slice(1)
- }
- } ];
- };
- Point.fromJSON = function fromJSON(curve, obj, red) {
- if (typeof obj === 'string')
- obj = JSON.parse(obj);
- var res = curve.point(obj[0], obj[1], red);
- if (!obj[2])
- return res;
- function obj2point(obj) {
- return curve.point(obj[0], obj[1], red);
- }
- var pre = obj[2];
- res.precomputed = {
- beta: null,
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: [ res ].concat(pre.doubles.points.map(obj2point))
- },
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: [ res ].concat(pre.naf.points.map(obj2point))
- }
- };
- return res;
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- return this.inf;
- };
- Point.prototype.add = function add(p) {
- // O + P = P
- if (this.inf)
- return p;
- // P + O = P
- if (p.inf)
- return this;
- // P + P = 2P
- if (this.eq(p))
- return this.dbl();
- // P + (-P) = O
- if (this.neg().eq(p))
- return this.curve.point(null, null);
- // P + Q = O
- if (this.x.cmp(p.x) === 0)
- return this.curve.point(null, null);
- var c = this.y.redSub(p.y);
- if (c.cmpn(0) !== 0)
- c = c.redMul(this.x.redSub(p.x).redInvm());
- var nx = c.redSqr().redISub(this.x).redISub(p.x);
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.dbl = function dbl() {
- if (this.inf)
- return this;
- // 2P = O
- var ys1 = this.y.redAdd(this.y);
- if (ys1.cmpn(0) === 0)
- return this.curve.point(null, null);
- var a = this.curve.a;
- var x2 = this.x.redSqr();
- var dyinv = ys1.redInvm();
- var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
- var nx = c.redSqr().redISub(this.x.redAdd(this.x));
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.getX = function getX() {
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- return this.y.fromRed();
- };
- Point.prototype.mul = function mul(k) {
- k = new BN(k, 16);
- if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else if (this.curve.endo)
- return this.curve._endoWnafMulAdd([ this ], [ k ]);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs, true);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
- };
- Point.prototype.eq = function eq(p) {
- return this === p ||
- this.inf === p.inf &&
- (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
- };
- Point.prototype.neg = function neg(_precompute) {
- if (this.inf)
- return this;
- var res = this.curve.point(this.x, this.y.redNeg());
- if (_precompute && this.precomputed) {
- var pre = this.precomputed;
- var negate = function(p) {
- return p.neg();
- };
- res.precomputed = {
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(negate)
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(negate)
- }
- };
- }
- return res;
- };
- Point.prototype.toJ = function toJ() {
- if (this.inf)
- return this.curve.jpoint(null, null, null);
- var res = this.curve.jpoint(this.x, this.y, this.curve.one);
- return res;
- };
- function JPoint(curve, x, y, z) {
- Base.BasePoint.call(this, curve, 'jacobian');
- if (x === null && y === null && z === null) {
- this.x = this.curve.one;
- this.y = this.curve.one;
- this.z = new BN(0);
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = new BN(z, 16);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- }
- inherits(JPoint, Base.BasePoint);
- ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
- return new JPoint(this, x, y, z);
- };
- JPoint.prototype.toP = function toP() {
- if (this.isInfinity())
- return this.curve.point(null, null);
- var zinv = this.z.redInvm();
- var zinv2 = zinv.redSqr();
- var ax = this.x.redMul(zinv2);
- var ay = this.y.redMul(zinv2).redMul(zinv);
- return this.curve.point(ax, ay);
- };
- JPoint.prototype.neg = function neg() {
- return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
- };
- JPoint.prototype.add = function add(p) {
- // O + P = P
- if (this.isInfinity())
- return p;
- // P + O = P
- if (p.isInfinity())
- return this;
- // 12M + 4S + 7A
- var pz2 = p.z.redSqr();
- var z2 = this.z.redSqr();
- var u1 = this.x.redMul(pz2);
- var u2 = p.x.redMul(z2);
- var s1 = this.y.redMul(pz2.redMul(p.z));
- var s2 = p.y.redMul(z2.redMul(this.z));
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(p.z).redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mixedAdd = function mixedAdd(p) {
- // O + P = P
- if (this.isInfinity())
- return p.toJ();
- // P + O = P
- if (p.isInfinity())
- return this;
- // 8M + 3S + 7A
- var z2 = this.z.redSqr();
- var u1 = this.x;
- var u2 = p.x.redMul(z2);
- var s1 = this.y;
- var s2 = p.y.redMul(z2).redMul(this.z);
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.dblp = function dblp(pow) {
- if (pow === 0)
- return this;
- if (this.isInfinity())
- return this;
- if (!pow)
- return this.dbl();
- if (this.curve.zeroA || this.curve.threeA) {
- var r = this;
- for (var i = 0; i < pow; i++)
- r = r.dbl();
- return r;
- }
- // 1M + 2S + 1A + N * (4S + 5M + 8A)
- // N = 1 => 6M + 6S + 9A
- var a = this.curve.a;
- var tinv = this.curve.tinv;
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- // Reuse results
- var jyd = jy.redAdd(jy);
- for (var i = 0; i < pow; i++) {
- var jx2 = jx.redSqr();
- var jyd2 = jyd.redSqr();
- var jyd4 = jyd2.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var t1 = jx.redMul(jyd2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var dny = c.redMul(t2);
- dny = dny.redIAdd(dny).redISub(jyd4);
- var nz = jyd.redMul(jz);
- if (i + 1 < pow)
- jz4 = jz4.redMul(jyd4);
- jx = nx;
- jz = nz;
- jyd = dny;
- }
- return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
- };
- JPoint.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- if (this.curve.zeroA)
- return this._zeroDbl();
- else if (this.curve.threeA)
- return this._threeDbl();
- else
- return this._dbl();
- };
- JPoint.prototype._zeroDbl = function _zeroDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 14A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // T = M ^ 2 - 2*S
- var t = m.redSqr().redISub(s).redISub(s);
- // 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2*Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-dbl-2009-l
- // 2M + 5S + 13A
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = B^2
- var c = b.redSqr();
- // D = 2 * ((X1 + B)^2 - A - C)
- var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
- d = d.redIAdd(d);
- // E = 3 * A
- var e = a.redAdd(a).redIAdd(a);
- // F = E^2
- var f = e.redSqr();
- // 8 * C
- var c8 = c.redIAdd(c);
- c8 = c8.redIAdd(c8);
- c8 = c8.redIAdd(c8);
- // X3 = F - 2 * D
- nx = f.redISub(d).redISub(d);
- // Y3 = E * (D - X3) - 8 * C
- ny = e.redMul(d.redISub(nx)).redISub(c8);
- // Z3 = 2 * Y1 * Z1
- nz = this.y.redMul(this.z);
- nz = nz.redIAdd(nz);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._threeDbl = function _threeDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 15A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a
- var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
- // T = M^2 - 2 * S
- var t = m.redSqr().redISub(s).redISub(s);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2 * Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
- // 3M + 5S
- // delta = Z1^2
- var delta = this.z.redSqr();
- // gamma = Y1^2
- var gamma = this.y.redSqr();
- // beta = X1 * gamma
- var beta = this.x.redMul(gamma);
- // alpha = 3 * (X1 - delta) * (X1 + delta)
- var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
- alpha = alpha.redAdd(alpha).redIAdd(alpha);
- // X3 = alpha^2 - 8 * beta
- var beta4 = beta.redIAdd(beta);
- beta4 = beta4.redIAdd(beta4);
- var beta8 = beta4.redAdd(beta4);
- nx = alpha.redSqr().redISub(beta8);
- // Z3 = (Y1 + Z1)^2 - gamma - delta
- nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
- // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
- var ggamma8 = gamma.redSqr();
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._dbl = function _dbl() {
- var a = this.curve.a;
- // 4M + 6S + 10A
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- var jx2 = jx.redSqr();
- var jy2 = jy.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var jxd4 = jx.redAdd(jx);
- jxd4 = jxd4.redIAdd(jxd4);
- var t1 = jxd4.redMul(jy2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var jyd8 = jy2.redSqr();
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- var ny = c.redMul(t2).redISub(jyd8);
- var nz = jy.redAdd(jy).redMul(jz);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.trpl = function trpl() {
- if (!this.curve.zeroA)
- return this.dbl().add(this);
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
- // 5M + 10S + ...
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // ZZ = Z1^2
- var zz = this.z.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // M = 3 * XX + a * ZZ2; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // MM = M^2
- var mm = m.redSqr();
- // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
- var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- e = e.redIAdd(e);
- e = e.redAdd(e).redIAdd(e);
- e = e.redISub(mm);
- // EE = E^2
- var ee = e.redSqr();
- // T = 16*YYYY
- var t = yyyy.redIAdd(yyyy);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- // U = (M + E)^2 - MM - EE - T
- var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
- // X3 = 4 * (X1 * EE - 4 * YY * U)
- var yyu4 = yy.redMul(u);
- yyu4 = yyu4.redIAdd(yyu4);
- yyu4 = yyu4.redIAdd(yyu4);
- var nx = this.x.redMul(ee).redISub(yyu4);
- nx = nx.redIAdd(nx);
- nx = nx.redIAdd(nx);
- // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
- var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- // Z3 = (Z1 + E)^2 - ZZ - EE
- var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mul = function mul(k, kbase) {
- k = new BN(k, kbase);
- return this.curve._wnafMul(this, k);
- };
- JPoint.prototype.eq = function eq(p) {
- if (p.type === 'affine')
- return this.eq(p.toJ());
- if (this === p)
- return true;
- // x1 * z2^2 == x2 * z1^2
- var z2 = this.z.redSqr();
- var pz2 = p.z.redSqr();
- if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
- return false;
- // y1 * z2^3 == y2 * z1^3
- var z3 = z2.redMul(this.z);
- var pz3 = pz2.redMul(p.z);
- return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
- };
- JPoint.prototype.eqXToP = function eqXToP(x) {
- var zs = this.z.redSqr();
- var rx = x.toRed(this.curve.red).redMul(zs);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(zs);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- return false;
- };
- JPoint.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC JPoint Infinity>';
- return '<EC JPoint x: ' + this.x.toString(16, 2) +
- ' y: ' + this.y.toString(16, 2) +
- ' z: ' + this.z.toString(16, 2) + '>';
- };
- JPoint.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- /***/ },
- /* 490 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var curves = exports;
- var hash = __webpack_require__(54);
- var elliptic = __webpack_require__(20);
- var assert = elliptic.utils.assert;
- function PresetCurve(options) {
- if (options.type === 'short')
- this.curve = new elliptic.curve.short(options);
- else if (options.type === 'edwards')
- this.curve = new elliptic.curve.edwards(options);
- else
- this.curve = new elliptic.curve.mont(options);
- this.g = this.curve.g;
- this.n = this.curve.n;
- this.hash = options.hash;
- assert(this.g.validate(), 'Invalid curve');
- assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
- }
- curves.PresetCurve = PresetCurve;
- function defineCurve(name, options) {
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- get: function() {
- var curve = new PresetCurve(options);
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- value: curve
- });
- return curve;
- }
- });
- }
- defineCurve('p192', {
- type: 'short',
- prime: 'p192',
- p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
- b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
- n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
- hash: hash.sha256,
- gRed: false,
- g: [
- '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
- '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
- ]
- });
- defineCurve('p224', {
- type: 'short',
- prime: 'p224',
- p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
- b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
- n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
- hash: hash.sha256,
- gRed: false,
- g: [
- 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
- 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
- ]
- });
- defineCurve('p256', {
- type: 'short',
- prime: null,
- p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
- a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
- b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
- n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
- hash: hash.sha256,
- gRed: false,
- g: [
- '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
- '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
- ]
- });
- defineCurve('p384', {
- type: 'short',
- prime: null,
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 ffffffff',
- a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 fffffffc',
- b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
- '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
- n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
- 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
- hash: hash.sha384,
- gRed: false,
- g: [
- 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
- '5502f25d bf55296c 3a545e38 72760ab7',
- '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
- '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
- ]
- });
- defineCurve('p521', {
- type: 'short',
- prime: null,
- p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff',
- a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff fffffffc',
- b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
- '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
- '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
- n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
- 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
- hash: hash.sha512,
- gRed: false,
- g: [
- '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
- '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
- 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
- '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
- '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
- '3fad0761 353c7086 a272c240 88be9476 9fd16650'
- ]
- });
- defineCurve('curve25519', {
- type: 'mont',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '76d06',
- b: '0',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '9'
- ]
- });
- defineCurve('ed25519', {
- type: 'edwards',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '-1',
- c: '1',
- // -121665 * (121666^(-1)) (mod P)
- d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
- // 4/5
- '6666666666666666666666666666666666666666666666666666666666666658'
- ]
- });
- var pre;
- try {
- pre = __webpack_require__(498);
- } catch (e) {
- pre = undefined;
- }
- defineCurve('secp256k1', {
- type: 'short',
- prime: 'k256',
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
- a: '0',
- b: '7',
- n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
- h: '1',
- hash: hash.sha256,
- // Precomputed endomorphism
- beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
- lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
- basis: [
- {
- a: '3086d221a7d46bcde86c90e49284eb15',
- b: '-e4437ed6010e88286f547fa90abfe4c3'
- },
- {
- a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
- b: '3086d221a7d46bcde86c90e49284eb15'
- }
- ],
- gRed: false,
- g: [
- '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
- '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
- pre
- ]
- });
- /***/ },
- /* 491 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var BN = __webpack_require__(12);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- var KeyPair = __webpack_require__(492);
- var Signature = __webpack_require__(493);
- function EC(options) {
- if (!(this instanceof EC))
- return new EC(options);
- // Shortcut `elliptic.ec(curve-name)`
- if (typeof options === 'string') {
- assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
- options = elliptic.curves[options];
- }
- // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
- if (options instanceof elliptic.curves.PresetCurve)
- options = { curve: options };
- this.curve = options.curve.curve;
- this.n = this.curve.n;
- this.nh = this.n.ushrn(1);
- this.g = this.curve.g;
- // Point on curve
- this.g = options.curve.g;
- this.g.precompute(options.curve.n.bitLength() + 1);
- // Hash for function for DRBG
- this.hash = options.hash || options.curve.hash;
- }
- module.exports = EC;
- EC.prototype.keyPair = function keyPair(options) {
- return new KeyPair(this, options);
- };
- EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
- return KeyPair.fromPrivate(this, priv, enc);
- };
- EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
- return KeyPair.fromPublic(this, pub, enc);
- };
- EC.prototype.genKeyPair = function genKeyPair(options) {
- if (!options)
- options = {};
- // Instantiate Hmac_DRBG
- var drbg = new elliptic.hmacDRBG({
- hash: this.hash,
- pers: options.pers,
- entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
- nonce: this.n.toArray()
- });
- var bytes = this.n.byteLength();
- var ns2 = this.n.sub(new BN(2));
- do {
- var priv = new BN(drbg.generate(bytes));
- if (priv.cmp(ns2) > 0)
- continue;
- priv.iaddn(1);
- return this.keyFromPrivate(priv);
- } while (true);
- };
- EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
- var delta = msg.byteLength() * 8 - this.n.bitLength();
- if (delta > 0)
- msg = msg.ushrn(delta);
- if (!truncOnly && msg.cmp(this.n) >= 0)
- return msg.sub(this.n);
- else
- return msg;
- };
- EC.prototype.sign = function sign(msg, key, enc, options) {
- if (typeof enc === 'object') {
- options = enc;
- enc = null;
- }
- if (!options)
- options = {};
- key = this.keyFromPrivate(key, enc);
- msg = this._truncateToN(new BN(msg, 16));
- // Zero-extend key to provide enough entropy
- var bytes = this.n.byteLength();
- var bkey = key.getPrivate().toArray('be', bytes);
- // Zero-extend nonce to have the same byte size as N
- var nonce = msg.toArray('be', bytes);
- // Instantiate Hmac_DRBG
- var drbg = new elliptic.hmacDRBG({
- hash: this.hash,
- entropy: bkey,
- nonce: nonce,
- pers: options.pers,
- persEnc: options.persEnc
- });
- // Number of bytes to generate
- var ns1 = this.n.sub(new BN(1));
- for (var iter = 0; true; iter++) {
- var k = options.k ?
- options.k(iter) :
- new BN(drbg.generate(this.n.byteLength()));
- k = this._truncateToN(k, true);
- if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
- continue;
- var kp = this.g.mul(k);
- if (kp.isInfinity())
- continue;
- var kpX = kp.getX();
- var r = kpX.umod(this.n);
- if (r.cmpn(0) === 0)
- continue;
- var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
- s = s.umod(this.n);
- if (s.cmpn(0) === 0)
- continue;
- var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
- (kpX.cmp(r) !== 0 ? 2 : 0);
- // Use complement of `s`, if it is > `n / 2`
- if (options.canonical && s.cmp(this.nh) > 0) {
- s = this.n.sub(s);
- recoveryParam ^= 1;
- }
- return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
- }
- };
- EC.prototype.verify = function verify(msg, signature, key, enc) {
- msg = this._truncateToN(new BN(msg, 16));
- key = this.keyFromPublic(key, enc);
- signature = new Signature(signature, 'hex');
- // Perform primitive values validation
- var r = signature.r;
- var s = signature.s;
- if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
- return false;
- if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
- return false;
- // Validate signature
- var sinv = s.invm(this.n);
- var u1 = sinv.mul(msg).umod(this.n);
- var u2 = sinv.mul(r).umod(this.n);
- if (!this.curve._maxwellTrick) {
- var p = this.g.mulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- return p.getX().umod(this.n).cmp(r) === 0;
- }
- // NOTE: Greg Maxwell's trick, inspired by:
- // https://git.io/vad3K
- var p = this.g.jmulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- // Compare `p.x` of Jacobian point with `r`,
- // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
- // inverse of `p.z^2`
- return p.eqXToP(r);
- };
- EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
- assert((3 & j) === j, 'The recovery param is more than two bits');
- signature = new Signature(signature, enc);
- var n = this.n;
- var e = new BN(msg);
- var r = signature.r;
- var s = signature.s;
- // A set LSB signifies that the y-coordinate is odd
- var isYOdd = j & 1;
- var isSecondKey = j >> 1;
- if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
- throw new Error('Unable to find sencond key candinate');
- // 1.1. Let x = r + jn.
- if (isSecondKey)
- r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
- else
- r = this.curve.pointFromX(r, isYOdd);
- var eNeg = n.sub(e);
- // 1.6.1 Compute Q = r^-1 (sR - eG)
- // Q = r^-1 (sR + -eG)
- var rInv = signature.r.invm(n);
- return this.g.mulAdd(eNeg, r, s).mul(rInv);
- };
- EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
- signature = new Signature(signature, enc);
- if (signature.recoveryParam !== null)
- return signature.recoveryParam;
- for (var i = 0; i < 4; i++) {
- var Qprime;
- try {
- Qprime = this.recoverPubKey(e, signature, i);
- } catch (e) {
- continue;
- }
- if (Qprime.eq(Q))
- return i;
- }
- throw new Error('Unable to find valid recovery factor');
- };
- /***/ },
- /* 492 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var BN = __webpack_require__(12);
- function KeyPair(ec, options) {
- this.ec = ec;
- this.priv = null;
- this.pub = null;
- // KeyPair(ec, { priv: ..., pub: ... })
- if (options.priv)
- this._importPrivate(options.priv, options.privEnc);
- if (options.pub)
- this._importPublic(options.pub, options.pubEnc);
- }
- module.exports = KeyPair;
- KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(ec, {
- pub: pub,
- pubEnc: enc
- });
- };
- KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
- if (priv instanceof KeyPair)
- return priv;
- return new KeyPair(ec, {
- priv: priv,
- privEnc: enc
- });
- };
- KeyPair.prototype.validate = function validate() {
- var pub = this.getPublic();
- if (pub.isInfinity())
- return { result: false, reason: 'Invalid public key' };
- if (!pub.validate())
- return { result: false, reason: 'Public key is not a point' };
- if (!pub.mul(this.ec.curve.n).isInfinity())
- return { result: false, reason: 'Public key * N != O' };
- return { result: true, reason: null };
- };
- KeyPair.prototype.getPublic = function getPublic(compact, enc) {
- // compact is optional argument
- if (typeof compact === 'string') {
- enc = compact;
- compact = null;
- }
- if (!this.pub)
- this.pub = this.ec.g.mul(this.priv);
- if (!enc)
- return this.pub;
- return this.pub.encode(enc, compact);
- };
- KeyPair.prototype.getPrivate = function getPrivate(enc) {
- if (enc === 'hex')
- return this.priv.toString(16, 2);
- else
- return this.priv;
- };
- KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
- this.priv = new BN(key, enc || 16);
- // Ensure that the priv won't be bigger than n, otherwise we may fail
- // in fixed multiplication method
- this.priv = this.priv.umod(this.ec.curve.n);
- };
- KeyPair.prototype._importPublic = function _importPublic(key, enc) {
- if (key.x || key.y) {
- this.pub = this.ec.curve.point(key.x, key.y);
- return;
- }
- this.pub = this.ec.curve.decodePoint(key, enc);
- };
- // ECDH
- KeyPair.prototype.derive = function derive(pub) {
- return pub.mul(this.priv).getX();
- };
- // ECDSA
- KeyPair.prototype.sign = function sign(msg, enc, options) {
- return this.ec.sign(msg, this, enc, options);
- };
- KeyPair.prototype.verify = function verify(msg, signature) {
- return this.ec.verify(msg, signature, this);
- };
- KeyPair.prototype.inspect = function inspect() {
- return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
- ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
- };
- /***/ },
- /* 493 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var BN = __webpack_require__(12);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- function Signature(options, enc) {
- if (options instanceof Signature)
- return options;
- if (this._importDER(options, enc))
- return;
- assert(options.r && options.s, 'Signature without r or s');
- this.r = new BN(options.r, 16);
- this.s = new BN(options.s, 16);
- if (options.recoveryParam === undefined)
- this.recoveryParam = null;
- else
- this.recoveryParam = options.recoveryParam;
- }
- module.exports = Signature;
- function Position() {
- this.place = 0;
- }
- function getLength(buf, p) {
- var initial = buf[p.place++];
- if (!(initial & 0x80)) {
- return initial;
- }
- var octetLen = initial & 0xf;
- var val = 0;
- for (var i = 0, off = p.place; i < octetLen; i++, off++) {
- val <<= 8;
- val |= buf[off];
- }
- p.place = off;
- return val;
- }
- function rmPadding(buf) {
- var i = 0;
- var len = buf.length - 1;
- while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
- i++;
- }
- if (i === 0) {
- return buf;
- }
- return buf.slice(i);
- }
- Signature.prototype._importDER = function _importDER(data, enc) {
- data = utils.toArray(data, enc);
- var p = new Position();
- if (data[p.place++] !== 0x30) {
- return false;
- }
- var len = getLength(data, p);
- if ((len + p.place) !== data.length) {
- return false;
- }
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var rlen = getLength(data, p);
- var r = data.slice(p.place, rlen + p.place);
- p.place += rlen;
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var slen = getLength(data, p);
- if (data.length !== slen + p.place) {
- return false;
- }
- var s = data.slice(p.place, slen + p.place);
- if (r[0] === 0 && (r[1] & 0x80)) {
- r = r.slice(1);
- }
- if (s[0] === 0 && (s[1] & 0x80)) {
- s = s.slice(1);
- }
- this.r = new BN(r);
- this.s = new BN(s);
- this.recoveryParam = null;
- return true;
- };
- function constructLength(arr, len) {
- if (len < 0x80) {
- arr.push(len);
- return;
- }
- var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
- arr.push(octets | 0x80);
- while (--octets) {
- arr.push((len >>> (octets << 3)) & 0xff);
- }
- arr.push(len);
- }
- Signature.prototype.toDER = function toDER(enc) {
- var r = this.r.toArray();
- var s = this.s.toArray();
- // Pad values
- if (r[0] & 0x80)
- r = [ 0 ].concat(r);
- // Pad values
- if (s[0] & 0x80)
- s = [ 0 ].concat(s);
- r = rmPadding(r);
- s = rmPadding(s);
- while (!s[0] && !(s[1] & 0x80)) {
- s = s.slice(1);
- }
- var arr = [ 0x02 ];
- constructLength(arr, r.length);
- arr = arr.concat(r);
- arr.push(0x02);
- constructLength(arr, s.length);
- var backHalf = arr.concat(s);
- var res = [ 0x30 ];
- constructLength(res, backHalf.length);
- res = res.concat(backHalf);
- return utils.encode(res, enc);
- };
- /***/ },
- /* 494 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var hash = __webpack_require__(54);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var KeyPair = __webpack_require__(495);
- var Signature = __webpack_require__(496);
- function EDDSA(curve) {
- assert(curve === 'ed25519', 'only tested with ed25519 so far');
- if (!(this instanceof EDDSA))
- return new EDDSA(curve);
- var curve = elliptic.curves[curve].curve;
- this.curve = curve;
- this.g = curve.g;
- this.g.precompute(curve.n.bitLength() + 1);
- this.pointClass = curve.point().constructor;
- this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
- this.hash = hash.sha512;
- }
- module.exports = EDDSA;
- /**
- * @param {Array|String} message - message bytes
- * @param {Array|String|KeyPair} secret - secret bytes or a keypair
- * @returns {Signature} - signature
- */
- EDDSA.prototype.sign = function sign(message, secret) {
- message = parseBytes(message);
- var key = this.keyFromSecret(secret);
- var r = this.hashInt(key.messagePrefix(), message);
- var R = this.g.mul(r);
- var Rencoded = this.encodePoint(R);
- var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
- .mul(key.priv());
- var S = r.add(s_).umod(this.curve.n);
- return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
- };
- /**
- * @param {Array} message - message bytes
- * @param {Array|String|Signature} sig - sig bytes
- * @param {Array|String|Point|KeyPair} pub - public key
- * @returns {Boolean} - true if public key matches sig of message
- */
- EDDSA.prototype.verify = function verify(message, sig, pub) {
- message = parseBytes(message);
- sig = this.makeSignature(sig);
- var key = this.keyFromPublic(pub);
- var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
- var SG = this.g.mul(sig.S());
- var RplusAh = sig.R().add(key.pub().mul(h));
- return RplusAh.eq(SG);
- };
- EDDSA.prototype.hashInt = function hashInt() {
- var hash = this.hash();
- for (var i = 0; i < arguments.length; i++)
- hash.update(arguments[i]);
- return utils.intFromLE(hash.digest()).umod(this.curve.n);
- };
- EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
- return KeyPair.fromPublic(this, pub);
- };
- EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
- return KeyPair.fromSecret(this, secret);
- };
- EDDSA.prototype.makeSignature = function makeSignature(sig) {
- if (sig instanceof Signature)
- return sig;
- return new Signature(this, sig);
- };
- /**
- * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
- *
- * EDDSA defines methods for encoding and decoding points and integers. These are
- * helper convenience methods, that pass along to utility functions implied
- * parameters.
- *
- */
- EDDSA.prototype.encodePoint = function encodePoint(point) {
- var enc = point.getY().toArray('le', this.encodingLength);
- enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
- return enc;
- };
- EDDSA.prototype.decodePoint = function decodePoint(bytes) {
- bytes = utils.parseBytes(bytes);
- var lastIx = bytes.length - 1;
- var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
- var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
- var y = utils.intFromLE(normed);
- return this.curve.pointFromY(y, xIsOdd);
- };
- EDDSA.prototype.encodeInt = function encodeInt(num) {
- return num.toArray('le', this.encodingLength);
- };
- EDDSA.prototype.decodeInt = function decodeInt(bytes) {
- return utils.intFromLE(bytes);
- };
- EDDSA.prototype.isPoint = function isPoint(val) {
- return val instanceof this.pointClass;
- };
- /***/ },
- /* 495 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var cachedProperty = utils.cachedProperty;
- /**
- * @param {EDDSA} eddsa - instance
- * @param {Object} params - public/private key parameters
- *
- * @param {Array<Byte>} [params.secret] - secret seed bytes
- * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
- * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
- *
- */
- function KeyPair(eddsa, params) {
- this.eddsa = eddsa;
- this._secret = parseBytes(params.secret);
- if (eddsa.isPoint(params.pub))
- this._pub = params.pub;
- else
- this._pubBytes = parseBytes(params.pub);
- }
- KeyPair.fromPublic = function fromPublic(eddsa, pub) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(eddsa, { pub: pub });
- };
- KeyPair.fromSecret = function fromSecret(eddsa, secret) {
- if (secret instanceof KeyPair)
- return secret;
- return new KeyPair(eddsa, { secret: secret });
- };
- KeyPair.prototype.secret = function secret() {
- return this._secret;
- };
- cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
- return this.eddsa.encodePoint(this.pub());
- });
- cachedProperty(KeyPair, 'pub', function pub() {
- if (this._pubBytes)
- return this.eddsa.decodePoint(this._pubBytes);
- return this.eddsa.g.mul(this.priv());
- });
- cachedProperty(KeyPair, 'privBytes', function privBytes() {
- var eddsa = this.eddsa;
- var hash = this.hash();
- var lastIx = eddsa.encodingLength - 1;
- var a = hash.slice(0, eddsa.encodingLength);
- a[0] &= 248;
- a[lastIx] &= 127;
- a[lastIx] |= 64;
- return a;
- });
- cachedProperty(KeyPair, 'priv', function priv() {
- return this.eddsa.decodeInt(this.privBytes());
- });
- cachedProperty(KeyPair, 'hash', function hash() {
- return this.eddsa.hash().update(this.secret()).digest();
- });
- cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
- return this.hash().slice(this.eddsa.encodingLength);
- });
- KeyPair.prototype.sign = function sign(message) {
- assert(this._secret, 'KeyPair can only verify');
- return this.eddsa.sign(message, this);
- };
- KeyPair.prototype.verify = function verify(message, sig) {
- return this.eddsa.verify(message, sig, this);
- };
- KeyPair.prototype.getSecret = function getSecret(enc) {
- assert(this._secret, 'KeyPair is public only');
- return utils.encode(this.secret(), enc);
- };
- KeyPair.prototype.getPublic = function getPublic(enc) {
- return utils.encode(this.pubBytes(), enc);
- };
- module.exports = KeyPair;
- /***/ },
- /* 496 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var BN = __webpack_require__(12);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- var cachedProperty = utils.cachedProperty;
- var parseBytes = utils.parseBytes;
- /**
- * @param {EDDSA} eddsa - eddsa instance
- * @param {Array<Bytes>|Object} sig -
- * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
- * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
- * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
- * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
- */
- function Signature(eddsa, sig) {
- this.eddsa = eddsa;
- if (typeof sig !== 'object')
- sig = parseBytes(sig);
- if (Array.isArray(sig)) {
- sig = {
- R: sig.slice(0, eddsa.encodingLength),
- S: sig.slice(eddsa.encodingLength)
- };
- }
- assert(sig.R && sig.S, 'Signature without R or S');
- if (eddsa.isPoint(sig.R))
- this._R = sig.R;
- if (sig.S instanceof BN)
- this._S = sig.S;
- this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
- this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
- }
- cachedProperty(Signature, 'S', function S() {
- return this.eddsa.decodeInt(this.Sencoded());
- });
- cachedProperty(Signature, 'R', function R() {
- return this.eddsa.decodePoint(this.Rencoded());
- });
- cachedProperty(Signature, 'Rencoded', function Rencoded() {
- return this.eddsa.encodePoint(this.R());
- });
- cachedProperty(Signature, 'Sencoded', function Sencoded() {
- return this.eddsa.encodeInt(this.S());
- });
- Signature.prototype.toBytes = function toBytes() {
- return this.Rencoded().concat(this.Sencoded());
- };
- Signature.prototype.toHex = function toHex() {
- return utils.encode(this.toBytes(), 'hex').toUpperCase();
- };
- module.exports = Signature;
- /***/ },
- /* 497 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var hash = __webpack_require__(54);
- var elliptic = __webpack_require__(20);
- var utils = elliptic.utils;
- var assert = utils.assert;
- function HmacDRBG(options) {
- if (!(this instanceof HmacDRBG))
- return new HmacDRBG(options);
- this.hash = options.hash;
- this.predResist = !!options.predResist;
- this.outLen = this.hash.outSize;
- this.minEntropy = options.minEntropy || this.hash.hmacStrength;
- this.reseed = null;
- this.reseedInterval = null;
- this.K = null;
- this.V = null;
- var entropy = utils.toArray(options.entropy, options.entropyEnc);
- var nonce = utils.toArray(options.nonce, options.nonceEnc);
- var pers = utils.toArray(options.pers, options.persEnc);
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._init(entropy, nonce, pers);
- }
- module.exports = HmacDRBG;
- HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
- var seed = entropy.concat(nonce).concat(pers);
- this.K = new Array(this.outLen / 8);
- this.V = new Array(this.outLen / 8);
- for (var i = 0; i < this.V.length; i++) {
- this.K[i] = 0x00;
- this.V[i] = 0x01;
- }
- this._update(seed);
- this.reseed = 1;
- this.reseedInterval = 0x1000000000000; // 2^48
- };
- HmacDRBG.prototype._hmac = function hmac() {
- return new hash.hmac(this.hash, this.K);
- };
- HmacDRBG.prototype._update = function update(seed) {
- var kmac = this._hmac()
- .update(this.V)
- .update([ 0x00 ]);
- if (seed)
- kmac = kmac.update(seed);
- this.K = kmac.digest();
- this.V = this._hmac().update(this.V).digest();
- if (!seed)
- return;
- this.K = this._hmac()
- .update(this.V)
- .update([ 0x01 ])
- .update(seed)
- .digest();
- this.V = this._hmac().update(this.V).digest();
- };
- HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
- // Optional entropy enc
- if (typeof entropyEnc !== 'string') {
- addEnc = add;
- add = entropyEnc;
- entropyEnc = null;
- }
- entropy = utils.toBuffer(entropy, entropyEnc);
- add = utils.toBuffer(add, addEnc);
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._update(entropy.concat(add || []));
- this.reseed = 1;
- };
- HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
- if (this.reseed > this.reseedInterval)
- throw new Error('Reseed is required');
- // Optional encoding
- if (typeof enc !== 'string') {
- addEnc = add;
- add = enc;
- enc = null;
- }
- // Optional additional data
- if (add) {
- add = utils.toArray(add, addEnc);
- this._update(add);
- }
- var temp = [];
- while (temp.length < len) {
- this.V = this._hmac().update(this.V).digest();
- temp = temp.concat(this.V);
- }
- var res = temp.slice(0, len);
- this._update(add);
- this.reseed++;
- return utils.encode(res, enc);
- };
- /***/ },
- /* 498 */
- /***/ function(module, exports) {
- module.exports = {
- doubles: {
- step: 4,
- points: [
- [
- 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
- 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
- ],
- [
- '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
- '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
- ],
- [
- '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
- 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
- ],
- [
- '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
- '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
- ],
- [
- '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
- '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
- ],
- [
- '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
- '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
- ],
- [
- 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
- '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
- ],
- [
- '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
- 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
- ],
- [
- 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
- '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
- ],
- [
- 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
- 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
- ],
- [
- 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
- '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
- ],
- [
- '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
- '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
- ],
- [
- '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
- '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
- ],
- [
- '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
- '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
- ],
- [
- '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
- '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
- ],
- [
- '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
- '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
- ],
- [
- '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
- '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
- ],
- [
- '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
- '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
- ],
- [
- '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
- 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
- ],
- [
- 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
- '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
- ],
- [
- 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
- '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
- ],
- [
- '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
- '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
- ],
- [
- '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
- '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
- ],
- [
- 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
- '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
- ],
- [
- '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
- 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
- ],
- [
- 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
- '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
- ],
- [
- 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
- 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
- ],
- [
- 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
- '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
- ],
- [
- 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
- 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
- ],
- [
- 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
- '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
- ],
- [
- '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
- 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
- ],
- [
- '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
- '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
- ],
- [
- 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
- '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
- ],
- [
- '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
- 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
- ],
- [
- 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
- '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
- ],
- [
- 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
- '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
- ],
- [
- 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
- 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
- ],
- [
- '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
- '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
- ],
- [
- '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
- '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
- ],
- [
- '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
- 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
- ],
- [
- '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
- '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
- ],
- [
- 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
- '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
- ],
- [
- '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
- '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
- ],
- [
- '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
- 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
- ],
- [
- '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
- '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
- ],
- [
- 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
- '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
- ],
- [
- '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
- 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
- ],
- [
- 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
- 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
- ],
- [
- 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
- '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
- ],
- [
- '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
- 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
- ],
- [
- '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
- 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
- ],
- [
- 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
- '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
- ],
- [
- 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
- '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
- ],
- [
- 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
- '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
- ],
- [
- '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
- 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
- ],
- [
- '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
- '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
- ],
- [
- 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
- 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
- ],
- [
- '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
- 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
- ],
- [
- '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
- '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
- ],
- [
- '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
- '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
- ],
- [
- 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
- 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
- ],
- [
- '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
- '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
- ],
- [
- '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
- '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
- ],
- [
- 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
- '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
- ],
- [
- 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
- 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
- ]
- ]
- },
- naf: {
- wnd: 7,
- points: [
- [
- 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
- '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
- ],
- [
- '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
- 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
- ],
- [
- '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
- '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
- ],
- [
- 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
- 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
- ],
- [
- '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
- 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
- ],
- [
- 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
- 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
- ],
- [
- 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
- '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
- ],
- [
- 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
- '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
- ],
- [
- '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
- '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
- ],
- [
- '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
- '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
- ],
- [
- '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
- '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
- ],
- [
- '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
- '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
- ],
- [
- 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
- 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
- ],
- [
- 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
- '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
- ],
- [
- '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
- 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
- ],
- [
- '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
- 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
- ],
- [
- '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
- '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
- ],
- [
- '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
- '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
- ],
- [
- '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
- '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
- ],
- [
- '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
- 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
- ],
- [
- 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
- 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
- ],
- [
- '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
- '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
- ],
- [
- '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
- '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
- ],
- [
- 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
- 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
- ],
- [
- '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
- '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
- ],
- [
- 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
- 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
- ],
- [
- 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
- 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
- ],
- [
- '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
- '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
- ],
- [
- '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
- '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
- ],
- [
- '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
- '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
- ],
- [
- 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
- '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
- ],
- [
- '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
- '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
- ],
- [
- 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
- '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
- ],
- [
- '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
- 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
- ],
- [
- '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
- 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
- ],
- [
- 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
- 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
- ],
- [
- '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
- '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
- ],
- [
- '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
- 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
- ],
- [
- 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
- 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
- ],
- [
- '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
- '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
- ],
- [
- '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
- 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
- ],
- [
- '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
- '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
- ],
- [
- '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
- 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
- ],
- [
- 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
- '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
- ],
- [
- '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
- '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
- ],
- [
- '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
- 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
- ],
- [
- '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
- 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
- ],
- [
- 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
- 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
- ],
- [
- 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
- 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
- ],
- [
- '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
- '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
- ],
- [
- '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
- '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
- ],
- [
- 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
- '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
- ],
- [
- 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
- 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
- ],
- [
- '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
- '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
- ],
- [
- '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
- '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
- ],
- [
- 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
- '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
- ],
- [
- '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
- '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
- ],
- [
- 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
- 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
- ],
- [
- '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
- 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
- ],
- [
- '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
- '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
- ],
- [
- 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
- '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
- ],
- [
- 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
- '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
- ],
- [
- '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
- '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
- ],
- [
- '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
- '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
- ],
- [
- '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
- 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
- ],
- [
- '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
- 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
- ],
- [
- '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
- '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
- ],
- [
- '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
- '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
- ],
- [
- '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
- '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
- ],
- [
- '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
- 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
- ],
- [
- 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
- 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
- ],
- [
- '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
- 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
- ],
- [
- 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
- '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
- ],
- [
- 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
- '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
- ],
- [
- 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
- '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
- ],
- [
- 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
- '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
- ],
- [
- '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
- 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
- ],
- [
- '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
- '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
- ],
- [
- '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
- 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
- ],
- [
- 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
- 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
- ],
- [
- 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
- '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
- ],
- [
- 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
- 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
- ],
- [
- 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
- '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
- ],
- [
- '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
- '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
- ],
- [
- 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
- '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
- ],
- [
- 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
- '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
- ],
- [
- '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
- '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
- ],
- [
- '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
- 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
- ],
- [
- 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
- '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
- ],
- [
- 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
- '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
- ],
- [
- 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
- '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
- ],
- [
- '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
- '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
- ],
- [
- 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
- 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
- ],
- [
- '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
- 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
- ],
- [
- 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
- 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
- ],
- [
- 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
- '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
- ],
- [
- '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
- 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
- ],
- [
- 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
- '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
- ],
- [
- 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
- '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
- ],
- [
- 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
- '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
- ],
- [
- '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
- 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
- ],
- [
- '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
- 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
- ],
- [
- 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
- '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
- ],
- [
- '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
- 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
- ],
- [
- '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
- '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
- ],
- [
- '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
- 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
- ],
- [
- 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
- 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
- ],
- [
- '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
- 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
- ],
- [
- '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
- '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
- ],
- [
- '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
- 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
- ],
- [
- '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
- '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
- ],
- [
- 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
- 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
- ],
- [
- '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
- '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
- ],
- [
- 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
- '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
- ],
- [
- '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
- '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
- ],
- [
- 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
- 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
- ],
- [
- 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
- '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
- ],
- [
- 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
- 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
- ],
- [
- '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
- 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
- ],
- [
- '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
- '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
- ],
- [
- '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
- 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
- ],
- [
- '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
- '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
- ],
- [
- '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
- '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
- ],
- [
- '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
- 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
- ],
- [
- '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
- '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
- ],
- [
- '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
- '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
- ],
- [
- '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
- '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
- ]
- ]
- }
- };
- /***/ },
- /* 499 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var utils = exports;
- var BN = __webpack_require__(12);
- utils.assert = function assert(val, msg) {
- if (!val)
- throw new Error(msg || 'Assertion failed');
- };
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg !== 'string') {
- for (var i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- return res;
- }
- if (!enc) {
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- var hi = c >> 8;
- var lo = c & 0xff;
- if (hi)
- res.push(hi, lo);
- else
- res.push(lo);
- }
- } else if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (var i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- }
- return res;
- }
- utils.toArray = toArray;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- utils.zero2 = zero2;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- utils.toHex = toHex;
- utils.encode = function encode(arr, enc) {
- if (enc === 'hex')
- return toHex(arr);
- else
- return arr;
- };
- // Represent num in a w-NAF form
- function getNAF(num, w) {
- var naf = [];
- var ws = 1 << (w + 1);
- var k = num.clone();
- while (k.cmpn(1) >= 0) {
- var z;
- if (k.isOdd()) {
- var mod = k.andln(ws - 1);
- if (mod > (ws >> 1) - 1)
- z = (ws >> 1) - mod;
- else
- z = mod;
- k.isubn(z);
- } else {
- z = 0;
- }
- naf.push(z);
- // Optimization, shift by word if possible
- var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
- for (var i = 1; i < shift; i++)
- naf.push(0);
- k.iushrn(shift);
- }
- return naf;
- }
- utils.getNAF = getNAF;
- // Represent k1, k2 in a Joint Sparse Form
- function getJSF(k1, k2) {
- var jsf = [
- [],
- []
- ];
- k1 = k1.clone();
- k2 = k2.clone();
- var d1 = 0;
- var d2 = 0;
- while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
- // First phase
- var m14 = (k1.andln(3) + d1) & 3;
- var m24 = (k2.andln(3) + d2) & 3;
- if (m14 === 3)
- m14 = -1;
- if (m24 === 3)
- m24 = -1;
- var u1;
- if ((m14 & 1) === 0) {
- u1 = 0;
- } else {
- var m8 = (k1.andln(7) + d1) & 7;
- if ((m8 === 3 || m8 === 5) && m24 === 2)
- u1 = -m14;
- else
- u1 = m14;
- }
- jsf[0].push(u1);
- var u2;
- if ((m24 & 1) === 0) {
- u2 = 0;
- } else {
- var m8 = (k2.andln(7) + d2) & 7;
- if ((m8 === 3 || m8 === 5) && m14 === 2)
- u2 = -m24;
- else
- u2 = m24;
- }
- jsf[1].push(u2);
- // Second phase
- if (2 * d1 === u1 + 1)
- d1 = 1 - d1;
- if (2 * d2 === u2 + 1)
- d2 = 1 - d2;
- k1.iushrn(1);
- k2.iushrn(1);
- }
- return jsf;
- }
- utils.getJSF = getJSF;
- function cachedProperty(obj, name, computer) {
- var key = '_' + name;
- obj.prototype[name] = function cachedProperty() {
- return this[key] !== undefined ? this[key] :
- this[key] = computer.call(this);
- };
- }
- utils.cachedProperty = cachedProperty;
- function parseBytes(bytes) {
- return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
- bytes;
- }
- utils.parseBytes = parseBytes;
- function intFromLE(bytes) {
- return new BN(bytes, 'hex', 'le');
- }
- utils.intFromLE = intFromLE;
- /***/ },
- /* 500 */
- /***/ function(module, exports) {
- "use strict";
- "use strict";
- module.exports = function(arr, iter, context) {
- var results = [];
- if (!Array.isArray(arr)) return results;
- arr.forEach(function(value, index, list) {
- var res = iter.call(context, value, index, list);
- if (Array.isArray(res)) {
- results.push.apply(results, res);
- } else if (res != null) {
- results.push(res);
- }
- });
- return results;
- };
- /***/ },
- /* 501 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var pathModule = __webpack_require__(43);
- var isWindows = process.platform === 'win32';
- // JavaScript implementation of realpath, ported from node pre-v6
- var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
- function rethrow() {
- // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
- // is fairly slow to generate.
- var callback;
- if (DEBUG) {
- var backtrace = new Error;
- callback = debugCallback;
- } else
- callback = missingCallback;
- return callback;
- function debugCallback(err) {
- if (err) {
- backtrace.message = err.message;
- err = backtrace;
- missingCallback(err);
- }
- }
- function missingCallback(err) {
- if (err) {
- if (process.throwDeprecation)
- throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
- else if (!process.noDeprecation) {
- var msg = 'fs: missing callback ' + (err.stack || err.message);
- if (process.traceDeprecation)
- console.trace(msg);
- else
- console.error(msg);
- }
- }
- }
- }
- function maybeCallback(cb) {
- return typeof cb === 'function' ? cb : rethrow();
- }
- var normalize = pathModule.normalize;
- // Regexp that finds the next partion of a (partial) path
- // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
- if (isWindows) {
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
- } else {
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
- }
- // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
- if (isWindows) {
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
- } else {
- var splitRootRe = /^[\/]*/;
- }
- exports.realpathSync = function realpathSync(p, cache) {
- // make p is absolute
- p = pathModule.resolve(p);
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return cache[p];
- }
- var original = p,
- seenLinks = {},
- knownHard = {};
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
- start();
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstatSync(base);
- knownHard[base] = true;
- }
- }
- // walk down the path, swapping out linked pathparts for their real
- // values
- // NB: p.length changes.
- while (pos < p.length) {
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- continue;
- }
- var resolvedLink;
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // some known symbolic link. no need to stat again.
- resolvedLink = cache[base];
- } else {
- var stat = fs.lstatSync(base);
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- continue;
- }
- // read the link if it wasn't read before
- // dev/ino always return 0 on windows, so skip the check.
- var linkTarget = null;
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- linkTarget = seenLinks[id];
- }
- }
- if (linkTarget === null) {
- fs.statSync(base);
- linkTarget = fs.readlinkSync(base);
- }
- resolvedLink = pathModule.resolve(previous, linkTarget);
- // track this, if given a cache.
- if (cache) cache[base] = resolvedLink;
- if (!isWindows) seenLinks[id] = linkTarget;
- }
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
- }
- if (cache) cache[original] = p;
- return p;
- };
- exports.realpath = function realpath(p, cache, cb) {
- if (typeof cb !== 'function') {
- cb = maybeCallback(cache);
- cache = null;
- }
- // make p is absolute
- p = pathModule.resolve(p);
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return process.nextTick(cb.bind(null, null, cache[p]));
- }
- var original = p,
- seenLinks = {},
- knownHard = {};
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
- start();
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstat(base, function(err) {
- if (err) return cb(err);
- knownHard[base] = true;
- LOOP();
- });
- } else {
- process.nextTick(LOOP);
- }
- }
- // walk down the path, swapping out linked pathparts for their real
- // values
- function LOOP() {
- // stop if scanned past end of path
- if (pos >= p.length) {
- if (cache) cache[original] = p;
- return cb(null, p);
- }
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- return process.nextTick(LOOP);
- }
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // known symbolic link. no need to stat again.
- return gotResolvedLink(cache[base]);
- }
- return fs.lstat(base, gotStat);
- }
- function gotStat(err, stat) {
- if (err) return cb(err);
- // if not a symlink, skip to the next path part
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- return process.nextTick(LOOP);
- }
- // stat & read the link if not read before
- // call gotTarget as soon as the link target is known
- // dev/ino always return 0 on windows, so skip the check.
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- return gotTarget(null, seenLinks[id], base);
- }
- }
- fs.stat(base, function(err) {
- if (err) return cb(err);
- fs.readlink(base, function(err, target) {
- if (!isWindows) seenLinks[id] = target;
- gotTarget(err, target);
- });
- });
- }
- function gotTarget(err, target, base) {
- if (err) return cb(err);
- var resolvedLink = pathModule.resolve(previous, target);
- if (cache) cache[base] = resolvedLink;
- gotResolvedLink(resolvedLink);
- }
- function gotResolvedLink(resolvedLink) {
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
- }
- };
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 502 */
- /***/ function(module, exports, __webpack_require__) {
- var util = __webpack_require__(44)
- var INDENT_START = /[\{\[]/
- var INDENT_END = /[\}\]]/
- module.exports = function() {
- var lines = []
- var indent = 0
- var push = function(str) {
- var spaces = ''
- while (spaces.length < indent*2) spaces += ' '
- lines.push(spaces+str)
- }
- var line = function(fmt) {
- if (!fmt) return line
- if (INDENT_END.test(fmt.trim()[0]) && INDENT_START.test(fmt[fmt.length-1])) {
- indent--
- push(util.format.apply(util, arguments))
- indent++
- return line
- }
- if (INDENT_START.test(fmt[fmt.length-1])) {
- push(util.format.apply(util, arguments))
- indent++
- return line
- }
- if (INDENT_END.test(fmt.trim()[0])) {
- indent--
- push(util.format.apply(util, arguments))
- return line
- }
- push(util.format.apply(util, arguments))
- return line
- }
- line.toString = function() {
- return lines.join('\n')
- }
- line.toFunction = function(scope) {
- var src = 'return ('+line.toString()+')'
- var keys = Object.keys(scope || {}).map(function(key) {
- return key
- })
- var vals = keys.map(function(key) {
- return scope[key]
- })
- return Function.apply(null, keys.concat(src)).apply(null, vals)
- }
- if (arguments.length) line.apply(null, arguments)
- return line
- }
- /***/ },
- /* 503 */
- /***/ function(module, exports, __webpack_require__) {
- var isProperty = __webpack_require__(515)
- var gen = function(obj, prop) {
- return isProperty(prop) ? obj+'.'+prop : obj+'['+JSON.stringify(prop)+']'
- }
- gen.valid = isProperty
- gen.property = function (prop) {
- return isProperty(prop) ? prop : JSON.stringify(prop)
- }
- module.exports = gen
- /***/ },
- /* 504 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {module.exports = globSync
- globSync.GlobSync = GlobSync
- var rp = __webpack_require__(198)
- var minimatch = __webpack_require__(135)
- var Minimatch = minimatch.Minimatch
- var Glob = __webpack_require__(200).Glob
- var util = __webpack_require__(44)
- var path = __webpack_require__(43)
- var assert = __webpack_require__(144)
- var isAbsolute = __webpack_require__(137)
- var common = __webpack_require__(199)
- var alphasort = common.alphasort
- var alphasorti = common.alphasorti
- var setopts = common.setopts
- var ownProp = common.ownProp
- var childrenIgnored = common.childrenIgnored
- function globSync (pattern, options) {
- if (typeof options === 'function' || arguments.length === 3)
- throw new TypeError('callback provided to sync glob\n'+
- 'See: https://github.com/isaacs/node-glob/issues/167')
- return new GlobSync(pattern, options).found
- }
- function GlobSync (pattern, options) {
- if (!pattern)
- throw new Error('must provide pattern')
- if (typeof options === 'function' || arguments.length === 3)
- throw new TypeError('callback provided to sync glob\n'+
- 'See: https://github.com/isaacs/node-glob/issues/167')
- if (!(this instanceof GlobSync))
- return new GlobSync(pattern, options)
- setopts(this, pattern, options)
- if (this.noprocess)
- return this
- var n = this.minimatch.set.length
- this.matches = new Array(n)
- for (var i = 0; i < n; i ++) {
- this._process(this.minimatch.set[i], i, false)
- }
- this._finish()
- }
- GlobSync.prototype._finish = function () {
- assert(this instanceof GlobSync)
- if (this.realpath) {
- var self = this
- this.matches.forEach(function (matchset, index) {
- var set = self.matches[index] = Object.create(null)
- for (var p in matchset) {
- try {
- p = self._makeAbs(p)
- var real = rp.realpathSync(p, self.realpathCache)
- set[real] = true
- } catch (er) {
- if (er.syscall === 'stat')
- set[self._makeAbs(p)] = true
- else
- throw er
- }
- }
- })
- }
- common.finish(this)
- }
- GlobSync.prototype._process = function (pattern, index, inGlobStar) {
- assert(this instanceof GlobSync)
- // Get the first [n] parts of pattern that are all strings.
- var n = 0
- while (typeof pattern[n] === 'string') {
- n ++
- }
- // now n is the index of the first one that is *not* a string.
- // See if there's anything else
- var prefix
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index)
- return
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null
- break
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/')
- break
- }
- var remain = pattern.slice(n)
- // get the list of entries.
- var read
- if (prefix === null)
- read = '.'
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
- if (!prefix || !isAbsolute(prefix))
- prefix = '/' + prefix
- read = prefix
- } else
- read = prefix
- var abs = this._makeAbs(read)
- //if ignored, skip processing
- if (childrenIgnored(this, read))
- return
- var isGlobStar = remain[0] === minimatch.GLOBSTAR
- if (isGlobStar)
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)
- else
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar)
- }
- GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
- var entries = this._readdir(abs, inGlobStar)
- // if the abs isn't a dir, then nothing can match!
- if (!entries)
- return
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0]
- var negate = !!this.minimatch.negate
- var rawGlob = pn._glob
- var dotOk = this.dot || rawGlob.charAt(0) === '.'
- var matchedEntries = []
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i]
- if (e.charAt(0) !== '.' || dotOk) {
- var m
- if (negate && !prefix) {
- m = !e.match(pn)
- } else {
- m = e.match(pn)
- }
- if (m)
- matchedEntries.push(e)
- }
- }
- var len = matchedEntries.length
- // If there are no matched entries, then nothing matches.
- if (len === 0)
- return
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index])
- this.matches[index] = Object.create(null)
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i]
- if (prefix) {
- if (prefix.slice(-1) !== '/')
- e = prefix + '/' + e
- else
- e = prefix + e
- }
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path.join(this.root, e)
- }
- this.matches[index][e] = true
- }
- // This was the last one, and no stats were needed
- return
- }
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift()
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i]
- var newPattern
- if (prefix)
- newPattern = [prefix, e]
- else
- newPattern = [e]
- this._process(newPattern.concat(remain), index, inGlobStar)
- }
- }
- GlobSync.prototype._emitMatch = function (index, e) {
- var abs = this._makeAbs(e)
- if (this.mark)
- e = this._mark(e)
- if (this.matches[index][e])
- return
- if (this.nodir) {
- var c = this.cache[this._makeAbs(e)]
- if (c === 'DIR' || Array.isArray(c))
- return
- }
- this.matches[index][e] = true
- if (this.stat)
- this._stat(e)
- }
- GlobSync.prototype._readdirInGlobStar = function (abs) {
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow)
- return this._readdir(abs, false)
- var entries
- var lstat
- var stat
- try {
- lstat = fs.lstatSync(abs)
- } catch (er) {
- // lstat failed, doesn't exist
- return null
- }
- var isSym = lstat.isSymbolicLink()
- this.symlinks[abs] = isSym
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && !lstat.isDirectory())
- this.cache[abs] = 'FILE'
- else
- entries = this._readdir(abs, false)
- return entries
- }
- GlobSync.prototype._readdir = function (abs, inGlobStar) {
- var entries
- if (inGlobStar && !ownProp(this.symlinks, abs))
- return this._readdirInGlobStar(abs)
- if (ownProp(this.cache, abs)) {
- var c = this.cache[abs]
- if (!c || c === 'FILE')
- return null
- if (Array.isArray(c))
- return c
- }
- try {
- return this._readdirEntries(abs, fs.readdirSync(abs))
- } catch (er) {
- this._readdirError(abs, er)
- return null
- }
- }
- GlobSync.prototype._readdirEntries = function (abs, entries) {
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i ++) {
- var e = entries[i]
- if (abs === '/')
- e = abs + e
- else
- e = abs + '/' + e
- this.cache[e] = true
- }
- }
- this.cache[abs] = entries
- // mark and cache dir-ness
- return entries
- }
- GlobSync.prototype._readdirError = function (f, er) {
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR': // totally normal. means it *does* exist.
- var abs = this._makeAbs(f)
- this.cache[abs] = 'FILE'
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd)
- error.path = this.cwd
- error.code = er.code
- throw error
- }
- break
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false
- break
- default: // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false
- if (this.strict)
- throw er
- if (!this.silent)
- console.error('glob error', er)
- break
- }
- }
- GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
- var entries = this._readdir(abs, inGlobStar)
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries)
- return
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1)
- var gspref = prefix ? [ prefix ] : []
- var noGlobStar = gspref.concat(remainWithoutGlobStar)
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false)
- var len = entries.length
- var isSym = this.symlinks[abs]
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar)
- return
- for (var i = 0; i < len; i++) {
- var e = entries[i]
- if (e.charAt(0) === '.' && !this.dot)
- continue
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar)
- this._process(instead, index, true)
- var below = gspref.concat(entries[i], remain)
- this._process(below, index, true)
- }
- }
- GlobSync.prototype._processSimple = function (prefix, index) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var exists = this._stat(prefix)
- if (!this.matches[index])
- this.matches[index] = Object.create(null)
- // If it doesn't exist, then just mark the lack of results
- if (!exists)
- return
- if (prefix && isAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix)
- if (prefix.charAt(0) === '/') {
- prefix = path.join(this.root, prefix)
- } else {
- prefix = path.resolve(this.root, prefix)
- if (trail)
- prefix += '/'
- }
- }
- if (process.platform === 'win32')
- prefix = prefix.replace(/\\/g, '/')
- // Mark this as a match
- this.matches[index][prefix] = true
- }
- // Returns either 'DIR', 'FILE', or false
- GlobSync.prototype._stat = function (f) {
- var abs = this._makeAbs(f)
- var needDir = f.slice(-1) === '/'
- if (f.length > this.maxLength)
- return false
- if (!this.stat && ownProp(this.cache, abs)) {
- var c = this.cache[abs]
- if (Array.isArray(c))
- c = 'DIR'
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR')
- return c
- if (needDir && c === 'FILE')
- return false
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
- var exists
- var stat = this.statCache[abs]
- if (!stat) {
- var lstat
- try {
- lstat = fs.lstatSync(abs)
- } catch (er) {
- return false
- }
- if (lstat.isSymbolicLink()) {
- try {
- stat = fs.statSync(abs)
- } catch (er) {
- stat = lstat
- }
- } else {
- stat = lstat
- }
- }
- this.statCache[abs] = stat
- var c = stat.isDirectory() ? 'DIR' : 'FILE'
- this.cache[abs] = this.cache[abs] || c
- if (needDir && c !== 'DIR')
- return false
- return c
- }
- GlobSync.prototype._mark = function (p) {
- return common.mark(this, p)
- }
- GlobSync.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 505 */
- /***/ function(module, exports, __webpack_require__) {
- var hash = __webpack_require__(54);
- var utils = hash.utils;
- var assert = utils.assert;
- function BlockHash() {
- this.pending = null;
- this.pendingTotal = 0;
- this.blockSize = this.constructor.blockSize;
- this.outSize = this.constructor.outSize;
- this.hmacStrength = this.constructor.hmacStrength;
- this.padLength = this.constructor.padLength / 8;
- this.endian = 'big';
- this._delta8 = this.blockSize / 8;
- this._delta32 = this.blockSize / 32;
- }
- exports.BlockHash = BlockHash;
- BlockHash.prototype.update = function update(msg, enc) {
- // Convert message to array, pad it, and join into 32bit blocks
- msg = utils.toArray(msg, enc);
- if (!this.pending)
- this.pending = msg;
- else
- this.pending = this.pending.concat(msg);
- this.pendingTotal += msg.length;
- // Enough data, try updating
- if (this.pending.length >= this._delta8) {
- msg = this.pending;
- // Process pending data in blocks
- var r = msg.length % this._delta8;
- this.pending = msg.slice(msg.length - r, msg.length);
- if (this.pending.length === 0)
- this.pending = null;
- msg = utils.join32(msg, 0, msg.length - r, this.endian);
- for (var i = 0; i < msg.length; i += this._delta32)
- this._update(msg, i, i + this._delta32);
- }
- return this;
- };
- BlockHash.prototype.digest = function digest(enc) {
- this.update(this._pad());
- assert(this.pending === null);
- return this._digest(enc);
- };
- BlockHash.prototype._pad = function pad() {
- var len = this.pendingTotal;
- var bytes = this._delta8;
- var k = bytes - ((len + this.padLength) % bytes);
- var res = new Array(k + this.padLength);
- res[0] = 0x80;
- for (var i = 1; i < k; i++)
- res[i] = 0;
- // Append length
- len <<= 3;
- if (this.endian === 'big') {
- for (var t = 8; t < this.padLength; t++)
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = len & 0xff;
- } else {
- res[i++] = len & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- for (var t = 8; t < this.padLength; t++)
- res[i++] = 0;
- }
- return res;
- };
- /***/ },
- /* 506 */
- /***/ function(module, exports, __webpack_require__) {
- var hmac = exports;
- var hash = __webpack_require__(54);
- var utils = hash.utils;
- var assert = utils.assert;
- function Hmac(hash, key, enc) {
- if (!(this instanceof Hmac))
- return new Hmac(hash, key, enc);
- this.Hash = hash;
- this.blockSize = hash.blockSize / 8;
- this.outSize = hash.outSize / 8;
- this.inner = null;
- this.outer = null;
- this._init(utils.toArray(key, enc));
- }
- module.exports = Hmac;
- Hmac.prototype._init = function init(key) {
- // Shorten key, if needed
- if (key.length > this.blockSize)
- key = new this.Hash().update(key).digest();
- assert(key.length <= this.blockSize);
- // Add padding to key
- for (var i = key.length; i < this.blockSize; i++)
- key.push(0);
- for (var i = 0; i < key.length; i++)
- key[i] ^= 0x36;
- this.inner = new this.Hash().update(key);
- // 0x36 ^ 0x5c = 0x6a
- for (var i = 0; i < key.length; i++)
- key[i] ^= 0x6a;
- this.outer = new this.Hash().update(key);
- };
- Hmac.prototype.update = function update(msg, enc) {
- this.inner.update(msg, enc);
- return this;
- };
- Hmac.prototype.digest = function digest(enc) {
- this.outer.update(this.inner.digest());
- return this.outer.digest(enc);
- };
- /***/ },
- /* 507 */
- /***/ function(module, exports, __webpack_require__) {
- var hash = __webpack_require__(54);
- var utils = hash.utils;
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_3 = utils.sum32_3;
- var sum32_4 = utils.sum32_4;
- var BlockHash = hash.common.BlockHash;
- function RIPEMD160() {
- if (!(this instanceof RIPEMD160))
- return new RIPEMD160();
- BlockHash.call(this);
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
- this.endian = 'little';
- }
- utils.inherits(RIPEMD160, BlockHash);
- exports.ripemd160 = RIPEMD160;
- RIPEMD160.blockSize = 512;
- RIPEMD160.outSize = 160;
- RIPEMD160.hmacStrength = 192;
- RIPEMD160.padLength = 64;
- RIPEMD160.prototype._update = function update(msg, start) {
- var A = this.h[0];
- var B = this.h[1];
- var C = this.h[2];
- var D = this.h[3];
- var E = this.h[4];
- var Ah = A;
- var Bh = B;
- var Ch = C;
- var Dh = D;
- var Eh = E;
- for (var j = 0; j < 80; j++) {
- var T = sum32(
- rotl32(
- sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
- s[j]),
- E);
- A = E;
- E = D;
- D = rotl32(C, 10);
- C = B;
- B = T;
- T = sum32(
- rotl32(
- sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
- sh[j]),
- Eh);
- Ah = Eh;
- Eh = Dh;
- Dh = rotl32(Ch, 10);
- Ch = Bh;
- Bh = T;
- }
- T = sum32_3(this.h[1], C, Dh);
- this.h[1] = sum32_3(this.h[2], D, Eh);
- this.h[2] = sum32_3(this.h[3], E, Ah);
- this.h[3] = sum32_3(this.h[4], A, Bh);
- this.h[4] = sum32_3(this.h[0], B, Ch);
- this.h[0] = T;
- };
- RIPEMD160.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'little');
- else
- return utils.split32(this.h, 'little');
- };
- function f(j, x, y, z) {
- if (j <= 15)
- return x ^ y ^ z;
- else if (j <= 31)
- return (x & y) | ((~x) & z);
- else if (j <= 47)
- return (x | (~y)) ^ z;
- else if (j <= 63)
- return (x & z) | (y & (~z));
- else
- return x ^ (y | (~z));
- }
- function K(j) {
- if (j <= 15)
- return 0x00000000;
- else if (j <= 31)
- return 0x5a827999;
- else if (j <= 47)
- return 0x6ed9eba1;
- else if (j <= 63)
- return 0x8f1bbcdc;
- else
- return 0xa953fd4e;
- }
- function Kh(j) {
- if (j <= 15)
- return 0x50a28be6;
- else if (j <= 31)
- return 0x5c4dd124;
- else if (j <= 47)
- return 0x6d703ef3;
- else if (j <= 63)
- return 0x7a6d76e9;
- else
- return 0x00000000;
- }
- var r = [
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
- ];
- var rh = [
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
- ];
- var s = [
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
- ];
- var sh = [
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
- ];
- /***/ },
- /* 508 */
- /***/ function(module, exports, __webpack_require__) {
- var hash = __webpack_require__(54);
- var utils = hash.utils;
- var assert = utils.assert;
- var rotr32 = utils.rotr32;
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_4 = utils.sum32_4;
- var sum32_5 = utils.sum32_5;
- var rotr64_hi = utils.rotr64_hi;
- var rotr64_lo = utils.rotr64_lo;
- var shr64_hi = utils.shr64_hi;
- var shr64_lo = utils.shr64_lo;
- var sum64 = utils.sum64;
- var sum64_hi = utils.sum64_hi;
- var sum64_lo = utils.sum64_lo;
- var sum64_4_hi = utils.sum64_4_hi;
- var sum64_4_lo = utils.sum64_4_lo;
- var sum64_5_hi = utils.sum64_5_hi;
- var sum64_5_lo = utils.sum64_5_lo;
- var BlockHash = hash.common.BlockHash;
- var sha256_K = [
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
- ];
- var sha512_K = [
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
- ];
- var sha1_K = [
- 0x5A827999, 0x6ED9EBA1,
- 0x8F1BBCDC, 0xCA62C1D6
- ];
- function SHA256() {
- if (!(this instanceof SHA256))
- return new SHA256();
- BlockHash.call(this);
- this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
- this.k = sha256_K;
- this.W = new Array(64);
- }
- utils.inherits(SHA256, BlockHash);
- exports.sha256 = SHA256;
- SHA256.blockSize = 512;
- SHA256.outSize = 256;
- SHA256.hmacStrength = 192;
- SHA256.padLength = 64;
- SHA256.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i++)
- W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- var f = this.h[5];
- var g = this.h[6];
- var h = this.h[7];
- assert(this.k.length === W.length);
- for (var i = 0; i < W.length; i++) {
- var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
- var T2 = sum32(s0_256(a), maj32(a, b, c));
- h = g;
- g = f;
- f = e;
- e = sum32(d, T1);
- d = c;
- c = b;
- b = a;
- a = sum32(T1, T2);
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- this.h[5] = sum32(this.h[5], f);
- this.h[6] = sum32(this.h[6], g);
- this.h[7] = sum32(this.h[7], h);
- };
- SHA256.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function SHA224() {
- if (!(this instanceof SHA224))
- return new SHA224();
- SHA256.call(this);
- this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
- 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
- }
- utils.inherits(SHA224, SHA256);
- exports.sha224 = SHA224;
- SHA224.blockSize = 512;
- SHA224.outSize = 224;
- SHA224.hmacStrength = 192;
- SHA224.padLength = 64;
- SHA224.prototype._digest = function digest(enc) {
- // Just truncate output
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 7), 'big');
- else
- return utils.split32(this.h.slice(0, 7), 'big');
- };
- function SHA512() {
- if (!(this instanceof SHA512))
- return new SHA512();
- BlockHash.call(this);
- this.h = [ 0x6a09e667, 0xf3bcc908,
- 0xbb67ae85, 0x84caa73b,
- 0x3c6ef372, 0xfe94f82b,
- 0xa54ff53a, 0x5f1d36f1,
- 0x510e527f, 0xade682d1,
- 0x9b05688c, 0x2b3e6c1f,
- 0x1f83d9ab, 0xfb41bd6b,
- 0x5be0cd19, 0x137e2179 ];
- this.k = sha512_K;
- this.W = new Array(160);
- }
- utils.inherits(SHA512, BlockHash);
- exports.sha512 = SHA512;
- SHA512.blockSize = 1024;
- SHA512.outSize = 512;
- SHA512.hmacStrength = 192;
- SHA512.padLength = 128;
- SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
- var W = this.W;
- // 32 x 32bit words
- for (var i = 0; i < 32; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i += 2) {
- var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
- var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
- var c1_hi = W[i - 14]; // i - 7
- var c1_lo = W[i - 13];
- var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
- var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
- var c3_hi = W[i - 32]; // i - 16
- var c3_lo = W[i - 31];
- W[i] = sum64_4_hi(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- }
- };
- SHA512.prototype._update = function _update(msg, start) {
- this._prepareBlock(msg, start);
- var W = this.W;
- var ah = this.h[0];
- var al = this.h[1];
- var bh = this.h[2];
- var bl = this.h[3];
- var ch = this.h[4];
- var cl = this.h[5];
- var dh = this.h[6];
- var dl = this.h[7];
- var eh = this.h[8];
- var el = this.h[9];
- var fh = this.h[10];
- var fl = this.h[11];
- var gh = this.h[12];
- var gl = this.h[13];
- var hh = this.h[14];
- var hl = this.h[15];
- assert(this.k.length === W.length);
- for (var i = 0; i < W.length; i += 2) {
- var c0_hi = hh;
- var c0_lo = hl;
- var c1_hi = s1_512_hi(eh, el);
- var c1_lo = s1_512_lo(eh, el);
- var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
- var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
- var c3_hi = this.k[i];
- var c3_lo = this.k[i + 1];
- var c4_hi = W[i];
- var c4_lo = W[i + 1];
- var T1_hi = sum64_5_hi(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- var T1_lo = sum64_5_lo(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- var c0_hi = s0_512_hi(ah, al);
- var c0_lo = s0_512_lo(ah, al);
- var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
- var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
- var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
- var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
- hh = gh;
- hl = gl;
- gh = fh;
- gl = fl;
- fh = eh;
- fl = el;
- eh = sum64_hi(dh, dl, T1_hi, T1_lo);
- el = sum64_lo(dl, dl, T1_hi, T1_lo);
- dh = ch;
- dl = cl;
- ch = bh;
- cl = bl;
- bh = ah;
- bl = al;
- ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
- al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
- }
- sum64(this.h, 0, ah, al);
- sum64(this.h, 2, bh, bl);
- sum64(this.h, 4, ch, cl);
- sum64(this.h, 6, dh, dl);
- sum64(this.h, 8, eh, el);
- sum64(this.h, 10, fh, fl);
- sum64(this.h, 12, gh, gl);
- sum64(this.h, 14, hh, hl);
- };
- SHA512.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function SHA384() {
- if (!(this instanceof SHA384))
- return new SHA384();
- SHA512.call(this);
- this.h = [ 0xcbbb9d5d, 0xc1059ed8,
- 0x629a292a, 0x367cd507,
- 0x9159015a, 0x3070dd17,
- 0x152fecd8, 0xf70e5939,
- 0x67332667, 0xffc00b31,
- 0x8eb44a87, 0x68581511,
- 0xdb0c2e0d, 0x64f98fa7,
- 0x47b5481d, 0xbefa4fa4 ];
- }
- utils.inherits(SHA384, SHA512);
- exports.sha384 = SHA384;
- SHA384.blockSize = 1024;
- SHA384.outSize = 384;
- SHA384.hmacStrength = 192;
- SHA384.padLength = 128;
- SHA384.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 12), 'big');
- else
- return utils.split32(this.h.slice(0, 12), 'big');
- };
- function SHA1() {
- if (!(this instanceof SHA1))
- return new SHA1();
- BlockHash.call(this);
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
- 0x10325476, 0xc3d2e1f0 ];
- this.W = new Array(80);
- }
- utils.inherits(SHA1, BlockHash);
- exports.sha1 = SHA1;
- SHA1.blockSize = 512;
- SHA1.outSize = 160;
- SHA1.hmacStrength = 80;
- SHA1.padLength = 64;
- SHA1.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for(; i < W.length; i++)
- W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- for (var i = 0; i < W.length; i++) {
- var s = ~~(i / 20);
- var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
- e = d;
- d = c;
- c = rotl32(b, 30);
- b = a;
- a = t;
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- };
- SHA1.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function ch32(x, y, z) {
- return (x & y) ^ ((~x) & z);
- }
- function maj32(x, y, z) {
- return (x & y) ^ (x & z) ^ (y & z);
- }
- function p32(x, y, z) {
- return x ^ y ^ z;
- }
- function s0_256(x) {
- return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
- }
- function s1_256(x) {
- return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
- }
- function g0_256(x) {
- return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
- }
- function g1_256(x) {
- return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
- }
- function ft_1(s, x, y, z) {
- if (s === 0)
- return ch32(x, y, z);
- if (s === 1 || s === 3)
- return p32(x, y, z);
- if (s === 2)
- return maj32(x, y, z);
- }
- function ch64_hi(xh, xl, yh, yl, zh, zl) {
- var r = (xh & yh) ^ ((~xh) & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function ch64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ ((~xl) & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_hi(xh, xl, yh, yl, zh, zl) {
- var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 28);
- var c1_hi = rotr64_hi(xl, xh, 2); // 34
- var c2_hi = rotr64_hi(xl, xh, 7); // 39
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 28);
- var c1_lo = rotr64_lo(xl, xh, 2); // 34
- var c2_lo = rotr64_lo(xl, xh, 7); // 39
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 14);
- var c1_hi = rotr64_hi(xh, xl, 18);
- var c2_hi = rotr64_hi(xl, xh, 9); // 41
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 14);
- var c1_lo = rotr64_lo(xh, xl, 18);
- var c2_lo = rotr64_lo(xl, xh, 9); // 41
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 1);
- var c1_hi = rotr64_hi(xh, xl, 8);
- var c2_hi = shr64_hi(xh, xl, 7);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 1);
- var c1_lo = rotr64_lo(xh, xl, 8);
- var c2_lo = shr64_lo(xh, xl, 7);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 19);
- var c1_hi = rotr64_hi(xl, xh, 29); // 61
- var c2_hi = shr64_hi(xh, xl, 6);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 19);
- var c1_lo = rotr64_lo(xl, xh, 29); // 61
- var c2_lo = shr64_lo(xh, xl, 6);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- /***/ },
- /* 509 */
- /***/ function(module, exports, __webpack_require__) {
- var utils = exports;
- var inherits = __webpack_require__(2);
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg === 'string') {
- if (!enc) {
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- var hi = c >> 8;
- var lo = c & 0xff;
- if (hi)
- res.push(hi, lo);
- else
- res.push(lo);
- }
- } else if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (var i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- }
- } else {
- for (var i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- }
- return res;
- }
- utils.toArray = toArray;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- utils.toHex = toHex;
- function htonl(w) {
- var res = (w >>> 24) |
- ((w >>> 8) & 0xff00) |
- ((w << 8) & 0xff0000) |
- ((w & 0xff) << 24);
- return res >>> 0;
- }
- utils.htonl = htonl;
- function toHex32(msg, endian) {
- var res = '';
- for (var i = 0; i < msg.length; i++) {
- var w = msg[i];
- if (endian === 'little')
- w = htonl(w);
- res += zero8(w.toString(16));
- }
- return res;
- }
- utils.toHex32 = toHex32;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- utils.zero2 = zero2;
- function zero8(word) {
- if (word.length === 7)
- return '0' + word;
- else if (word.length === 6)
- return '00' + word;
- else if (word.length === 5)
- return '000' + word;
- else if (word.length === 4)
- return '0000' + word;
- else if (word.length === 3)
- return '00000' + word;
- else if (word.length === 2)
- return '000000' + word;
- else if (word.length === 1)
- return '0000000' + word;
- else
- return word;
- }
- utils.zero8 = zero8;
- function join32(msg, start, end, endian) {
- var len = end - start;
- assert(len % 4 === 0);
- var res = new Array(len / 4);
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
- var w;
- if (endian === 'big')
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
- else
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
- res[i] = w >>> 0;
- }
- return res;
- }
- utils.join32 = join32;
- function split32(msg, endian) {
- var res = new Array(msg.length * 4);
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
- var m = msg[i];
- if (endian === 'big') {
- res[k] = m >>> 24;
- res[k + 1] = (m >>> 16) & 0xff;
- res[k + 2] = (m >>> 8) & 0xff;
- res[k + 3] = m & 0xff;
- } else {
- res[k + 3] = m >>> 24;
- res[k + 2] = (m >>> 16) & 0xff;
- res[k + 1] = (m >>> 8) & 0xff;
- res[k] = m & 0xff;
- }
- }
- return res;
- }
- utils.split32 = split32;
- function rotr32(w, b) {
- return (w >>> b) | (w << (32 - b));
- }
- utils.rotr32 = rotr32;
- function rotl32(w, b) {
- return (w << b) | (w >>> (32 - b));
- }
- utils.rotl32 = rotl32;
- function sum32(a, b) {
- return (a + b) >>> 0;
- }
- utils.sum32 = sum32;
- function sum32_3(a, b, c) {
- return (a + b + c) >>> 0;
- }
- utils.sum32_3 = sum32_3;
- function sum32_4(a, b, c, d) {
- return (a + b + c + d) >>> 0;
- }
- utils.sum32_4 = sum32_4;
- function sum32_5(a, b, c, d, e) {
- return (a + b + c + d + e) >>> 0;
- }
- utils.sum32_5 = sum32_5;
- function assert(cond, msg) {
- if (!cond)
- throw new Error(msg || 'Assertion failed');
- }
- utils.assert = assert;
- utils.inherits = inherits;
- function sum64(buf, pos, ah, al) {
- var bh = buf[pos];
- var bl = buf[pos + 1];
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- buf[pos] = hi >>> 0;
- buf[pos + 1] = lo;
- }
- exports.sum64 = sum64;
- function sum64_hi(ah, al, bh, bl) {
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- return hi >>> 0;
- };
- exports.sum64_hi = sum64_hi;
- function sum64_lo(ah, al, bh, bl) {
- var lo = al + bl;
- return lo >>> 0;
- };
- exports.sum64_lo = sum64_lo;
- function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- var hi = ah + bh + ch + dh + carry;
- return hi >>> 0;
- };
- exports.sum64_4_hi = sum64_4_hi;
- function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
- var lo = al + bl + cl + dl;
- return lo >>> 0;
- };
- exports.sum64_4_lo = sum64_4_lo;
- function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- lo = (lo + el) >>> 0;
- carry += lo < el ? 1 : 0;
- var hi = ah + bh + ch + dh + eh + carry;
- return hi >>> 0;
- };
- exports.sum64_5_hi = sum64_5_hi;
- function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var lo = al + bl + cl + dl + el;
- return lo >>> 0;
- };
- exports.sum64_5_lo = sum64_5_lo;
- function rotr64_hi(ah, al, num) {
- var r = (al << (32 - num)) | (ah >>> num);
- return r >>> 0;
- };
- exports.rotr64_hi = rotr64_hi;
- function rotr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- };
- exports.rotr64_lo = rotr64_lo;
- function shr64_hi(ah, al, num) {
- return ah >>> num;
- };
- exports.shr64_hi = shr64_hi;
- function shr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- };
- exports.shr64_lo = shr64_lo;
- /***/ },
- /* 510 */
- /***/ function(module, exports, __webpack_require__) {
- var http = __webpack_require__(220);
- var https = module.exports;
- for (var key in http) {
- if (http.hasOwnProperty(key)) https[key] = http[key];
- };
- https.request = function (params, cb) {
- if (!params) params = {};
- params.scheme = 'https';
- params.protocol = 'https:';
- return http.request.call(this, params, cb);
- }
- /***/ },
- /* 511 */
- /***/ function(module, exports) {
- exports.read = function (buffer, offset, isLE, mLen, nBytes) {
- var e, m
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var nBits = -7
- var i = isLE ? (nBytes - 1) : 0
- var d = isLE ? -1 : 1
- var s = buffer[offset + i]
- i += d
- e = s & ((1 << (-nBits)) - 1)
- s >>= (-nBits)
- nBits += eLen
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
- m = e & ((1 << (-nBits)) - 1)
- e >>= (-nBits)
- nBits += mLen
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
- if (e === 0) {
- e = 1 - eBias
- } else if (e === eMax) {
- return m ? NaN : ((s ? -1 : 1) * Infinity)
- } else {
- m = m + Math.pow(2, mLen)
- e = e - eBias
- }
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
- }
- exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
- var e, m, c
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
- var i = isLE ? 0 : (nBytes - 1)
- var d = isLE ? 1 : -1
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
- value = Math.abs(value)
- if (isNaN(value) || value === Infinity) {
- m = isNaN(value) ? 1 : 0
- e = eMax
- } else {
- e = Math.floor(Math.log(value) / Math.LN2)
- if (value * (c = Math.pow(2, -e)) < 1) {
- e--
- c *= 2
- }
- if (e + eBias >= 1) {
- value += rt / c
- } else {
- value += rt * Math.pow(2, 1 - eBias)
- }
- if (value * c >= 2) {
- e++
- c /= 2
- }
- if (e + eBias >= eMax) {
- m = 0
- e = eMax
- } else if (e + eBias >= 1) {
- m = (value * c - 1) * Math.pow(2, mLen)
- e = e + eBias
- } else {
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
- e = 0
- }
- }
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
- e = (e << mLen) | m
- eLen += mLen
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
- buffer[offset + i - d] |= s * 128
- }
- /***/ },
- /* 512 */
- /***/ function(module, exports) {
- var indexOf = [].indexOf;
- module.exports = function(arr, obj){
- if (indexOf) return arr.indexOf(obj);
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i] === obj) return i;
- }
- return -1;
- };
- /***/ },
- /* 513 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {var wrappy = __webpack_require__(228)
- var reqs = Object.create(null)
- var once = __webpack_require__(208)
- module.exports = wrappy(inflight)
- function inflight (key, cb) {
- if (reqs[key]) {
- reqs[key].push(cb)
- return null
- } else {
- reqs[key] = [cb]
- return makeres(key)
- }
- }
- function makeres (key) {
- return once(function RES () {
- var cbs = reqs[key]
- var len = cbs.length
- var args = slice(arguments)
- for (var i = 0; i < len; i++) {
- cbs[i].apply(null, args)
- }
- if (cbs.length > len) {
- // added more in the interim.
- // de-zalgo, just in case, but don't call again.
- cbs.splice(0, len)
- process.nextTick(function () {
- RES.apply(null, args)
- })
- } else {
- delete reqs[key]
- }
- })
- }
- function slice (args) {
- var length = args.length
- var array = []
- for (var i = 0; i < length; i++) array[i] = args[i]
- return array
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 514 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- var ip = exports;
- var Buffer = __webpack_require__(1).Buffer;
- var os = __webpack_require__(209);
- ip.toBuffer = function(ip, buff, offset) {
- offset = ~~offset;
- var result;
- if (this.isV4Format(ip)) {
- result = buff || new Buffer(offset + 4);
- ip.split(/\./g).map(function(byte) {
- result[offset++] = parseInt(byte, 10) & 0xff;
- });
- } else if (this.isV6Format(ip)) {
- var sections = ip.split(':', 8);
- var i;
- for (i = 0; i < sections.length; i++) {
- var isv4 = this.isV4Format(sections[i]);
- var v4Buffer;
- if (isv4) {
- v4Buffer = this.toBuffer(sections[i]);
- sections[i] = v4Buffer.slice(0, 2).toString('hex');
- }
- if (v4Buffer && ++i < 8) {
- sections.splice(i, 0, v4Buffer.slice(2, 4).toString('hex'));
- }
- }
- if (sections[0] === '') {
- while (sections.length < 8) sections.unshift('0');
- } else if (sections[sections.length - 1] === '') {
- while (sections.length < 8) sections.push('0');
- } else if (sections.length < 8) {
- for (i = 0; i < sections.length && sections[i] !== ''; i++);
- var argv = [ i, 1 ];
- for (i = 9 - sections.length; i > 0; i--) {
- argv.push('0');
- }
- sections.splice.apply(sections, argv);
- }
- result = buff || new Buffer(offset + 16);
- for (i = 0; i < sections.length; i++) {
- var word = parseInt(sections[i], 16);
- result[offset++] = (word >> 8) & 0xff;
- result[offset++] = word & 0xff;
- }
- }
- if (!result) {
- throw Error('Invalid ip address: ' + ip);
- }
- return result;
- };
- ip.toString = function(buff, offset, length) {
- offset = ~~offset;
- length = length || (buff.length - offset);
- var result = [];
- if (length === 4) {
- // IPv4
- for (var i = 0; i < length; i++) {
- result.push(buff[offset + i]);
- }
- result = result.join('.');
- } else if (length === 16) {
- // IPv6
- for (var i = 0; i < length; i += 2) {
- result.push(buff.readUInt16BE(offset + i).toString(16));
- }
- result = result.join(':');
- result = result.replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3');
- result = result.replace(/:{3,4}/, '::');
- }
- return result;
- };
- var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
- var ipv6Regex =
- /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
- ip.isV4Format = function(ip) {
- return ipv4Regex.test(ip);
- };
- ip.isV6Format = function(ip) {
- return ipv6Regex.test(ip);
- };
- function _normalizeFamily(family) {
- return family ? family.toLowerCase() : 'ipv4';
- }
- ip.fromPrefixLen = function(prefixlen, family) {
- if (prefixlen > 32) {
- family = 'ipv6';
- } else {
- family = _normalizeFamily(family);
- }
- var len = 4;
- if (family === 'ipv6') {
- len = 16;
- }
- var buff = new Buffer(len);
- for (var i = 0, n = buff.length; i < n; ++i) {
- var bits = 8;
- if (prefixlen < 8) {
- bits = prefixlen;
- }
- prefixlen -= bits;
- buff[i] = ~(0xff >> bits);
- }
- return ip.toString(buff);
- };
- ip.mask = function(addr, mask) {
- addr = ip.toBuffer(addr);
- mask = ip.toBuffer(mask);
- var result = new Buffer(Math.max(addr.length, mask.length));
- // Same protocol - do bitwise and
- if (addr.length === mask.length) {
- for (var i = 0; i < addr.length; i++) {
- result[i] = addr[i] & mask[i];
- }
- } else if (mask.length === 4) {
- // IPv6 address and IPv4 mask
- // (Mask low bits)
- for (var i = 0; i < mask.length; i++) {
- result[i] = addr[addr.length - 4 + i] & mask[i];
- }
- } else {
- // IPv6 mask and IPv4 addr
- for (var i = 0; i < result.length - 6; i++) {
- result[i] = 0;
- }
- // ::ffff:ipv4
- result[10] = 0xff;
- result[11] = 0xff;
- for (var i = 0; i < addr.length; i++) {
- result[i + 12] = addr[i] & mask[i + 12];
- }
- }
- return ip.toString(result);
- };
- ip.cidr = function(cidrString) {
- var cidrParts = cidrString.split('/');
- var addr = cidrParts[0];
- if (cidrParts.length !== 2)
- throw new Error('invalid CIDR subnet: ' + addr);
- var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
- return ip.mask(addr, mask);
- };
- ip.subnet = function(addr, mask) {
- var networkAddress = ip.toLong(ip.mask(addr, mask));
- // Calculate the mask's length.
- var maskBuffer = ip.toBuffer(mask);
- var maskLength = 0;
- for (var i = 0; i < maskBuffer.length; i++) {
- if (maskBuffer[i] === 0xff) {
- maskLength += 8;
- } else {
- var octet = maskBuffer[i] & 0xff;
- while (octet) {
- octet = (octet << 1) & 0xff;
- maskLength++;
- }
- }
- }
- var numberOfAddresses = Math.pow(2, 32 - maskLength);
- return {
- networkAddress: ip.fromLong(networkAddress),
- firstAddress: numberOfAddresses <= 2 ?
- ip.fromLong(networkAddress) :
- ip.fromLong(networkAddress + 1),
- lastAddress: numberOfAddresses <= 2 ?
- ip.fromLong(networkAddress + numberOfAddresses - 1) :
- ip.fromLong(networkAddress + numberOfAddresses - 2),
- broadcastAddress: ip.fromLong(networkAddress + numberOfAddresses - 1),
- subnetMask: mask,
- subnetMaskLength: maskLength,
- numHosts: numberOfAddresses <= 2 ?
- numberOfAddresses : numberOfAddresses - 2,
- length: numberOfAddresses,
- contains: function(other) {
- return networkAddress === ip.toLong(ip.mask(other, mask));
- }
- };
- };
- ip.cidrSubnet = function(cidrString) {
- var cidrParts = cidrString.split('/');
- var addr = cidrParts[0];
- if (cidrParts.length !== 2)
- throw new Error('invalid CIDR subnet: ' + addr);
- var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
- return ip.subnet(addr, mask);
- };
- ip.not = function(addr) {
- var buff = ip.toBuffer(addr);
- for (var i = 0; i < buff.length; i++) {
- buff[i] = 0xff ^ buff[i];
- }
- return ip.toString(buff);
- };
- ip.or = function(a, b) {
- a = ip.toBuffer(a);
- b = ip.toBuffer(b);
- // same protocol
- if (a.length === b.length) {
- for (var i = 0; i < a.length; ++i) {
- a[i] |= b[i];
- }
- return ip.toString(a);
- // mixed protocols
- } else {
- var buff = a;
- var other = b;
- if (b.length > a.length) {
- buff = b;
- other = a;
- }
- var offset = buff.length - other.length;
- for (var i = offset; i < buff.length; ++i) {
- buff[i] |= other[i - offset];
- }
- return ip.toString(buff);
- }
- };
- ip.isEqual = function(a, b) {
- a = ip.toBuffer(a);
- b = ip.toBuffer(b);
- // Same protocol
- if (a.length === b.length) {
- for (var i = 0; i < a.length; i++) {
- if (a[i] !== b[i]) return false;
- }
- return true;
- }
- // Swap
- if (b.length === 4) {
- var t = b;
- b = a;
- a = t;
- }
- // a - IPv4, b - IPv6
- for (var i = 0; i < 10; i++) {
- if (b[i] !== 0) return false;
- }
- var word = b.readUInt16BE(10);
- if (word !== 0 && word !== 0xffff) return false;
- for (var i = 0; i < 4; i++) {
- if (a[i] !== b[i + 12]) return false;
- }
- return true;
- };
- ip.isPrivate = function(addr) {
- return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
- .test(addr) ||
- /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
- /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
- .test(addr) ||
- /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
- /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
- /^f[cd][0-9a-f]{2}:/i.test(addr) ||
- /^fe80:/i.test(addr) ||
- /^::1$/.test(addr) ||
- /^::$/.test(addr);
- };
- ip.isPublic = function(addr) {
- return !ip.isPrivate(addr);
- };
- ip.isLoopback = function(addr) {
- return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
- .test(addr) ||
- /^fe80::1$/.test(addr) ||
- /^::1$/.test(addr) ||
- /^::$/.test(addr);
- };
- ip.loopback = function(family) {
- //
- // Default to `ipv4`
- //
- family = _normalizeFamily(family);
- if (family !== 'ipv4' && family !== 'ipv6') {
- throw new Error('family must be ipv4 or ipv6');
- }
- return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
- };
- //
- // ### function address (name, family)
- // #### @name {string|'public'|'private'} **Optional** Name or security
- // of the network interface.
- // #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
- // to ipv4).
- //
- // Returns the address for the network interface on the current system with
- // the specified `name`:
- // * String: First `family` address of the interface.
- // If not found see `undefined`.
- // * 'public': the first public ip address of family.
- // * 'private': the first private ip address of family.
- // * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
- //
- ip.address = function(name, family) {
- var interfaces = os.networkInterfaces();
- var all;
- //
- // Default to `ipv4`
- //
- family = _normalizeFamily(family);
- //
- // If a specific network interface has been named,
- // return the address.
- //
- if (name && name !== 'private' && name !== 'public') {
- var res = interfaces[name].filter(function(details) {
- var itemFamily = details.family.toLowerCase();
- return itemFamily === family;
- });
- if (res.length === 0)
- return undefined;
- return res[0].address;
- }
- var all = Object.keys(interfaces).map(function (nic) {
- //
- // Note: name will only be `public` or `private`
- // when this is called.
- //
- var addresses = interfaces[nic].filter(function (details) {
- details.family = details.family.toLowerCase();
- if (details.family !== family || ip.isLoopback(details.address)) {
- return false;
- } else if (!name) {
- return true;
- }
- return name === 'public' ? ip.isPrivate(details.address) :
- ip.isPublic(details.address);
- });
- return addresses.length ? addresses[0].address : undefined;
- }).filter(Boolean);
- return !all.length ? ip.loopback(family) : all[0];
- };
- ip.toLong = function(ip) {
- var ipl = 0;
- ip.split('.').forEach(function(octet) {
- ipl <<= 8;
- ipl += parseInt(octet);
- });
- return(ipl >>> 0);
- };
- ip.fromLong = function(ipl) {
- return ((ipl >>> 24) + '.' +
- (ipl >> 16 & 255) + '.' +
- (ipl >> 8 & 255) + '.' +
- (ipl & 255) );
- };
- /***/ },
- /* 515 */
- /***/ function(module, exports) {
- "use strict";
- "use strict"
- function isProperty(str) {
- 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)
- }
- module.exports = isProperty
- /***/ },
- /* 516 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- var isStream = module.exports = function (stream) {
- return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
- };
- isStream.writable = function (stream) {
- return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
- };
- isStream.readable = function (stream) {
- return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
- };
- isStream.duplex = function (stream) {
- return isStream.writable(stream) && isStream.readable(stream);
- };
- isStream.transform = function (stream) {
- return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
- };
- /***/ },
- /* 517 */
- /***/ function(module, exports, __webpack_require__) {
- var stream = __webpack_require__(9)
- function isStream (obj) {
- return obj instanceof stream.Stream
- }
- function isReadable (obj) {
- return isStream(obj) && typeof obj._read == 'function' && typeof obj._readableState == 'object'
- }
- function isWritable (obj) {
- return isStream(obj) && typeof obj._write == 'function' && typeof obj._writableState == 'object'
- }
- function isDuplex (obj) {
- return isReadable(obj) && isWritable(obj)
- }
- module.exports = isStream
- module.exports.isReadable = isReadable
- module.exports.isWritable = isWritable
- module.exports.isDuplex = isDuplex
- /***/ },
- /* 518 */
- /***/ function(module, exports, __webpack_require__) {
- /**
- * lodash 4.0.1 (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license <https://lodash.com/license>
- */
- var baseEach = __webpack_require__(202);
- /**
- * The base implementation of `_.filter` without support for iteratee shorthands.
- *
- * @private
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function baseFilter(collection, predicate) {
- var result = [];
- baseEach(collection, function(value, index, collection) {
- if (predicate(value, index, collection)) {
- result.push(value);
- }
- });
- return result;
- }
- module.exports = baseFilter;
- /***/ },
- /* 519 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(module, global) {/**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0;
- /** `Object#toString` result references. */
- var symbolTag = '[object Symbol]';
- /** Used to determine if values are of the language type `Object`. */
- var objectTypes = {
- 'function': true,
- 'object': true
- };
- /** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
- ? exports
- : undefined;
- /** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
- ? module
- : undefined;
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(objectTypes[typeof self] && self);
- /** Detect free variable `window`. */
- var freeWindow = checkGlobal(objectTypes[typeof window] && window);
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
- /**
- * Used as a reference to the global object.
- *
- * The `this` value is used if it's the global object to avoid Greasemonkey's
- * restricted `window` object, otherwise the `window` object is used.
- */
- var root = freeGlobal ||
- ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
- freeSelf || thisGlobal || Function('return this')();
- /**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /** Built-in value references. */
- var Symbol = root.Symbol;
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = Symbol ? Symbol.prototype : undefined,
- symbolToString = symbolProto ? symbolProto.toString : undefined;
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isSymbol(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
- }
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
- }
- module.exports = baseToString;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
- /***/ },
- /* 520 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(module, global) {/**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- var baseToString = __webpack_require__(519);
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
- /** `Object#toString` result references. */
- var funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]';
- /** Used to match property names within property paths. */
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
- /** Used to match backslashes in property paths. */
- var reEscapeChar = /\\(\\)?/g;
- /** Used to detect host constructors (Safari). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
- /** Used to determine if values are of the language type `Object`. */
- var objectTypes = {
- 'function': true,
- 'object': true
- };
- /** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
- ? exports
- : undefined;
- /** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
- ? module
- : undefined;
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(objectTypes[typeof self] && self);
- /** Detect free variable `window`. */
- var freeWindow = checkGlobal(objectTypes[typeof window] && window);
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
- /**
- * Used as a reference to the global object.
- *
- * The `this` value is used if it's the global object to avoid Greasemonkey's
- * restricted `window` object, otherwise the `window` object is used.
- */
- var root = freeGlobal ||
- ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
- freeSelf || thisGlobal || Function('return this')();
- /**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
- /**
- * Checks if `value` is a host object in IE < 9.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
- */
- function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
- }
- return result;
- }
- /** Used for built-in method references. */
- var arrayProto = Array.prototype,
- objectProto = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString = Function.prototype.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objectToString = objectProto.toString;
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /** Built-in value references. */
- var splice = arrayProto.splice;
- /* Built-in method references that are verified to be native. */
- var Map = getNative(root, 'Map'),
- nativeCreate = getNative(Object, 'create');
- /**
- * Creates a hash object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Hash(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the hash.
- *
- * @private
- * @name clear
- * @memberOf Hash
- */
- function hashClear() {
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
- }
- /**
- * Removes `key` and its value from the hash.
- *
- * @private
- * @name delete
- * @memberOf Hash
- * @param {Object} hash The hash to modify.
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function hashDelete(key) {
- return this.has(key) && delete this.__data__[key];
- }
- /**
- * Gets the hash value for `key`.
- *
- * @private
- * @name get
- * @memberOf Hash
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function hashGet(key) {
- var data = this.__data__;
- if (nativeCreate) {
- var result = data[key];
- return result === HASH_UNDEFINED ? undefined : result;
- }
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
- }
- /**
- * Checks if a hash value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Hash
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function hashHas(key) {
- var data = this.__data__;
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
- }
- /**
- * Sets the hash `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Hash
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the hash instance.
- */
- function hashSet(key, value) {
- var data = this.__data__;
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
- return this;
- }
- // Add methods to `Hash`.
- Hash.prototype.clear = hashClear;
- Hash.prototype['delete'] = hashDelete;
- Hash.prototype.get = hashGet;
- Hash.prototype.has = hashHas;
- Hash.prototype.set = hashSet;
- /**
- * Creates an list cache object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function ListCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the list cache.
- *
- * @private
- * @name clear
- * @memberOf ListCache
- */
- function listCacheClear() {
- this.__data__ = [];
- }
- /**
- * Removes `key` and its value from the list cache.
- *
- * @private
- * @name delete
- * @memberOf ListCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function listCacheDelete(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- return false;
- }
- var lastIndex = data.length - 1;
- if (index == lastIndex) {
- data.pop();
- } else {
- splice.call(data, index, 1);
- }
- return true;
- }
- /**
- * Gets the list cache value for `key`.
- *
- * @private
- * @name get
- * @memberOf ListCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function listCacheGet(key) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- return index < 0 ? undefined : data[index][1];
- }
- /**
- * Checks if a list cache value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf ListCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function listCacheHas(key) {
- return assocIndexOf(this.__data__, key) > -1;
- }
- /**
- * Sets the list cache `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf ListCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the list cache instance.
- */
- function listCacheSet(key, value) {
- var data = this.__data__,
- index = assocIndexOf(data, key);
- if (index < 0) {
- data.push([key, value]);
- } else {
- data[index][1] = value;
- }
- return this;
- }
- // Add methods to `ListCache`.
- ListCache.prototype.clear = listCacheClear;
- ListCache.prototype['delete'] = listCacheDelete;
- ListCache.prototype.get = listCacheGet;
- ListCache.prototype.has = listCacheHas;
- ListCache.prototype.set = listCacheSet;
- /**
- * Creates a map cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function MapCache(entries) {
- var index = -1,
- length = entries ? entries.length : 0;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- /**
- * Removes all key-value entries from the map.
- *
- * @private
- * @name clear
- * @memberOf MapCache
- */
- function mapCacheClear() {
- this.__data__ = {
- 'hash': new Hash,
- 'map': new (Map || ListCache),
- 'string': new Hash
- };
- }
- /**
- * Removes `key` and its value from the map.
- *
- * @private
- * @name delete
- * @memberOf MapCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function mapCacheDelete(key) {
- return getMapData(this, key)['delete'](key);
- }
- /**
- * Gets the map value for `key`.
- *
- * @private
- * @name get
- * @memberOf MapCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function mapCacheGet(key) {
- return getMapData(this, key).get(key);
- }
- /**
- * Checks if a map value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf MapCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function mapCacheHas(key) {
- return getMapData(this, key).has(key);
- }
- /**
- * Sets the map `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf MapCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the map cache instance.
- */
- function mapCacheSet(key, value) {
- getMapData(this, key).set(key, value);
- return this;
- }
- // Add methods to `MapCache`.
- MapCache.prototype.clear = mapCacheClear;
- MapCache.prototype['delete'] = mapCacheDelete;
- MapCache.prototype.get = mapCacheGet;
- MapCache.prototype.has = mapCacheHas;
- MapCache.prototype.set = mapCacheSet;
- /**
- * Gets the index at which the `key` is found in `array` of key-value pairs.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} key The key to search for.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function assocIndexOf(array, key) {
- var length = array.length;
- while (length--) {
- if (eq(array[length][0], key)) {
- return length;
- }
- }
- return -1;
- }
- /**
- * Gets the data for `map`.
- *
- * @private
- * @param {Object} map The map to query.
- * @param {string} key The reference key.
- * @returns {*} Returns the map data.
- */
- function getMapData(map, key) {
- var data = map.__data__;
- return isKeyable(key)
- ? data[typeof key == 'string' ? 'string' : 'hash']
- : data.map;
- }
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = object[key];
- return isNative(value) ? value : undefined;
- }
- /**
- * Checks if `value` is suitable for use as unique object key.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
- */
- function isKeyable(value) {
- var type = typeof value;
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
- ? (value !== '__proto__')
- : (value === null);
- }
- /**
- * Converts `string` to a property path array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the property path array.
- */
- var stringToPath = memoize(function(string) {
- var result = [];
- toString(string).replace(rePropName, function(match, number, quote, string) {
- result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
- });
- return result;
- });
- /**
- * Converts `func` to its source code.
- *
- * @private
- * @param {Function} func The function to process.
- * @returns {string} Returns the source code.
- */
- function toSource(func) {
- if (func != null) {
- try {
- return funcToString.call(func);
- } catch (e) {}
- try {
- return (func + '');
- } catch (e) {}
- }
- return '';
- }
- /**
- * Creates a function that memoizes the result of `func`. If `resolver` is
- * provided, it determines the cache key for storing the result based on the
- * arguments provided to the memoized function. By default, the first argument
- * provided to the memoized function is used as the map cache key. The `func`
- * is invoked with the `this` binding of the memoized function.
- *
- * **Note:** The cache is exposed as the `cache` property on the memoized
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
- * constructor with one whose instances implement the
- * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
- * method interface of `delete`, `get`, `has`, and `set`.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to have its output memoized.
- * @param {Function} [resolver] The function to resolve the cache key.
- * @returns {Function} Returns the new memoized function.
- * @example
- *
- * var object = { 'a': 1, 'b': 2 };
- * var other = { 'c': 3, 'd': 4 };
- *
- * var values = _.memoize(_.values);
- * values(object);
- * // => [1, 2]
- *
- * values(other);
- * // => [3, 4]
- *
- * object.a = 2;
- * values(object);
- * // => [1, 2]
- *
- * // Modify the result cache.
- * values.cache.set(object, ['a', 'b']);
- * values(object);
- * // => ['a', 'b']
- *
- * // Replace `_.memoize.Cache`.
- * _.memoize.Cache = WeakMap;
- */
- function memoize(func, resolver) {
- if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- var memoized = function() {
- var args = arguments,
- key = resolver ? resolver.apply(this, args) : args[0],
- cache = memoized.cache;
- if (cache.has(key)) {
- return cache.get(key);
- }
- var result = func.apply(this, args);
- memoized.cache = cache.set(key, result);
- return result;
- };
- memoized.cache = new (memoize.Cache || MapCache);
- return memoized;
- }
- // Assign cache to `_.memoize`.
- memoize.Cache = MapCache;
- /**
- * Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * comparison between two values to determine if they are equivalent.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
- *
- * _.eq(object, object);
- * // => true
- *
- * _.eq(object, other);
- * // => false
- *
- * _.eq('a', 'a');
- * // => true
- *
- * _.eq('a', Object('a'));
- * // => false
- *
- * _.eq(NaN, NaN);
- * // => true
- */
- function eq(value, other) {
- return value === other || (value !== value && other !== other);
- }
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
- }
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- /**
- * Checks if `value` is a native function.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function,
- * else `false`.
- * @example
- *
- * _.isNative(Array.prototype.push);
- * // => true
- *
- * _.isNative(_);
- * // => false
- */
- function isNative(value) {
- if (!isObject(value)) {
- return false;
- }
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
- return pattern.test(toSource(value));
- }
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : baseToString(value);
- }
- module.exports = stringToPath;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
- /***/ },
- /* 521 */
- /***/ function(module, exports, __webpack_require__) {
- /**
- * lodash (Custom Build) <https://lodash.com/>
- * Build: `lodash modularize exports="npm" -o ./`
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
- * Released under MIT license <https://lodash.com/license>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- */
- var baseFilter = __webpack_require__(518),
- baseIteratee = __webpack_require__(203);
- /**
- * A specialized version of `_.filter` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function arrayFilter(array, predicate) {
- var index = -1,
- length = array.length,
- resIndex = 0,
- result = [];
- while (++index < length) {
- var value = array[index];
- if (predicate(value, index, array)) {
- result[resIndex++] = value;
- }
- }
- return result;
- }
- /**
- * Iterates over elements of `collection`, returning an array of all elements
- * `predicate` returns truthy for. The predicate is invoked with three
- * arguments: (value, index|key, collection).
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Collection
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- * @see _.reject
- * @example
- *
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false }
- * ];
- *
- * _.filter(users, function(o) { return !o.active; });
- * // => objects for ['fred']
- *
- * // The `_.matches` iteratee shorthand.
- * _.filter(users, { 'age': 36, 'active': true });
- * // => objects for ['barney']
- *
- * // The `_.matchesProperty` iteratee shorthand.
- * _.filter(users, ['active', false]);
- * // => objects for ['fred']
- *
- * // The `_.property` iteratee shorthand.
- * _.filter(users, 'active');
- * // => objects for ['barney']
- */
- function filter(collection, predicate) {
- var func = isArray(collection) ? arrayFilter : baseFilter;
- return func(collection, baseIteratee(predicate, 3));
- }
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @type {Function}
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- module.exports = filter;
- /***/ },
- /* 522 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var map = __webpack_require__(134);
- var filter = __webpack_require__(521);
- var convert = __webpack_require__(523);
- var protocols = __webpack_require__(136);
- var varint = __webpack_require__(75);
- // export codec
- module.exports = {
- stringToStringTuples: stringToStringTuples,
- stringTuplesToString: stringTuplesToString,
- tuplesToStringTuples: tuplesToStringTuples,
- stringTuplesToTuples: stringTuplesToTuples,
- bufferToTuples: bufferToTuples,
- tuplesToBuffer: tuplesToBuffer,
- bufferToString: bufferToString,
- stringToBuffer: stringToBuffer,
- fromString: fromString,
- fromBuffer: fromBuffer,
- validateBuffer: validateBuffer,
- isValidBuffer: isValidBuffer,
- cleanPath: cleanPath,
- ParseError: ParseError,
- protoFromTuple: protoFromTuple,
- sizeForAddr: sizeForAddr
- };
- // string -> [[str name, str addr]... ]
- function stringToStringTuples(str) {
- var tuples = [];
- var parts = str.split('/').slice(1); // skip first empty elem
- if (parts.length === 1 && parts[0] === '') {
- return [];
- }
- for (var p = 0; p < parts.length; p++) {
- var part = parts[p];
- var proto = protocols(part);
- if (proto.size === 0) {
- tuples.push([part]);
- continue;
- }
- p++; // advance addr part
- if (p >= parts.length) {
- throw ParseError('invalid address: ' + str);
- }
- tuples.push([part, parts[p]]);
- }
- return tuples;
- }
- // [[str name, str addr]... ] -> string
- function stringTuplesToString(tuples) {
- var parts = [];
- map(tuples, function (tup) {
- var proto = protoFromTuple(tup);
- parts.push(proto.name);
- if (tup.length > 1) {
- parts.push(tup[1]);
- }
- });
- return '/' + parts.join('/');
- }
- // [[str name, str addr]... ] -> [[int code, Buffer]... ]
- function stringTuplesToTuples(tuples) {
- return map(tuples, function (tup) {
- if (!Array.isArray(tup)) {
- tup = [tup];
- }
- var proto = protoFromTuple(tup);
- if (tup.length > 1) {
- return [proto.code, convert.toBuffer(proto.code, tup[1])];
- }
- return [proto.code];
- });
- }
- // [[int code, Buffer]... ] -> [[str name, str addr]... ]
- function tuplesToStringTuples(tuples) {
- return map(tuples, function (tup) {
- var proto = protoFromTuple(tup);
- if (tup.length > 1) {
- return [proto.code, convert.toString(proto.code, tup[1])];
- }
- return [proto.code];
- });
- }
- // [[int code, Buffer ]... ] -> Buffer
- function tuplesToBuffer(tuples) {
- return fromBuffer(Buffer.concat(map(tuples, function (tup) {
- var proto = protoFromTuple(tup);
- var buf = new Buffer(varint.encode(proto.code));
- if (tup.length > 1) {
- buf = Buffer.concat([buf, tup[1]]); // add address buffer
- }
- return buf;
- })));
- }
- function sizeForAddr(p, addr) {
- if (p.size > 0) {
- return p.size / 8;
- } else if (p.size === 0) {
- return 0;
- } else {
- var size = varint.decode(addr);
- return size + varint.decode.bytes;
- }
- }
- // Buffer -> [[int code, Buffer ]... ]
- function bufferToTuples(buf) {
- var tuples = [];
- var i = 0;
- while (i < buf.length) {
- var code = varint.decode(buf, i);
- var n = varint.decode.bytes;
- var p = protocols(code);
- var size = sizeForAddr(p, buf.slice(i + n));
- if (size === 0) {
- tuples.push([code]);
- i += n;
- continue;
- }
- var addr = buf.slice(i + n, i + n + size);
- i += size + n;
- if (i > buf.length) {
- // did not end _exactly_ at buffer.length
- throw ParseError('Invalid address buffer: ' + buf.toString('hex'));
- }
- // ok, tuple seems good.
- tuples.push([code, addr]);
- }
- return tuples;
- }
- // Buffer -> String
- function bufferToString(buf) {
- var a = bufferToTuples(buf);
- var b = tuplesToStringTuples(a);
- return stringTuplesToString(b);
- }
- // String -> Buffer
- function stringToBuffer(str) {
- str = cleanPath(str);
- var a = stringToStringTuples(str);
- var b = stringTuplesToTuples(a);
- return tuplesToBuffer(b);
- }
- // String -> Buffer
- function fromString(str) {
- return stringToBuffer(str);
- }
- // Buffer -> Buffer
- function fromBuffer(buf) {
- var err = validateBuffer(buf);
- if (err) throw err;
- return new Buffer(buf); // copy
- }
- function validateBuffer(buf) {
- try {
- bufferToTuples(buf); // try to parse. will throw if breaks
- } catch (err) {
- return err;
- }
- }
- function isValidBuffer(buf) {
- return validateBuffer(buf) === undefined;
- }
- function cleanPath(str) {
- return '/' + filter(str.trim().split('/')).join('/');
- }
- function ParseError(str) {
- return new Error('Error parsing address: ' + str);
- }
- function protoFromTuple(tup) {
- var proto = protocols(tup[0]);
- return proto;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 523 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var ip = __webpack_require__(514);
- var protocols = __webpack_require__(136);
- var bs58 = __webpack_require__(56);
- var varint = __webpack_require__(75);
- module.exports = Convert;
- // converts (serializes) addresses
- function Convert(proto, a) {
- if (a instanceof Buffer) {
- return Convert.toString(proto, a);
- } else {
- return Convert.toBuffer(proto, a);
- }
- }
- Convert.toString = function convertToString(proto, buf) {
- proto = protocols(proto);
- switch (proto.code) {
- case 4: // ipv4
- case 41:
- // ipv6
- return ip.toString(buf);
- case 6: // tcp
- case 17: // udp
- case 33: // dccp
- case 132:
- // sctp
- return buf2port(buf);
- case 421:
- // ipfs
- return buf2mh(buf);
- default:
- return buf.toString('hex'); // no clue. convert to hex
- }
- };
- Convert.toBuffer = function convertToBuffer(proto, str) {
- proto = protocols(proto);
- switch (proto.code) {
- case 4: // ipv4
- case 41:
- // ipv6
- return ip.toBuffer(str);
- case 6: // tcp
- case 17: // udp
- case 33: // dccp
- case 132:
- // sctp
- return port2buf(parseInt(str, 10));
- case 421:
- // ipfs
- return mh2buf(str);
- default:
- return new Buffer(str, 'hex'); // no clue. convert from hex
- }
- };
- function port2buf(port) {
- var buf = new Buffer(2);
- buf.writeUInt16BE(port, 0);
- return buf;
- }
- function buf2port(buf) {
- return buf.readUInt16BE(0);
- }
- function mh2buf(hash) {
- // the address is a varint prefixed multihash string representation
- var mh = new Buffer(bs58.decode(hash));
- var size = new Buffer(varint.encode(mh.length));
- return Buffer.concat([size, mh]);
- }
- function buf2mh(buf) {
- var size = varint.decode(buf);
- var address = buf.slice(varint.decode.bytes);
- if (address.length !== size) {
- throw new Error('inconsistent lengths');
- }
- return bs58.encode(address);
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 524 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
- var map = __webpack_require__(134);
- var extend = __webpack_require__(98);
- var codec = __webpack_require__(522);
- var protocols = __webpack_require__(136);
- var NotImplemented = new Error('Sorry, Not Implemented Yet.');
- var varint = __webpack_require__(75);
- exports = module.exports = Multiaddr;
- function Multiaddr(addr) {
- if (!(this instanceof Multiaddr)) {
- return new Multiaddr(addr);
- }
- // defaults
- if (!addr) {
- addr = '';
- }
- if (addr instanceof Buffer) {
- this.buffer = codec.fromBuffer(addr);
- } else if (typeof addr === 'string' || addr instanceof String) {
- this.buffer = codec.fromString(addr);
- } else if (addr.buffer && addr.protos && addr.protoCodes) {
- // Multiaddr
- this.buffer = codec.fromBuffer(addr.buffer); // validate + copy buffer
- } else {
- throw new Error('addr must be a string, Buffer, or another Multiaddr');
- }
- }
- // get the multiaddr protocols
- Multiaddr.prototype.toString = function toString() {
- return codec.bufferToString(this.buffer);
- };
- // get the multiaddr as a convinent options object to be dropped in net.createConnection
- Multiaddr.prototype.toOptions = function toOptions() {
- var opts = {};
- var parsed = this.toString().split('/');
- opts.family = parsed[1] === 'ip4' ? 'ipv4' : 'ipv6';
- opts.host = parsed[2];
- opts.port = parsed[4];
- return opts;
- };
- // get the multiaddr protocols
- Multiaddr.prototype.inspect = function inspect() {
- return '<Multiaddr ' + this.buffer.toString('hex') + ' - ' + codec.bufferToString(this.buffer) + '>';
- };
- // get the multiaddr protocols
- Multiaddr.prototype.protos = function protos() {
- return map(this.protoCodes(), function (code) {
- return extend(protocols(code));
- // copy to prevent users from modifying the internal objs.
- });
- };
- // get the multiaddr protocol codes
- Multiaddr.prototype.protoCodes = function protoCodes() {
- var codes = [];
- var buf = this.buffer;
- var i = 0;
- while (i < buf.length) {
- var code = varint.decode(buf, i);
- var n = varint.decode.bytes;
- var p = protocols(code);
- var size = codec.sizeForAddr(p, buf.slice(i + n));
- i += size + n;
- codes.push(code);
- }
- return codes;
- };
- // get the multiaddr protocol string names
- Multiaddr.prototype.protoNames = function protoNames() {
- return map(this.protos(), function (proto) {
- return proto.name;
- });
- };
- // Returns a tuple of parts:
- Multiaddr.prototype.tuples = function tuples() {
- return codec.bufferToTuples(this.buffer);
- };
- // Returns a tuple of string parts:
- Multiaddr.prototype.stringTuples = function stringTuples() {
- var t = codec.bufferToTuples(this.buffer);
- return codec.tuplesToStringTuples(t);
- };
- Multiaddr.prototype.encapsulate = function encapsulate(addr) {
- addr = Multiaddr(addr);
- return Multiaddr(this.toString() + addr.toString());
- };
- Multiaddr.prototype.decapsulate = function decapsulate(addr) {
- addr = addr.toString();
- var s = this.toString();
- var i = s.lastIndexOf(addr);
- if (i < 0) {
- throw new Error('Address ' + this + ' does not contain subaddress: ' + addr);
- }
- return Multiaddr(s.slice(0, i));
- };
- Multiaddr.prototype.equals = function equals(addr) {
- return this.buffer.equals(addr.buffer);
- };
- // get a node friendly address object
- Multiaddr.prototype.nodeAddress = function nodeAddress() {
- if (!this.isThinWaistAddress()) {
- throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');
- }
- var codes = this.protoCodes();
- var parts = this.toString().split('/').slice(1);
- return {
- family: codes[0] === 41 ? 'IPv6' : 'IPv4',
- address: parts[1], // ip addr
- port: parts[3] // tcp or udp port
- };
- };
- // from a node friendly address object
- Multiaddr.fromNodeAddress = function fromNodeAddress(addr, transport) {
- if (!addr) throw new Error('requires node address object');
- if (!transport) throw new Error('requires transport protocol');
- var ip = addr.family === 'IPv6' ? 'ip6' : 'ip4';
- return Multiaddr('/' + [ip, addr.address, transport, addr.port].join('/'));
- };
- // returns whether this address is a standard combination:
- // /{IPv4, IPv6}/{TCP, UDP}
- Multiaddr.prototype.isThinWaistAddress = function isThinWaistAddress(addr) {
- var protos = (addr || this).protos();
- if (protos.length !== 2) {
- return false;
- }
- if (protos[0].code !== 4 && protos[0].code !== 41) {
- return false;
- }
- if (protos[1].code !== 6 && protos[1].code !== 17) {
- return false;
- }
- return true;
- };
- // parses the "stupid string" format:
- // <proto><IPv>://<IP Addr>[:<proto port>]
- // udp4://1.2.3.4:5678
- Multiaddr.prototype.fromStupidString = function fromStupidString(str) {
- throw NotImplemented;
- };
- // patch this in
- Multiaddr.protocols = protocols;
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 525 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- exports.names = {
- sha1: 0x11,
- 'sha2-256': 0x12,
- 'sha2-512': 0x13,
- sha3: 0x14,
- blake2b: 0x40,
- blake2s: 0x41
- };
- exports.codes = {
- 0x11: 'sha1',
- 0x12: 'sha2-256',
- 0x13: 'sha2-512',
- 0x14: 'sha3',
- 0x40: 'blake2b',
- 0x41: 'blake2s'
- };
- exports.defaultLengths = {
- 0x11: 20,
- 0x12: 32,
- 0x13: 64,
- 0x14: 64,
- 0x40: 64,
- 0x41: 32
- };
- /***/ },
- /* 526 */
- /***/ function(module, exports, __webpack_require__) {
- var Sandwich = __webpack_require__(555).SandwichStream
- var stream = __webpack_require__(9)
- var inherits = __webpack_require__(2)
- var isStream = __webpack_require__(516)
- var CRNL = '\r\n'
- module.exports = Multipart
- /**
- * Multipart request constructor.
- * @constructor
- * @param {object} [opts]
- * @param {string} [opts.boundary] - The boundary to be used. If omitted one is generated.
- * @returns {function} Returns the multipart stream.
- */
- function Multipart(boundary) {
- if(!this instanceof Multipart) {
- return new Multipart(boundary)
- }
- this.boundary = boundary || Math.random().toString(36).slice(2)
- Sandwich.call(this, {
- head: '--' + this.boundary + CRNL,
- tail: CRNL + '--' + this.boundary + '--',
- separator: CRNL + '--' + this.boundary + CRNL
- })
- this._add = this.add
- this.add = this.addPart
- }
- inherits(Multipart, Sandwich)
- /**
- * Adds a new part to the request.
- * @param {object} [part={}]
- * @param {object} [part.headers={}]
- * @param {string|buffer|stream} [part.body=\r\n]
- * @returns {function} Returns the multipart stream.
- */
- Multipart.prototype.addPart = function(part) {
- part = part || {}
- var partStream = new stream.PassThrough()
- if(part.headers) {
- for(var key in part.headers) {
- var header = part.headers[key]
- partStream.write(key + ': ' + header + CRNL)
- }
- }
- partStream.write(CRNL)
- if(isStream(part.body)) {
- part.body.pipe(partStream)
- } else {
- partStream.end(part.body)
- }
- this._add(partStream)
- }
- /***/ },
- /* 527 */
- /***/ function(module, exports) {
- module.exports = Array.isArray || function (arr) {
- return Object.prototype.toString.call(arr) == '[object Array]';
- };
- /***/ },
- /* 528 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Readable;
- /*<replacement>*/
- var isArray = __webpack_require__(527);
- /*</replacement>*/
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- var EE = __webpack_require__(30).EventEmitter;
- /*<replacement>*/
- if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- var Stream = __webpack_require__(9);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var StringDecoder;
- util.inherits(Readable, Stream);
- function ReadableState(options, stream) {
- options = options || {};
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.buffer = [];
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = false;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // In streams that never have any data, and do push(null) right away,
- // the consumer can miss the 'end' event if they do some I/O before
- // consuming the stream. So, we don't emit('end') until some reading
- // happens.
- this.calledRead = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, becuase any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder)
- StringDecoder = __webpack_require__(38).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- function Readable(options) {
- if (!(this instanceof Readable))
- return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function(chunk, encoding) {
- var state = this._readableState;
- if (typeof chunk === 'string' && !state.objectMode) {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = new Buffer(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function(chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null || chunk === undefined) {
- state.reading = false;
- if (!state.ended)
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var e = new Error('stream.unshift() after end event');
- stream.emit('error', e);
- } else {
- if (state.decoder && !addToFront && !encoding)
- chunk = state.decoder.write(chunk);
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) {
- state.buffer.unshift(chunk);
- } else {
- state.reading = false;
- state.buffer.push(chunk);
- }
- if (state.needReadable)
- emitReadable(stream);
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended &&
- (state.needReadable ||
- state.length < state.highWaterMark ||
- state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function(enc) {
- if (!StringDecoder)
- StringDecoder = __webpack_require__(38).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- };
- // Don't raise the hwm > 128MB
- var MAX_HWM = 0x800000;
- function roundUpToNextPowerOf2(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2
- n--;
- for (var p = 1; p < 32; p <<= 1) n |= n >> p;
- n++;
- }
- return n;
- }
- function howMuchToRead(n, state) {
- if (state.length === 0 && state.ended)
- return 0;
- if (state.objectMode)
- return n === 0 ? 0 : 1;
- if (n === null || isNaN(n)) {
- // only flow one buffer at a time
- if (state.flowing && state.buffer.length)
- return state.buffer[0].length;
- else
- return state.length;
- }
- if (n <= 0)
- return 0;
- // If we're asking for more than the target buffer level,
- // then raise the water mark. Bump up to the next highest
- // power of 2, to prevent increasing it excessively in tiny
- // amounts.
- if (n > state.highWaterMark)
- state.highWaterMark = roundUpToNextPowerOf2(n);
- // don't have that much. return null, unless we've ended.
- if (n > state.length) {
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- } else
- return state.length;
- }
- return n;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function(n) {
- var state = this._readableState;
- state.calledRead = true;
- var nOrig = n;
- var ret;
- if (typeof n !== 'number' || n > 0)
- state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 &&
- state.needReadable &&
- (state.length >= state.highWaterMark || state.ended)) {
- emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- ret = null;
- // In cases where the decoder did not receive enough data
- // to produce a full chunk, then immediately received an
- // EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
- // howMuchToRead will see this and coerce the amount to
- // read to zero (because it's looking at the length of the
- // first <Buffer > in state.buffer), and we'll end up here.
- //
- // This can only happen via state.decoder -- no other venue
- // exists for pushing a zero-length chunk into state.buffer
- // and triggering this behavior. In this case, we return our
- // remaining data and end the stream, if appropriate.
- if (state.length > 0 && state.decoder) {
- ret = fromList(n, state);
- state.length -= ret.length;
- }
- if (state.length === 0)
- endReadable(this);
- return ret;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- // if we currently have less than the highWaterMark, then also read some
- if (state.length - n <= state.highWaterMark)
- doRead = true;
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading)
- doRead = false;
- if (doRead) {
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0)
- state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- }
- // If _read called its callback synchronously, then `reading`
- // will be false, and we need to re-evaluate how much data we
- // can return to the user.
- if (doRead && !state.reading)
- n = howMuchToRead(nOrig, state);
- if (n > 0)
- ret = fromList(n, state);
- else
- ret = null;
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- }
- state.length -= n;
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (state.length === 0 && !state.ended)
- state.needReadable = true;
- // If we happened to read() exactly the remaining amount in the
- // buffer, and the EOF has been seen at this point, then make sure
- // that we emit 'end' on the very next tick.
- if (state.ended && !state.endEmitted && state.length === 0)
- endReadable(this);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) &&
- 'string' !== typeof chunk &&
- chunk !== null &&
- chunk !== undefined &&
- !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // if we've ended and we have some data left, then emit
- // 'readable' now to make sure it gets picked up.
- if (state.length > 0)
- emitReadable(stream);
- else
- endReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (state.emittedReadable)
- return;
- state.emittedReadable = true;
- if (state.sync)
- process.nextTick(function() {
- emitReadable_(stream);
- });
- else
- emitReadable_(stream);
- }
- function emitReadable_(stream) {
- stream.emit('readable');
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- process.nextTick(function() {
- maybeReadMore_(stream, state);
- });
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended &&
- state.length < state.highWaterMark) {
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;
- else
- len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function(n) {
- this.emit('error', new Error('not implemented'));
- };
- Readable.prototype.pipe = function(dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
- dest !== process.stdout &&
- dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted)
- process.nextTick(endFn);
- else
- src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- if (readable !== src) return;
- cleanup();
- }
- function onend() {
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- function cleanup() {
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (!dest._writableState || dest._writableState.needDrain)
- ondrain();
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- unpipe();
- dest.removeListener('error', onerror);
- if (EE.listenerCount(dest, 'error') === 0)
- dest.emit('error', er);
- }
- // This is a brutally ugly hack to make sure that our error handler
- // is attached before any userland ones. NEVER DO THIS.
- 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];
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- // the handler that waits for readable events after all
- // the data gets sucked out in flow.
- // This would be easier to follow with a .once() handler
- // in flow(), but that is too slow.
- this.on('readable', pipeOnReadable);
- state.flowing = true;
- process.nextTick(function() {
- flow(src);
- });
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function() {
- var dest = this;
- var state = src._readableState;
- state.awaitDrain--;
- if (state.awaitDrain === 0)
- flow(src);
- };
- }
- function flow(src) {
- var state = src._readableState;
- var chunk;
- state.awaitDrain = 0;
- function write(dest, i, list) {
- var written = dest.write(chunk);
- if (false === written) {
- state.awaitDrain++;
- }
- }
- while (state.pipesCount && null !== (chunk = src.read())) {
- if (state.pipesCount === 1)
- write(state.pipes, 0, null);
- else
- forEach(state.pipes, write);
- src.emit('data', chunk);
- // if anyone needs a drain, then we have to wait for that.
- if (state.awaitDrain > 0)
- return;
- }
- // if every destination was unpiped, either before entering this
- // function, or in the while loop, then stop flowing.
- //
- // NB: This is a pretty rare edge case.
- if (state.pipesCount === 0) {
- state.flowing = false;
- // if there were data event listeners added, then switch to old mode.
- if (EE.listenerCount(src, 'data') > 0)
- emitDataEvents(src);
- return;
- }
- // at this point, no one needed a drain, so we just ran out of data
- // on the next readable event, start it over again.
- state.ranOut = true;
- }
- function pipeOnReadable() {
- if (this._readableState.ranOut) {
- this._readableState.ranOut = false;
- flow(this);
- }
- }
- Readable.prototype.unpipe = function(dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0)
- return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes)
- return this;
- if (!dest)
- dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- this.removeListener('readable', pipeOnReadable);
- state.flowing = false;
- if (dest)
- dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- this.removeListener('readable', pipeOnReadable);
- state.flowing = false;
- for (var i = 0; i < len; i++)
- dests[i].emit('unpipe', this);
- return this;
- }
- // try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1)
- return this;
- state.pipes.splice(i, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1)
- state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function(ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- if (ev === 'data' && !this._readableState.flowing)
- emitDataEvents(this);
- if (ev === 'readable' && this.readable) {
- var state = this._readableState;
- if (!state.readableListening) {
- state.readableListening = true;
- state.emittedReadable = false;
- state.needReadable = true;
- if (!state.reading) {
- this.read(0);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function() {
- emitDataEvents(this);
- this.read(0);
- this.emit('resume');
- };
- Readable.prototype.pause = function() {
- emitDataEvents(this, true);
- this.emit('pause');
- };
- function emitDataEvents(stream, startPaused) {
- var state = stream._readableState;
- if (state.flowing) {
- // https://github.com/isaacs/readable-stream/issues/16
- throw new Error('Cannot switch to old mode now.');
- }
- var paused = startPaused || false;
- var readable = false;
- // convert to an old-style stream.
- stream.readable = true;
- stream.pipe = Stream.prototype.pipe;
- stream.on = stream.addListener = Stream.prototype.on;
- stream.on('readable', function() {
- readable = true;
- var c;
- while (!paused && (null !== (c = stream.read())))
- stream.emit('data', c);
- if (c === null) {
- readable = false;
- stream._readableState.needReadable = true;
- }
- });
- stream.pause = function() {
- paused = true;
- this.emit('pause');
- };
- stream.resume = function() {
- paused = false;
- if (readable)
- process.nextTick(function() {
- stream.emit('readable');
- });
- else
- this.read(0);
- this.emit('resume');
- };
- // now make it start, just in case it hadn't already.
- stream.emit('readable');
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function(stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function() {
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length)
- self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function(chunk) {
- if (state.decoder)
- chunk = state.decoder.write(chunk);
- // don't skip over falsy values in objectMode
- //if (state.objectMode && util.isNullOrUndefined(chunk))
- if (state.objectMode && (chunk === null || chunk === undefined))
- return;
- else if (!state.objectMode && (!chunk || !chunk.length))
- return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (typeof stream[i] === 'function' &&
- typeof this[i] === 'undefined') {
- this[i] = function(method) { return function() {
- return stream[method].apply(stream, arguments);
- }}(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function(ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function(n) {
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- function fromList(n, state) {
- var list = state.buffer;
- var length = state.length;
- var stringMode = !!state.decoder;
- var objectMode = !!state.objectMode;
- var ret;
- // nothing in the list, definitely empty.
- if (list.length === 0)
- return null;
- if (length === 0)
- ret = null;
- else if (objectMode)
- ret = list.shift();
- else if (!n || n >= length) {
- // read it all, truncate the array.
- if (stringMode)
- ret = list.join('');
- else
- ret = Buffer.concat(list, length);
- list.length = 0;
- } else {
- // read just some of it.
- if (n < list[0].length) {
- // just take a part of the first list item.
- // slice is the same for buffers and strings.
- var buf = list[0];
- ret = buf.slice(0, n);
- list[0] = buf.slice(n);
- } else if (n === list[0].length) {
- // first list is a perfect match
- ret = list.shift();
- } else {
- // complex case.
- // we have enough to cover it, but it spans past the first buffer.
- if (stringMode)
- ret = '';
- else
- ret = new Buffer(n);
- var c = 0;
- for (var i = 0, l = list.length; i < l && c < n; i++) {
- var buf = list[0];
- var cpy = Math.min(n - c, buf.length);
- if (stringMode)
- ret += buf.slice(0, cpy);
- else
- buf.copy(ret, c, 0, cpy);
- if (cpy < buf.length)
- list[0] = buf.slice(cpy);
- else
- list.shift();
- c += cpy;
- }
- }
- }
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0)
- throw new Error('endReadable called on non-empty stream');
- if (!state.endEmitted && state.calledRead) {
- state.ended = true;
- process.nextTick(function() {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- });
- }
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf (xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 529 */
- /***/ function(module, exports, __webpack_require__) {
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- module.exports = Transform;
- var Duplex = __webpack_require__(207);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(options, stream) {
- this.afterTransform = function(er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb)
- return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (data !== null && data !== undefined)
- stream.push(data);
- if (cb)
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform))
- return new Transform(options);
- Duplex.call(this, options);
- var ts = this._transformState = new TransformState(options, this);
- // when the writable side finishes, then flush out anything remaining.
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- this.once('finish', function() {
- if ('function' === typeof this._flush)
- this._flush(function(er) {
- done(stream, er);
- });
- else
- done(stream);
- });
- }
- Transform.prototype.push = function(chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function(chunk, encoding, cb) {
- throw new Error('not implemented');
- };
- Transform.prototype._write = function(chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform ||
- rs.needReadable ||
- rs.length < rs.highWaterMark)
- this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function(n) {
- var ts = this._transformState;
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er) {
- if (er)
- return stream.emit('error', er);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var rs = stream._readableState;
- var ts = stream._transformState;
- if (ws.length)
- throw new Error('calling transform done when ws.length != 0');
- if (ts.transforming)
- throw new Error('calling transform done when still transforming');
- return stream.push(null);
- }
- /***/ },
- /* 530 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // A bit simpler than readable streams.
- // Implement an async ._write(chunk, cb), and it'll handle all
- // the drain event emission and buffering.
- module.exports = Writable;
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Stream = __webpack_require__(9);
- util.inherits(Writable, Stream);
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- }
- function WritableState(options, stream) {
- options = options || {};
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, becuase any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function(er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.buffer = [];
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- }
- function Writable(options) {
- var Duplex = __webpack_require__(207);
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex))
- return new Writable(options);
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function() {
- this.emit('error', new Error('Cannot pipe. Not readable.'));
- };
- function writeAfterEnd(stream, state, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- if (!Buffer.isBuffer(chunk) &&
- 'string' !== typeof chunk &&
- chunk !== null &&
- chunk !== undefined &&
- !state.objectMode) {
- var er = new TypeError('Invalid non-string/buffer chunk');
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function(chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (Buffer.isBuffer(chunk))
- encoding = 'buffer';
- else if (!encoding)
- encoding = state.defaultEncoding;
- if (typeof cb !== 'function')
- cb = function() {};
- if (state.ended)
- writeAfterEnd(this, state, cb);
- else if (validChunk(this, state, chunk, cb))
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- return ret;
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode &&
- state.decodeStrings !== false &&
- typeof chunk === 'string') {
- chunk = new Buffer(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk))
- encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret)
- state.needDrain = true;
- if (state.writing)
- state.buffer.push(new WriteReq(chunk, encoding, cb));
- else
- doWrite(stream, state, len, chunk, encoding, cb);
- return ret;
- }
- function doWrite(stream, state, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- if (sync)
- process.nextTick(function() {
- cb(er);
- });
- else
- cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er)
- onwriteError(stream, state, sync, er, cb);
- else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(stream, state);
- if (!finished && !state.bufferProcessing && state.buffer.length)
- clearBuffer(stream, state);
- if (sync) {
- process.nextTick(function() {
- afterWrite(stream, state, finished, cb);
- });
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished)
- onwriteDrain(stream, state);
- cb();
- if (finished)
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- for (var c = 0; c < state.buffer.length; c++) {
- var entry = state.buffer[c];
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, len, chunk, encoding, cb);
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- c++;
- break;
- }
- }
- state.bufferProcessing = false;
- if (c < state.buffer.length)
- state.buffer = state.buffer.slice(c);
- else
- state.buffer.length = 0;
- }
- Writable.prototype._write = function(chunk, encoding, cb) {
- cb(new Error('not implemented'));
- };
- Writable.prototype.end = function(chunk, encoding, cb) {
- var state = this._writableState;
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (typeof chunk !== 'undefined' && chunk !== null)
- this.write(chunk, encoding);
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished)
- endWritable(this, state, cb);
- };
- function needFinish(stream, state) {
- return (state.ending &&
- state.length === 0 &&
- !state.finished &&
- !state.writing);
- }
- function finishMaybe(stream, state) {
- var need = needFinish(stream, state);
- if (need) {
- state.finished = true;
- stream.emit('finish');
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished)
- process.nextTick(cb);
- else
- stream.once('finish', cb);
- }
- state.ended = true;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 531 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(529)
- /***/ },
- /* 532 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {var Transform = __webpack_require__(531)
- , inherits = __webpack_require__(44).inherits
- , xtend = __webpack_require__(98)
- function DestroyableTransform(opts) {
- Transform.call(this, opts)
- this._destroyed = false
- }
- inherits(DestroyableTransform, Transform)
- DestroyableTransform.prototype.destroy = function(err) {
- if (this._destroyed) return
- this._destroyed = true
-
- var self = this
- process.nextTick(function() {
- if (err)
- self.emit('error', err)
- self.emit('close')
- })
- }
- // a noop _transform function
- function noop (chunk, enc, callback) {
- callback(null, chunk)
- }
- // create a new export function, used by both the main export and
- // the .ctor export, contains common logic for dealing with arguments
- function through2 (construct) {
- return function (options, transform, flush) {
- if (typeof options == 'function') {
- flush = transform
- transform = options
- options = {}
- }
- if (typeof transform != 'function')
- transform = noop
- if (typeof flush != 'function')
- flush = null
- return construct(options, transform, flush)
- }
- }
- // main export, just make me a transform stream!
- module.exports = through2(function (options, transform, flush) {
- var t2 = new DestroyableTransform(options)
- t2._transform = transform
- if (flush)
- t2._flush = flush
- return t2
- })
- // make me a reusable prototype that I can `new`, or implicitly `new`
- // with a constructor call
- module.exports.ctor = through2(function (options, transform, flush) {
- function Through2 (override) {
- if (!(this instanceof Through2))
- return new Through2(override)
- this.options = xtend(options, override)
- DestroyableTransform.call(this, this.options)
- }
- inherits(Through2, DestroyableTransform)
- Through2.prototype._transform = transform
- if (flush)
- Through2.prototype._flush = flush
- return Through2
- })
- module.exports.obj = through2(function (options, transform, flush) {
- var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
- t2._transform = transform
- if (flush)
- t2._flush = flush
- return t2
- })
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 533 */
- /***/ function(module, exports, __webpack_require__) {
- // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
- // Fedor, you are amazing.
- var asn1 = __webpack_require__(77)
- var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
- this.seq().obj(
- this.key('version').int(),
- this.key('modulus').int(),
- this.key('publicExponent').int(),
- this.key('privateExponent').int(),
- this.key('prime1').int(),
- this.key('prime2').int(),
- this.key('exponent1').int(),
- this.key('exponent2').int(),
- this.key('coefficient').int()
- )
- })
- exports.RSAPrivateKey = RSAPrivateKey
- var RSAPublicKey = asn1.define('RSAPublicKey', function () {
- this.seq().obj(
- this.key('modulus').int(),
- this.key('publicExponent').int()
- )
- })
- exports.RSAPublicKey = RSAPublicKey
- var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
- this.seq().obj(
- this.key('algorithm').use(AlgorithmIdentifier),
- this.key('subjectPublicKey').bitstr()
- )
- })
- exports.PublicKey = PublicKey
- var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
- this.seq().obj(
- this.key('algorithm').objid(),
- this.key('none').null_().optional(),
- this.key('curve').objid().optional(),
- this.key('params').seq().obj(
- this.key('p').int(),
- this.key('q').int(),
- this.key('g').int()
- ).optional()
- )
- })
- var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
- this.seq().obj(
- this.key('version').int(),
- this.key('algorithm').use(AlgorithmIdentifier),
- this.key('subjectPrivateKey').octstr()
- )
- })
- exports.PrivateKey = PrivateKeyInfo
- var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
- this.seq().obj(
- this.key('algorithm').seq().obj(
- this.key('id').objid(),
- this.key('decrypt').seq().obj(
- this.key('kde').seq().obj(
- this.key('id').objid(),
- this.key('kdeparams').seq().obj(
- this.key('salt').octstr(),
- this.key('iters').int()
- )
- ),
- this.key('cipher').seq().obj(
- this.key('algo').objid(),
- this.key('iv').octstr()
- )
- )
- ),
- this.key('subjectPrivateKey').octstr()
- )
- })
- exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
- var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
- this.seq().obj(
- this.key('version').int(),
- this.key('p').int(),
- this.key('q').int(),
- this.key('g').int(),
- this.key('pub_key').int(),
- this.key('priv_key').int()
- )
- })
- exports.DSAPrivateKey = DSAPrivateKey
- exports.DSAparam = asn1.define('DSAparam', function () {
- this.int()
- })
- var ECPrivateKey = asn1.define('ECPrivateKey', function () {
- this.seq().obj(
- this.key('version').int(),
- this.key('privateKey').octstr(),
- this.key('parameters').optional().explicit(0).use(ECParameters),
- this.key('publicKey').optional().explicit(1).bitstr()
- )
- })
- exports.ECPrivateKey = ECPrivateKey
- var ECParameters = asn1.define('ECParameters', function () {
- this.choice({
- namedCurve: this.objid()
- })
- })
- exports.signature = asn1.define('signature', function () {
- this.seq().obj(
- this.key('r').int(),
- this.key('s').int()
- )
- })
- /***/ },
- /* 534 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {// adapted from https://github.com/apatil/pemstrip
- 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
- var startRegex = /^-----BEGIN (.*) KEY-----\r?\n/m
- var fullRegex = /^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m
- var evp = __webpack_require__(95)
- var ciphers = __webpack_require__(102)
- module.exports = function (okey, password) {
- var key = okey.toString()
- var match = key.match(findProc)
- var decrypted
- if (!match) {
- var match2 = key.match(fullRegex)
- decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64')
- } else {
- var suite = 'aes' + match[1]
- var iv = new Buffer(match[2], 'hex')
- var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64')
- var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
- var out = []
- var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
- out.push(cipher.update(cipherText))
- out.push(cipher.final())
- decrypted = Buffer.concat(out)
- }
- var tag = key.match(startRegex)[1] + ' KEY'
- return {
- tag: tag,
- data: decrypted
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 535 */
- /***/ function(module, exports, __webpack_require__) {
- var parse = __webpack_require__(536)
- var stringify = __webpack_require__(537)
- module.exports = parse
- module.exports.parse = parse
- module.exports.stringify = stringify
- /***/ },
- /* 536 */
- /***/ function(module, exports, __webpack_require__) {
- var tokenize = __webpack_require__(538)
- var MAX_RANGE = 0x1FFFFFFF
- var onfieldoptions = function (tokens) {
- var opts = {}
- while (tokens.length) {
- switch (tokens[0]) {
- case '[':
- case ',':
- tokens.shift()
- var name = tokens.shift()
- if (name === '(') { // handling [(A) = B]
- name = tokens.shift()
- tokens.shift() // remove the end of bracket
- }
- if (tokens[0] !== '=') throw new Error('Unexpected token in field options: ' + tokens[0])
- tokens.shift()
- if (tokens[0] === ']') throw new Error('Unexpected ] in field option')
- opts[name] = tokens.shift()
- break
- case ']':
- tokens.shift()
- return opts
- default:
- throw new Error('Unexpected token in field options: ' + tokens[0])
- }
- }
- throw new Error('No closing tag for field options')
- }
- var onfield = function (tokens) {
- var field = {
- name: null,
- type: null,
- tag: 0,
- map: null,
- oneof: null,
- required: false,
- repeated: false,
- options: {}
- }
- while (tokens.length) {
- switch (tokens[0]) {
- case '=':
- tokens.shift()
- field.tag = Number(tokens.shift())
- break
- case 'map':
- field.type = 'map'
- field.map = {from: null, to: null}
- tokens.shift()
- if (tokens[0] !== '<') throw new Error('Unexpected token in map type: ' + tokens[0])
- tokens.shift()
- field.map.from = tokens.shift()
- if (tokens[0] !== ',') throw new Error('Unexpected token in map type: ' + tokens[0])
- tokens.shift()
- field.map.to = tokens.shift()
- if (tokens[0] !== '>') throw new Error('Unexpected token in map type: ' + tokens[0])
- tokens.shift()
- field.name = tokens.shift()
- break
- case 'repeated':
- case 'required':
- case 'optional':
- var t = tokens.shift()
- field.required = t === 'required'
- field.repeated = t === 'repeated'
- field.type = tokens.shift()
- field.name = tokens.shift()
- break
- case '[':
- field.options = onfieldoptions(tokens)
- break
- case ';':
- tokens.shift()
- return field
- default:
- throw new Error('Unexpected token in message field: ' + tokens[0])
- }
- }
- throw new Error('No ; found for message field')
- }
- var onmessagebody = function (tokens) {
- var body = {
- enums: [],
- messages: [],
- fields: [],
- extensions: null
- }
- while (tokens.length) {
- switch (tokens[0]) {
- case 'map':
- case 'repeated':
- case 'optional':
- case 'required':
- body.fields.push(onfield(tokens))
- break
- case 'enum':
- body.enums.push(onenum(tokens))
- break
- case 'message':
- body.messages.push(onmessage(tokens))
- break
- case 'extensions':
- body.extensions = onextensions(tokens)
- break
- case 'oneof':
- tokens.shift()
- var name = tokens.shift()
- if (tokens[0] !== '{') throw new Error('Unexpected token in oneof: ' + tokens[0])
- tokens.shift()
- while (tokens[0] !== '}') {
- tokens.unshift('optional')
- var field = onfield(tokens)
- field.oneof = name
- body.fields.push(field)
- }
- tokens.shift()
- break
- case ';':
- tokens.shift()
- break
- default:
- // proto3 does not require the use of optional/required, assumed as optional
- // "singular: a well-formed message can have zero or one of this field (but not more than one)."
- // https://developers.google.com/protocol-buffers/docs/proto3#specifying-field-rules
- tokens.unshift('optional')
- body.fields.push(onfield(tokens))
- }
- }
- return body
- }
- var onextend = function (tokens) {
- var out = {
- name: tokens[1],
- message: onmessage(tokens)
- }
- return out
- }
- var onextensions = function (tokens) {
- tokens.shift()
- var from = Number(tokens.shift())
- if (isNaN(from)) throw new Error('Invalid from in extensions definition')
- if (tokens.shift() !== 'to') throw new Error("Expected keyword 'to' in extensions definition")
- var to = tokens.shift()
- if (to === 'max') to = MAX_RANGE
- to = Number(to)
- if (isNaN(to)) throw new Error('Invalid to in extensions definition')
- if (tokens.shift() !== ';') throw new Error('Missing ; in extensions definition')
- return {from: from, to: to}
- }
- var onmessage = function (tokens) {
- tokens.shift()
- var lvl = 1
- var body = []
- var msg = {
- name: tokens.shift(),
- enums: [],
- messages: [],
- fields: []
- }
- if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
- tokens.shift()
- while (tokens.length) {
- if (tokens[0] === '{') lvl++
- else if (tokens[0] === '}') lvl--
- if (!lvl) {
- tokens.shift()
- body = onmessagebody(body)
- msg.enums = body.enums
- msg.messages = body.messages
- msg.fields = body.fields
- msg.extensions = body.extensions
- return msg
- }
- body.push(tokens.shift())
- }
- if (lvl) throw new Error('No closing tag for message')
- }
- var onpackagename = function (tokens) {
- tokens.shift()
- var name = tokens.shift()
- if (tokens[0] !== ';') throw new Error('Expected ; but found ' + tokens[0])
- tokens.shift()
- return name
- }
- var onsyntaxversion = function (tokens) {
- tokens.shift()
- if (tokens[0] !== '=') throw new Error('Expected = but found ' + tokens[0])
- tokens.shift()
- var version = tokens.shift()
- switch (version) {
- case '"proto2"':
- version = 2
- break
- case '"proto3"':
- version = 3
- break
- default:
- throw new Error('Expected protobuf syntax version but found ' + version)
- }
- if (tokens[0] !== ';') throw new Error('Expected ; but found ' + tokens[0])
- tokens.shift()
- return version
- }
- var onenumvalue = function (tokens) {
- if (tokens.length < 4) throw new Error('Invalid enum value: ' + tokens.slice(0, 3).join(' '))
- if (tokens[1] !== '=') throw new Error('Expected = but found ' + tokens[1])
- if (tokens[3] !== ';') throw new Error('Expected ; but found ' + tokens[1])
- var name = tokens.shift()
- tokens.shift()
- var value = Number(tokens.shift())
- tokens.shift()
- return {
- name: name,
- value: value
- }
- }
- var onenum = function (tokens) {
- tokens.shift()
- var e = {
- name: tokens.shift(),
- values: {}
- }
- if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
- tokens.shift()
- while (tokens.length) {
- if (tokens[0] === '}') {
- tokens.shift()
- // there goes optional semicolon after the enclosing "}"
- if (tokens[0] === ';') tokens.shift()
- return e
- }
- if (tokens[0] === 'option') {
- // just skip "option allow_alias = true;"
- while (tokens.shift() !== ';') {
- // do nothing
- }
- }
- var val = onenumvalue(tokens)
- e.values[val.name] = val.value
- }
- throw new Error('No closing tag for enum')
- }
- var onoption = function (tokens) {
- var name = null
- var value = null
- var parse = function (value) {
- if (value === 'true') return true
- if (value === 'false') return false
- return value.replace(/^"+|"+$/gm, '')
- }
- while (tokens.length) {
- if (tokens[0] === ';') {
- tokens.shift()
- return {name: name, value: value}
- }
- switch (tokens[0]) {
- case 'option':
- tokens.shift()
- var hasBracket = tokens[0] === '('
- if (hasBracket) tokens.shift()
- name = tokens.shift()
- if (hasBracket) {
- if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
- tokens.shift()
- }
- break
- case '=':
- tokens.shift()
- if (name === null) throw new Error('Expected key for option with value: ' + tokens[0])
- value = parse(tokens.shift())
- if (name === 'optimize_for' && !/^(SPEED|CODE_SIZE|LITE_RUNTIME)$/.test(value)) {
- throw new Error('Unexpected value for option optimize_for: ' + value)
- } else if (value === '{') {
- // option foo = {bar: baz}
- value = onoptionMap(tokens)
- }
- break
- default:
- throw new Error('Unexpected token in option: ' + tokens[0])
- }
- }
- }
- var onoptionMap = function (tokens) {
- var parse = function (value) {
- if (value === 'true') return true
- if (value === 'false') return false
- return value.replace(/^"+|"+$/gm, '')
- }
- var map = {}
- while (tokens.length) {
- if (tokens[0] === '}') {
- tokens.shift()
- return map
- }
- var hasBracket = tokens[0] === '('
- if (hasBracket) tokens.shift()
- var key = tokens.shift()
- if (hasBracket) {
- if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
- tokens.shift()
- }
- var value = null
- switch (tokens[0]) {
- case ':':
- if (map[key] !== undefined) throw new Error('Duplicate option map key ' + key)
- tokens.shift()
- value = parse(tokens.shift())
- if (value === '{') {
- // option foo = {bar: baz}
- value = onoptionMap(tokens)
- }
- map[key] = value
- break
- case '{':
- tokens.shift()
- value = onoptionMap(tokens)
- if (map[key] === undefined) map[key] = []
- if (!Array.isArray(map[key])) throw new Error('Duplicate option map key ' + key)
- map[key].push(value)
- break
- default:
- throw new Error('Unexpected token in option map: ' + tokens[0])
- }
- }
- throw new Error('No closing tag for option map')
- }
- var onimport = function (tokens) {
- tokens.shift()
- var file = tokens.shift().replace(/^"+|"+$/gm, '')
- if (tokens[0] !== ';') throw new Error('Unexpected token: ' + tokens[0] + '. Expected ";"')
- tokens.shift()
- return file
- }
- var onservice = function (tokens) {
- tokens.shift()
- var service = {
- name: tokens.shift(),
- methods: [],
- options: {}
- }
- if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
- tokens.shift()
- while (tokens.length) {
- if (tokens[0] === '}') {
- tokens.shift()
- // there goes optional semicolon after the enclosing "}"
- if (tokens[0] === ';') tokens.shift()
- return service
- }
- switch (tokens[0]) {
- case 'option':
- var opt = onoption(tokens)
- if (service.options[opt.name] !== undefined) throw new Error('Duplicate option ' + opt.name)
- service.options[opt.name] = opt.value
- break
- case 'rpc':
- service.methods.push(onrpc(tokens))
- break
- default:
- throw new Error('Unexpected token in service: ' + tokens[0])
- }
- }
- throw new Error('No closing tag for service')
- }
- var onrpc = function (tokens) {
- tokens.shift()
- var rpc = {
- name: tokens.shift(),
- input_type: null,
- output_type: null,
- client_streaming: false,
- server_streaming: false,
- options: {}
- }
- if (tokens[0] !== '(') throw new Error('Expected ( but found ' + tokens[0])
- tokens.shift()
- if (tokens[0] === 'stream') {
- tokens.shift()
- rpc.client_streaming = true
- }
- rpc.input_type = tokens.shift()
- if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
- tokens.shift()
- if (tokens[0] !== 'returns') throw new Error('Expected returns but found ' + tokens[0])
- tokens.shift()
- if (tokens[0] !== '(') throw new Error('Expected ( but found ' + tokens[0])
- tokens.shift()
- if (tokens[0] === 'stream') {
- tokens.shift()
- rpc.server_streaming = true
- }
- rpc.output_type = tokens.shift()
- if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
- tokens.shift()
- if (tokens[0] === ';') {
- tokens.shift()
- return rpc
- }
- if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
- tokens.shift()
- while (tokens.length) {
- if (tokens[0] === '}') {
- tokens.shift()
- // there goes optional semicolon after the enclosing "}"
- if (tokens[0] === ';') tokens.shift()
- return rpc
- }
- if (tokens[0] === 'option') {
- var opt = onoption(tokens)
- if (rpc.options[opt.name] !== undefined) throw new Error('Duplicate option ' + opt.name)
- rpc.options[opt.name] = opt.value
- } else {
- throw new Error('Unexpected token in rpc options: ' + tokens[0])
- }
- }
- throw new Error('No closing tag for rpc')
- }
- var parse = function (buf) {
- var tokens = tokenize(buf.toString())
- // check for isolated strings in tokens by looking for opening quote
- for (var i = 0; i < tokens.length; i++) {
- if (/^(\"|\')([^\'\"]*)$/.test(tokens[i])) {
- var j
- if (tokens[i].length === 1) {
- j = i + 1
- } else {
- j = i
- }
- // look ahead for the closing quote and collapse all
- // in-between tokens into a single token
- for (j; j < tokens.length; j++) {
- if (/^([^\'\"]*)(\"|\')$/.test(tokens[j])) {
- tokens = tokens.slice(0, i).concat(tokens.slice(i, j + 1).join('')).concat(tokens.slice(j + 1))
- break
- }
- }
- }
- }
- var schema = {
- syntax: 3,
- package: null,
- imports: [],
- enums: [],
- messages: [],
- options: {},
- extends: []
- }
- var firstline = true
- while (tokens.length) {
- switch (tokens[0]) {
- case 'package':
- schema.package = onpackagename(tokens)
- break
- case 'syntax':
- if (!firstline) throw new Error('Protobuf syntax version should be first thing in file')
- schema.syntax = onsyntaxversion(tokens)
- break
- case 'message':
- schema.messages.push(onmessage(tokens))
- break
- case 'enum':
- schema.enums.push(onenum(tokens))
- break
- case 'option':
- var opt = onoption(tokens)
- if (schema.options[opt.name]) throw new Error('Duplicate option ' + opt.name)
- schema.options[opt.name] = opt.value
- break
- case 'import':
- schema.imports.push(onimport(tokens))
- break
- case 'extend':
- schema.extends.push(onextend(tokens))
- break
- case 'service':
- if (!schema.services) schema.services = []
- schema.services.push(onservice(tokens))
- break
- default:
- throw new Error('Unexpected token: ' + tokens[0])
- }
- firstline = false
- }
- // now iterate over messages and propagate extends
- schema.extends.forEach(function (ext) {
- schema.messages.forEach(function (msg) {
- if (msg.name === ext.name) {
- ext.message.fields.forEach(function (field) {
- if (!msg.extensions || field.tag < msg.extensions.from || field.tag > msg.extensions.to) {
- throw new Error(msg.name + ' does not declare ' + field.tag + ' as an extension number')
- }
- msg.fields.push(field)
- })
- }
- })
- })
- return schema
- }
- module.exports = parse
- /***/ },
- /* 537 */
- /***/ function(module, exports) {
- var onfield = function (f, result) {
- var prefix = f.repeated ? 'repeated' : f.required ? 'required' : 'optional'
- if (f.type === 'map') prefix = 'map<' + f.map.from + ',' + f.map.to + '>'
- if (f.oneof) prefix = ''
- var opts = Object.keys(f.options || {}).map(function (key) {
- return key + ' = ' + f.options[key]
- }).join(',')
- if (opts) opts = ' [' + opts + ']'
- result.push((prefix ? prefix + ' ' : '') + (f.map === 'map' ? '' : f.type + ' ') + f.name + ' = ' + f.tag + opts + ';')
- return result
- }
- var onmessage = function (m, result) {
- result.push('message ' + m.name + ' {')
- if (!m.enums) m.enums = []
- m.enums.forEach(function (e) {
- result.push(onenum(e, []))
- })
- if (!m.messages) m.messages = []
- m.messages.forEach(function (m) {
- result.push(onmessage(m, []))
- })
- var oneofs = {}
- if (!m.fields) m.fields = []
- m.fields.forEach(function (f) {
- if (f.oneof) {
- if (!oneofs[f.oneof]) oneofs[f.oneof] = []
- oneofs[f.oneof].push(onfield(f, []))
- } else {
- result.push(onfield(f, []))
- }
- })
- Object.keys(oneofs).forEach(function (n) {
- oneofs[n].unshift('oneof ' + n + ' {')
- oneofs[n].push('}')
- result.push(oneofs[n])
- })
- result.push('}', '')
- return result
- }
- var onenum = function (e, result) {
- result.push('enum ' + e.name + ' {')
- var vals = Object.keys(e.values).map(function (key) {
- return key + ' = ' + e.values[key] + ';'
- })
- result.push(vals)
- result.push('}', '')
- return result
- }
- var onoption = function (o, result) {
- var keys = Object.keys(o)
- keys.forEach(function (option) {
- var v = o[option]
- if (~option.indexOf('.')) option = '(' + option + ')'
- var type = typeof v
- if (type === 'object') {
- v = onoptionMap(v, [])
- if (v.length) result.push('option ' + option + ' = {', v, '};')
- } else {
- if (type === 'string' && option !== 'optimize_for') v = '"' + v + '"'
- result.push('option ' + option + ' = ' + v + ';')
- }
- })
- if (keys.length > 0) {
- result.push('')
- }
- return result
- }
- var onoptionMap = function (o, result) {
- var keys = Object.keys(o)
- keys.forEach(function (k) {
- var v = o[k]
- var type = typeof v
- if (type === 'object') {
- if (Array.isArray(v)) {
- v.forEach(function (v) {
- v = onoptionMap(v, [])
- if (v.length) result.push(k + ' {', v, '}')
- })
- } else {
- v = onoptionMap(v, [])
- if (v.length) result.push(k + ' {', v, '}')
- }
- } else {
- if (type === 'string') v = '"' + v + '"'
- result.push(k + ': ' + v)
- }
- })
- return result
- }
- var onservices = function (s, result) {
- result.push('service ' + s.name + ' {')
- if (!s.options) s.options = {}
- onoption(s.options, result)
- if (!s.methods) s.methods = []
- s.methods.forEach(function (m) {
- result.push(onrpc(m, []))
- })
- result.push('}', '')
- return result
- }
- var onrpc = function (rpc, result) {
- var def = 'rpc ' + rpc.name + '('
- if (rpc.client_streaming) def += 'stream '
- def += rpc.input_type + ') returns ('
- if (rpc.server_streaming) def += 'stream '
- def += rpc.output_type + ')'
- if (!rpc.options) rpc.options = {}
- var options = onoption(rpc.options, [])
- if (options.length > 1) {
- result.push(def + ' {', options.slice(0, -1), '}')
- } else {
- result.push(def + ';')
- }
- return result
- }
- var indent = function (lvl) {
- return function (line) {
- if (Array.isArray(line)) return line.map(indent(lvl + ' ')).join('\n')
- return lvl + line
- }
- }
- module.exports = function (schema) {
- var result = []
- result.push('syntax = "proto' + schema.syntax + '";', '')
- if (schema.package) result.push('package ' + schema.package + ';', '')
- if (!schema.options) schema.options = {}
- onoption(schema.options, result)
- if (!schema.enums) schema.enums = []
- schema.enums.forEach(function (e) {
- onenum(e, result)
- })
- if (!schema.messages) schema.messages = []
- schema.messages.forEach(function (m) {
- onmessage(m, result)
- })
- if (schema.services) {
- schema.services.forEach(function (s) {
- onservices(s, result)
- })
- }
- return result.map(indent('')).join('\n')
- }
- /***/ },
- /* 538 */
- /***/ function(module, exports) {
- module.exports = function (sch) {
- var noComments = function (line) {
- var i = line.indexOf('//')
- return i > -1 ? line.slice(0, i) : line
- }
- var noMultilineComments = function () {
- var inside = false
- return function (token) {
- if (token === '/*') {
- inside = true
- return false
- }
- if (token === '*/') {
- inside = false
- return false
- }
- return !inside
- }
- }
- var trim = function (line) {
- return line.trim()
- }
- return sch
- .replace(/([;,{}\(\)=\:\[\]<>]|\/\*|\*\/)/g, ' $1 ')
- .split(/\n/)
- .map(trim)
- .filter(Boolean)
- .map(noComments)
- .map(trim)
- .filter(Boolean)
- .join('\n')
- .split(/\s+|\n+/gm)
- .filter(noMultilineComments())
- }
- /***/ },
- /* 539 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/* eslint-disable no-spaced-func */
- /* eslint-disable no-unexpected-multiline */
- var encodings = __webpack_require__(540)
- var varint = __webpack_require__(75)
- var genobj = __webpack_require__(503)
- var genfun = __webpack_require__(502)
- var skip = function (type, buffer, offset) {
- switch (type) {
- case 0:
- varint.decode(buffer, offset)
- return offset + varint.decode.bytes
- case 1:
- return offset + 8
- case 2:
- var len = varint.decode(buffer, offset)
- return offset + varint.decode.bytes + len
- case 3:
- case 4:
- throw new Error('Groups are not supported')
- case 5:
- return offset + 4
- }
- throw new Error('Unknown wire type: ' + type)
- }
- var defined = function (val) {
- return val !== null && val !== undefined && (typeof val !== 'number' || !isNaN(val))
- }
- var isString = function (def) {
- try {
- return !!def && typeof JSON.parse(def) === 'string'
- } catch (err) {
- return false
- }
- }
- var defaultValue = function (f, def) {
- if (f.map) return '{}'
- if (f.repeated) return '[]'
- switch (f.type) {
- case 'string':
- return isString(def) ? def : '""'
- case 'bool':
- if (def === 'true') return 'true'
- return 'false'
- case 'float':
- case 'double':
- case 'sfixed32':
- case 'fixed32':
- case 'varint':
- case 'enum':
- case 'uint64':
- case 'uint32':
- case 'int64':
- case 'int32':
- case 'sint64':
- case 'sint32':
- return '' + Number(def || 0)
- default:
- return 'null'
- }
- }
- module.exports = function (schema, extraEncodings) {
- var messages = {}
- var enums = {}
- var cache = {}
- var visit = function (schema, prefix) {
- if (schema.enums) {
- schema.enums.forEach(function (e) {
- e.id = prefix + (prefix ? '.' : '') + e.name
- enums[e.id] = e
- visit(e, e.id)
- })
- }
- if (schema.messages) {
- schema.messages.forEach(function (m) {
- m.id = prefix + (prefix ? '.' : '') + m.name
- messages[m.id] = m
- m.fields.forEach(function (f) {
- if (!f.map) return
- var name = 'Map_' + f.map.from + '_' + f.map.to
- var map = {
- name: name,
- enums: [],
- messages: [],
- fields: [{
- name: 'key',
- type: f.map.from,
- tag: 1,
- repeated: false,
- required: true
- }, {
- name: 'value',
- type: f.map.to,
- tag: 2,
- repeated: false,
- required: false
- }],
- extensions: null,
- id: prefix + (prefix ? '.' : '') + name
- }
- if (!messages[map.id]) {
- messages[map.id] = map
- schema.messages.push(map)
- }
- f.type = name
- f.repeated = true
- })
- visit(m, m.id)
- })
- }
- }
- visit(schema, '')
- var compileEnum = function (e) {
- var conditions = Object.keys(e.values)
- .map(function (k) {
- return 'val !== ' + parseInt(e.values[k], 10)
- })
- .join(' && ')
- if (!conditions) conditions = 'true'
- var encode = genfun()
- ('function encode (val, buf, offset) {')
- ('if (%s) throw new Error("Invalid enum value: "+val)', conditions)
- ('varint.encode(val, buf, offset)')
- ('encode.bytes = varint.encode.bytes')
- ('return buf')
- ('}')
- .toFunction({
- varint: varint
- })
- var decode = genfun()
- ('function decode (buf, offset) {')
- ('var val = varint.decode(buf, offset)')
- ('if (%s) throw new Error("Invalid enum value: "+val)', conditions)
- ('decode.bytes = varint.decode.bytes')
- ('return val')
- ('}')
- .toFunction({
- varint: varint
- })
- return encodings.make(0, encode, decode, varint.encodingLength)
- }
- var compileMessage = function (m, exports) {
- m.messages.forEach(function (nested) {
- exports[nested.name] = resolve(nested.name, m.id)
- })
- m.enums.forEach(function (val) {
- exports[val.name] = val.values
- })
- exports.type = 2
- exports.message = true
- exports.name = m.name
- var oneofs = {}
- m.fields.forEach(function (f) {
- if (!f.oneof) return
- if (!oneofs[f.oneof]) oneofs[f.oneof] = []
- oneofs[f.oneof].push(f.name)
- })
- var enc = m.fields.map(function (f) {
- return resolve(f.type, m.id)
- })
- var forEach = function (fn) {
- for (var i = 0; i < enc.length; i++) fn(enc[i], m.fields[i], genobj('obj', m.fields[i].name), i)
- }
- // compile encodingLength
- var encodingLength = genfun()
- ('function encodingLength (obj) {')
- ('var length = 0')
- Object.keys(oneofs).forEach(function (name) {
- var msg = JSON.stringify('only one of the properties defined in oneof ' + name + ' can be set')
- var cnt = oneofs[name]
- .map(function (prop) {
- return '+defined(' + genobj('obj', prop) + ')'
- })
- .join(' + ')
- encodingLength('if ((%s) > 1) throw new Error(%s)', cnt, msg)
- })
- forEach(function (e, f, val, i) {
- var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
- var hl = varint.encodingLength(f.tag << 3 | e.type)
- if (f.required) encodingLength('if (!defined(%s)) throw new Error(%s)', val, JSON.stringify(f.name + ' is required'))
- else encodingLength('if (defined(%s)) {', val)
- if (f.map) {
- encodingLength()
- ('var tmp = Object.keys(%s)', val)
- ('for (var i = 0; i < tmp.length; i++) {')
- ('tmp[i] = {key: tmp[i], value: %s[tmp[i]]}', val)
- ('}')
- val = 'tmp'
- }
- if (packed) {
- encodingLength()
- ('var packedLen = 0')
- ('for (var i = 0; i < %s.length; i++) {', val)
- ('if (!defined(%s)) continue', val + '[i]')
- ('var len = enc[%d].encodingLength(%s)', i, val + '[i]')
- ('packedLen += len')
- if (e.message) encodingLength('packedLen += varint.encodingLength(len)')
- encodingLength('}')
- ('if (packedLen) {')
- ('length += %d + packedLen + varint.encodingLength(packedLen)', hl)
- ('}')
- } else {
- if (f.repeated) {
- encodingLength('for (var i = 0; i < %s.length; i++) {', val)
- val += '[i]'
- encodingLength('if (!defined(%s)) continue', val)
- }
- encodingLength('var len = enc[%d].encodingLength(%s)', i, val)
- if (e.message) encodingLength('length += varint.encodingLength(len)')
- encodingLength('length += %d + len', hl)
- if (f.repeated) encodingLength('}')
- }
- if (!f.required) encodingLength('}')
- })
- encodingLength()
- ('return length')
- ('}')
- encodingLength = encodingLength.toFunction({
- defined: defined,
- varint: varint,
- enc: enc
- })
- // compile encode
- var encode = genfun()
- ('function encode (obj, buf, offset) {')
- ('if (!offset) offset = 0')
- ('if (!buf) buf = new Buffer(encodingLength(obj))')
- ('var oldOffset = offset')
- Object.keys(oneofs).forEach(function (name) {
- var msg = JSON.stringify('only one of the properties defined in oneof ' + name + ' can be set')
- var cnt = oneofs[name]
- .map(function (prop) {
- return '+defined(' + genobj('obj', prop) + ')'
- })
- .join(' + ')
- encode('if ((%s) > 1) throw new Error(%s)', cnt, msg)
- })
- forEach(function (e, f, val, i) {
- if (f.required) encode('if (!defined(%s)) throw new Error(%s)', val, JSON.stringify(f.name + ' is required'))
- else encode('if (defined(%s)) {', val)
- var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
- var p = varint.encode(f.tag << 3 | 2)
- var h = varint.encode(f.tag << 3 | e.type)
- var j
- if (f.map) {
- encode()
- ('var tmp = Object.keys(%s)', val)
- ('for (var i = 0; i < tmp.length; i++) {')
- ('tmp[i] = {key: tmp[i], value: %s[tmp[i]]}', val)
- ('}')
- val = 'tmp'
- }
- if (packed) {
- encode()
- ('var packedLen = 0')
- ('for (var i = 0; i < %s.length; i++) {', val)
- ('if (!defined(%s)) continue', val + '[i]')
- ('packedLen += enc[%d].encodingLength(%s)', i, val + '[i]')
- ('}')
- encode('if (packedLen) {')
- for (j = 0; j < h.length; j++) encode('buf[offset++] = %d', p[j])
- encode('varint.encode(packedLen, buf, offset)')
- encode('offset += varint.encode.bytes')
- encode('}')
- }
- if (f.repeated) {
- encode('for (var i = 0; i < %s.length; i++) {', val)
- val += '[i]'
- encode('if (!defined(%s)) continue', val)
- }
- if (!packed) for (j = 0; j < h.length; j++) encode('buf[offset++] = %d', h[j])
- if (e.message) {
- encode('varint.encode(enc[%d].encodingLength(%s), buf, offset)', i, val)
- encode('offset += varint.encode.bytes')
- }
- encode('enc[%d].encode(%s, buf, offset)', i, val)
- encode('offset += enc[%d].encode.bytes', i)
- if (f.repeated) encode('}')
- if (!f.required) encode('}')
- })
- encode()
- ('encode.bytes = offset - oldOffset')
- ('return buf')
- ('}')
- encode = encode.toFunction({
- encodingLength: encodingLength,
- defined: defined,
- varint: varint,
- enc: enc,
- Buffer: Buffer
- })
- // compile decode
- var invalid = m.fields
- .map(function (f, i) {
- return f.required && '!found' + i
- })
- .filter(function (f) {
- return f
- })
- .join(' || ')
- var decode = genfun()
- var objectKeys = []
- forEach(function (e, f) {
- var def = f.options && f.options.default
- var resolved = resolve(f.type, m.id, false)
- var vals = resolved && resolved.values
- if (vals) { // is enum
- if (f.repeated) {
- objectKeys.push(genobj.property(f.name) + ': []')
- } else {
- def = (def && def in vals) ? vals[def] : vals[Object.keys(vals)[0]]
- objectKeys.push(genobj.property(f.name) + ': ' + parseInt(def || 0, 10))
- }
- return
- }
- if (!f.oneof) {
- objectKeys.push(genobj.property(f.name) + ': ' + defaultValue(f, def))
- }
- })
- decode()
- ('function decode (buf, offset, end) {')
- ('if (!offset) offset = 0')
- ('if (!end) end = buf.length')
- ('if (!(end <= buf.length && offset <= buf.length)) throw new Error("Decoded message is not valid")')
- ('var oldOffset = offset')
- ('var obj = {')
- objectKeys.forEach(function (prop, i) {
- decode(prop + (i === objectKeys.length - 1 ? '' : ','))
- })
- decode('}')
- forEach(function (e, f, val, i) {
- if (f.required) decode('var found%d = false', i)
- })
- decode('while (true) {')
- ('if (end <= offset) {')
- (invalid && 'if (%s) throw new Error("Decoded message is not valid")', invalid)
- ('decode.bytes = offset - oldOffset')
- ('return obj')
- ('}')
- ('var prefix = varint.decode(buf, offset)')
- ('offset += varint.decode.bytes')
- ('var tag = prefix >> 3')
- ('switch (tag) {')
- forEach(function (e, f, val, i) {
- var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
- decode('case %d:', f.tag)
- if (f.oneof) {
- m.fields.forEach(function (otherField) {
- if (otherField.oneof === f.oneof && f.name !== otherField.name) {
- decode('delete %s', genobj('obj', otherField.name))
- }
- })
- }
- if (packed) {
- decode()
- ('var packedEnd = varint.decode(buf, offset)')
- ('offset += varint.decode.bytes')
- ('packedEnd += offset')
- ('while (offset < packedEnd) {')
- }
- if (e.message) {
- decode('var len = varint.decode(buf, offset)')
- decode('offset += varint.decode.bytes')
- if (f.map) {
- decode('var tmp = enc[%d].decode(buf, offset, offset + len)', i)
- decode('%s[tmp.key] = tmp.value', val)
- } else if (f.repeated) {
- decode('%s.push(enc[%d].decode(buf, offset, offset + len))', val, i)
- } else {
- decode('%s = enc[%d].decode(buf, offset, offset + len)', val, i)
- }
- } else {
- if (f.repeated) {
- decode('%s.push(enc[%d].decode(buf, offset))', val, i)
- } else {
- decode('%s = enc[%d].decode(buf, offset)', val, i)
- }
- }
- decode('offset += enc[%d].decode.bytes', i)
- if (packed) decode('}')
- if (f.required) decode('found%d = true', i)
- decode('break')
- })
- decode()
- ('default:')
- ('offset = skip(prefix & 7, buf, offset)')
- ('}')
- ('}')
- ('}')
- decode = decode.toFunction({
- varint: varint,
- skip: skip,
- enc: enc
- })
- // end of compilation - return all the things
- encode.bytes = decode.bytes = 0
- exports.buffer = true
- exports.encode = encode
- exports.decode = decode
- exports.encodingLength = encodingLength
- return exports
- }
- var resolve = function (name, from, compile) {
- if (extraEncodings && extraEncodings[name]) return extraEncodings[name]
- if (encodings[name]) return encodings[name]
- var m = (from ? from + '.' + name : name).split('.')
- .map(function (part, i, list) {
- return list.slice(0, i).concat(name).join('.')
- })
- .reverse()
- .reduce(function (result, id) {
- return result || messages[id] || enums[id]
- }, null)
- if (compile === false) return m
- if (!m) throw new Error('Could not resolve ' + name)
- if (m.values) return compileEnum(m)
- return cache[m.id] || compileMessage(m, cache[m.id] = {})
- }
- return (schema.enums || []).concat((schema.messages || []).map(function (message) {
- return resolve(message.id)
- }))
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 540 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var varint = __webpack_require__(75)
- var svarint = __webpack_require__(561)
- var encoder = function (type, encode, decode, encodingLength) {
- encode.bytes = decode.bytes = 0
- return {
- type: type,
- encode: encode,
- decode: decode,
- encodingLength: encodingLength
- }
- }
- exports.make = encoder
- exports.bytes = (function (tag) {
- var bufferLength = function (val) {
- return Buffer.isBuffer(val) ? val.length : Buffer.byteLength(val)
- }
- var encodingLength = function (val) {
- var len = bufferLength(val)
- return varint.encodingLength(len) + len
- }
- var encode = function (val, buffer, offset) {
- var oldOffset = offset
- var len = bufferLength(val)
- varint.encode(len, buffer, offset)
- offset += varint.encode.bytes
- if (Buffer.isBuffer(val)) val.copy(buffer, offset)
- else buffer.write(val, offset, len)
- offset += len
- encode.bytes = offset - oldOffset
- return buffer
- }
- var decode = function (buffer, offset) {
- var oldOffset = offset
- var len = varint.decode(buffer, offset)
- offset += varint.decode.bytes
- var val = buffer.slice(offset, offset + len)
- offset += val.length
- decode.bytes = offset - oldOffset
- return val
- }
- return encoder(2, encode, decode, encodingLength)
- })()
- exports.string = (function () {
- var encodingLength = function (val) {
- var len = Buffer.byteLength(val)
- return varint.encodingLength(len) + len
- }
- var encode = function (val, buffer, offset) {
- var oldOffset = offset
- var len = Buffer.byteLength(val)
- varint.encode(len, buffer, offset, 'utf-8')
- offset += varint.encode.bytes
- buffer.write(val, offset, len)
- offset += len
- encode.bytes = offset - oldOffset
- return buffer
- }
- var decode = function (buffer, offset) {
- var oldOffset = offset
- var len = varint.decode(buffer, offset)
- offset += varint.decode.bytes
- var val = buffer.toString('utf-8', offset, offset + len)
- offset += len
- decode.bytes = offset - oldOffset
- return val
- }
- return encoder(2, encode, decode, encodingLength)
- })()
- exports.bool = (function () {
- var encodingLength = function (val) {
- return 1
- }
- var encode = function (val, buffer, offset) {
- buffer[offset] = val ? 1 : 0
- encode.bytes = 1
- return buffer
- }
- var decode = function (buffer, offset) {
- var bool = buffer[offset] > 0
- decode.bytes = 1
- return bool
- }
- return encoder(0, encode, decode, encodingLength)
- })()
- exports.int32 = (function () {
- var decode = function (buffer, offset) {
- var val = varint.decode(buffer, offset)
- decode.bytes = varint.decode.bytes
- return val > 2147483647 ? val - 4294967296 : val
- }
- var encode = function (val, buffer, offset) {
- varint.encode(val < 0 ? val + 4294967296 : val, buffer, offset)
- encode.bytes = varint.encode.bytes
- return buffer
- }
- var encodingLength = function (val) {
- return varint.encodingLength(val < 0 ? val + 4294967296 : val)
- }
- return encoder(0, varint.encode, decode, encodingLength)
- })()
- exports.int64 = (function () {
- var decode = function (buffer, offset) {
- var val = varint.decode(buffer, offset)
- if (val >= Math.pow(2, 63)) {
- var limit = 9
- while (buffer[offset + limit - 1] === 0xff) limit--
- limit = limit || 9
- var subset = new Buffer(limit)
- buffer.copy(subset, 0, offset, offset + limit)
- subset[limit - 1] = subset[limit - 1] & 0x7f
- val = -1 * varint.decode(subset, 0)
- decode.bytes = 10
- } else {
- decode.bytes = varint.decode.bytes
- }
- return val
- }
- var encode = function (val, buffer, offset) {
- if (val < 0) {
- var last = offset + 9
- varint.encode(val * -1, buffer, offset)
- offset += varint.encode.bytes - 1
- buffer[offset] = buffer[offset] | 0x80
- while (offset < last - 1) {
- offset++
- buffer[offset] = 0xff
- }
- buffer[last] = 0x01
- encode.bytes = 10
- } else {
- varint.encode(val, buffer, offset)
- encode.bytes = varint.encode.bytes
- }
- return buffer
- }
- var encodingLength = function (val) {
- return val < 0 ? 10 : varint.encodingLength(val)
- }
- return encoder(0, encode, decode, encodingLength)
- })()
- exports.sint32 =
- exports.sint64 = (function () {
- return encoder(0, svarint.encode, svarint.decode, svarint.encodingLength)
- })()
- exports.uint32 =
- exports.uint64 =
- exports.enum =
- exports.varint = (function () {
- return encoder(0, varint.encode, varint.decode, varint.encodingLength)
- })()
- // we cannot represent these in javascript so we just use buffers
- exports.fixed64 =
- exports.sfixed64 = (function () {
- var encodingLength = function (val) {
- return 8
- }
- var encode = function (val, buffer, offset) {
- val.copy(buffer, offset)
- encode.bytes = 8
- return buffer
- }
- var decode = function (buffer, offset) {
- var val = buffer.slice(offset, offset + 8)
- decode.bytes = 8
- return val
- }
- return encoder(1, encode, decode, encodingLength)
- })()
- exports.double = (function () {
- var encodingLength = function (val) {
- return 8
- }
- var encode = function (val, buffer, offset) {
- buffer.writeDoubleLE(val, offset)
- encode.bytes = 8
- return buffer
- }
- var decode = function (buffer, offset) {
- var val = buffer.readDoubleLE(offset)
- decode.bytes = 8
- return val
- }
- return encoder(1, encode, decode, encodingLength)
- })()
- exports.fixed32 = (function () {
- var encodingLength = function (val) {
- return 4
- }
- var encode = function (val, buffer, offset) {
- buffer.writeUInt32LE(val, offset)
- encode.bytes = 4
- return buffer
- }
- var decode = function (buffer, offset) {
- var val = buffer.readUInt32LE(offset)
- decode.bytes = 4
- return val
- }
- return encoder(5, encode, decode, encodingLength)
- })()
- exports.sfixed32 = (function () {
- var encodingLength = function (val) {
- return 4
- }
- var encode = function (val, buffer, offset) {
- buffer.writeInt32LE(val, offset)
- encode.bytes = 4
- return buffer
- }
- var decode = function (buffer, offset) {
- var val = buffer.readInt32LE(offset)
- decode.bytes = 4
- return val
- }
- return encoder(5, encode, decode, encodingLength)
- })()
- exports.float = (function () {
- var encodingLength = function (val) {
- return 4
- }
- var encode = function (val, buffer, offset) {
- buffer.writeFloatLE(val, offset)
- encode.bytes = 4
- return buffer
- }
- var decode = function (buffer, offset) {
- var val = buffer.readFloatLE(offset)
- decode.bytes = 4
- return val
- }
- return encoder(5, encode, decode, encodingLength)
- })()
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 541 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var schema = __webpack_require__(535)
- var compile = __webpack_require__(539)
- module.exports = function (proto, opts) {
- if (!opts) opts = {}
- if (!proto) throw new Error('Pass in a .proto string or a protobuf-schema parsed object')
- var sch = (typeof proto === 'object' && !Buffer.isBuffer(proto)) ? proto : schema.parse(proto)
- // to not make toString,toJSON enumarable we make a fire-and-forget prototype
- var Messages = function () {
- var self = this
- compile(sch, opts.encodings || {}).forEach(function (m) {
- self[m.name] = m.values || m
- })
- }
- Messages.prototype.toString = function () {
- return schema.stringify(sch)
- }
- Messages.prototype.toJSON = function () {
- return sch
- }
- return new Messages()
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 542 */
- /***/ function(module, exports, __webpack_require__) {
- exports.publicEncrypt = __webpack_require__(544);
- exports.privateDecrypt = __webpack_require__(543);
- exports.privateEncrypt = function privateEncrypt(key, buf) {
- return exports.publicEncrypt(key, buf, true);
- };
- exports.publicDecrypt = function publicDecrypt(key, buf) {
- return exports.privateDecrypt(key, buf, true);
- };
- /***/ },
- /* 543 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(97);
- var mgf = __webpack_require__(211);
- var xor = __webpack_require__(213);
- var bn = __webpack_require__(12);
- var crt = __webpack_require__(103);
- var createHash = __webpack_require__(63);
- var withPublic = __webpack_require__(212);
- module.exports = function privateDecrypt(private_key, enc, reverse) {
- var padding;
- if (private_key.padding) {
- padding = private_key.padding;
- } else if (reverse) {
- padding = 1;
- } else {
- padding = 4;
- }
-
- var key = parseKeys(private_key);
- var k = key.modulus.byteLength();
- if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
- throw new Error('decryption error');
- }
- var msg;
- if (reverse) {
- msg = withPublic(new bn(enc), key);
- } else {
- msg = crt(enc, key);
- }
- var zBuffer = new Buffer(k - msg.length);
- zBuffer.fill(0);
- msg = Buffer.concat([zBuffer, msg], k);
- if (padding === 4) {
- return oaep(key, msg);
- } else if (padding === 1) {
- return pkcs1(key, msg, reverse);
- } else if (padding === 3) {
- return msg;
- } else {
- throw new Error('unknown padding');
- }
- };
- function oaep(key, msg){
- var n = key.modulus;
- var k = key.modulus.byteLength();
- var mLen = msg.length;
- var iHash = createHash('sha1').update(new Buffer('')).digest();
- var hLen = iHash.length;
- var hLen2 = 2 * hLen;
- if (msg[0] !== 0) {
- throw new Error('decryption error');
- }
- var maskedSeed = msg.slice(1, hLen + 1);
- var maskedDb = msg.slice(hLen + 1);
- var seed = xor(maskedSeed, mgf(maskedDb, hLen));
- var db = xor(maskedDb, mgf(seed, k - hLen - 1));
- if (compare(iHash, db.slice(0, hLen))) {
- throw new Error('decryption error');
- }
- var i = hLen;
- while (db[i] === 0) {
- i++;
- }
- if (db[i++] !== 1) {
- throw new Error('decryption error');
- }
- return db.slice(i);
- }
- function pkcs1(key, msg, reverse){
- var p1 = msg.slice(0, 2);
- var i = 2;
- var status = 0;
- while (msg[i++] !== 0) {
- if (i >= msg.length) {
- status++;
- break;
- }
- }
- var ps = msg.slice(2, i - 1);
- var p2 = msg.slice(i - 1, i);
- if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
- status++;
- }
- if (ps.length < 8) {
- status++;
- }
- if (status) {
- throw new Error('decryption error');
- }
- return msg.slice(i);
- }
- function compare(a, b){
- a = new Buffer(a);
- b = new Buffer(b);
- var dif = 0;
- var len = a.length;
- if (a.length !== b.length) {
- dif++;
- len = Math.min(a.length, b.length);
- }
- var i = -1;
- while (++i < len) {
- dif += (a[i] ^ b[i]);
- }
- return dif;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 544 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(97);
- var randomBytes = __webpack_require__(73);
- var createHash = __webpack_require__(63);
- var mgf = __webpack_require__(211);
- var xor = __webpack_require__(213);
- var bn = __webpack_require__(12);
- var withPublic = __webpack_require__(212);
- var crt = __webpack_require__(103);
- var constants = {
- RSA_PKCS1_OAEP_PADDING: 4,
- RSA_PKCS1_PADDIN: 1,
- RSA_NO_PADDING: 3
- };
- module.exports = function publicEncrypt(public_key, msg, reverse) {
- var padding;
- if (public_key.padding) {
- padding = public_key.padding;
- } else if (reverse) {
- padding = 1;
- } else {
- padding = 4;
- }
- var key = parseKeys(public_key);
- var paddedMsg;
- if (padding === 4) {
- paddedMsg = oaep(key, msg);
- } else if (padding === 1) {
- paddedMsg = pkcs1(key, msg, reverse);
- } else if (padding === 3) {
- paddedMsg = new bn(msg);
- if (paddedMsg.cmp(key.modulus) >= 0) {
- throw new Error('data too long for modulus');
- }
- } else {
- throw new Error('unknown padding');
- }
- if (reverse) {
- return crt(paddedMsg, key);
- } else {
- return withPublic(paddedMsg, key);
- }
- };
- function oaep(key, msg){
- var k = key.modulus.byteLength();
- var mLen = msg.length;
- var iHash = createHash('sha1').update(new Buffer('')).digest();
- var hLen = iHash.length;
- var hLen2 = 2 * hLen;
- if (mLen > k - hLen2 - 2) {
- throw new Error('message too long');
- }
- var ps = new Buffer(k - mLen - hLen2 - 2);
- ps.fill(0);
- var dblen = k - hLen - 1;
- var seed = randomBytes(hLen);
- var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
- var maskedSeed = xor(seed, mgf(maskedDb, hLen));
- return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
- }
- function pkcs1(key, msg, reverse){
- var mLen = msg.length;
- var k = key.modulus.byteLength();
- if (mLen > k - 11) {
- throw new Error('message too long');
- }
- var ps;
- if (reverse) {
- ps = new Buffer(k - mLen - 3);
- ps.fill(0xff);
- } else {
- ps = nonZero(k - mLen - 3);
- }
- return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
- }
- function nonZero(len, crypto) {
- var out = new Buffer(len);
- var i = 0;
- var cache = randomBytes(len*2);
- var cur = 0;
- var num;
- while (i < len) {
- if (cur === cache.length) {
- cache = randomBytes(len*2);
- cur = 0;
- }
- num = cache[cur++];
- if (num) {
- out[i++] = num;
- }
- }
- return out;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 545 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
- ;(function(root) {
- /** Detect free variables */
- var freeExports = typeof exports == 'object' && exports &&
- !exports.nodeType && exports;
- var freeModule = typeof module == 'object' && module &&
- !module.nodeType && module;
- var freeGlobal = typeof global == 'object' && global;
- if (
- freeGlobal.global === freeGlobal ||
- freeGlobal.window === freeGlobal ||
- freeGlobal.self === freeGlobal
- ) {
- root = freeGlobal;
- }
- /**
- * The `punycode` object.
- * @name punycode
- * @type Object
- */
- var punycode,
- /** Highest positive signed 32-bit float value */
- maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
- /** Bootstring parameters */
- base = 36,
- tMin = 1,
- tMax = 26,
- skew = 38,
- damp = 700,
- initialBias = 72,
- initialN = 128, // 0x80
- delimiter = '-', // '\x2D'
- /** Regular expressions */
- regexPunycode = /^xn--/,
- regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
- regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
- /** Error messages */
- errors = {
- 'overflow': 'Overflow: input needs wider integers to process',
- 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
- 'invalid-input': 'Invalid input'
- },
- /** Convenience shortcuts */
- baseMinusTMin = base - tMin,
- floor = Math.floor,
- stringFromCharCode = String.fromCharCode,
- /** Temporary variable */
- key;
- /*--------------------------------------------------------------------------*/
- /**
- * A generic error utility function.
- * @private
- * @param {String} type The error type.
- * @returns {Error} Throws a `RangeError` with the applicable error message.
- */
- function error(type) {
- throw new RangeError(errors[type]);
- }
- /**
- * A generic `Array#map` utility function.
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} callback The function that gets called for every array
- * item.
- * @returns {Array} A new array of values returned by the callback function.
- */
- function map(array, fn) {
- var length = array.length;
- var result = [];
- while (length--) {
- result[length] = fn(array[length]);
- }
- return result;
- }
- /**
- * A simple `Array#map`-like wrapper to work with domain name strings or email
- * addresses.
- * @private
- * @param {String} domain The domain name or email address.
- * @param {Function} callback The function that gets called for every
- * character.
- * @returns {Array} A new string of characters returned by the callback
- * function.
- */
- function mapDomain(string, fn) {
- var parts = string.split('@');
- var result = '';
- if (parts.length > 1) {
- // In email addresses, only the domain name should be punycoded. Leave
- // the local part (i.e. everything up to `@`) intact.
- result = parts[0] + '@';
- string = parts[1];
- }
- // Avoid `split(regex)` for IE8 compatibility. See #17.
- string = string.replace(regexSeparators, '\x2E');
- var labels = string.split('.');
- var encoded = map(labels, fn).join('.');
- return result + encoded;
- }
- /**
- * Creates an array containing the numeric code points of each Unicode
- * character in the string. While JavaScript uses UCS-2 internally,
- * this function will convert a pair of surrogate halves (each of which
- * UCS-2 exposes as separate characters) into a single code point,
- * matching UTF-16.
- * @see `punycode.ucs2.encode`
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
- * @memberOf punycode.ucs2
- * @name decode
- * @param {String} string The Unicode input string (UCS-2).
- * @returns {Array} The new array of code points.
- */
- function ucs2decode(string) {
- var output = [],
- counter = 0,
- length = string.length,
- value,
- extra;
- while (counter < length) {
- value = string.charCodeAt(counter++);
- if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
- // high surrogate, and there is a next character
- extra = string.charCodeAt(counter++);
- if ((extra & 0xFC00) == 0xDC00) { // low surrogate
- output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
- } else {
- // unmatched surrogate; only append this code unit, in case the next
- // code unit is the high surrogate of a surrogate pair
- output.push(value);
- counter--;
- }
- } else {
- output.push(value);
- }
- }
- return output;
- }
- /**
- * Creates a string based on an array of numeric code points.
- * @see `punycode.ucs2.decode`
- * @memberOf punycode.ucs2
- * @name encode
- * @param {Array} codePoints The array of numeric code points.
- * @returns {String} The new Unicode string (UCS-2).
- */
- function ucs2encode(array) {
- return map(array, function(value) {
- var output = '';
- if (value > 0xFFFF) {
- value -= 0x10000;
- output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
- value = 0xDC00 | value & 0x3FF;
- }
- output += stringFromCharCode(value);
- return output;
- }).join('');
- }
- /**
- * Converts a basic code point into a digit/integer.
- * @see `digitToBasic()`
- * @private
- * @param {Number} codePoint The basic numeric code point value.
- * @returns {Number} The numeric value of a basic code point (for use in
- * representing integers) in the range `0` to `base - 1`, or `base` if
- * the code point does not represent a value.
- */
- function basicToDigit(codePoint) {
- if (codePoint - 48 < 10) {
- return codePoint - 22;
- }
- if (codePoint - 65 < 26) {
- return codePoint - 65;
- }
- if (codePoint - 97 < 26) {
- return codePoint - 97;
- }
- return base;
- }
- /**
- * Converts a digit/integer into a basic code point.
- * @see `basicToDigit()`
- * @private
- * @param {Number} digit The numeric value of a basic code point.
- * @returns {Number} The basic code point whose value (when used for
- * representing integers) is `digit`, which needs to be in the range
- * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
- * used; else, the lowercase form is used. The behavior is undefined
- * if `flag` is non-zero and `digit` has no uppercase form.
- */
- function digitToBasic(digit, flag) {
- // 0..25 map to ASCII a..z or A..Z
- // 26..35 map to ASCII 0..9
- return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
- }
- /**
- * Bias adaptation function as per section 3.4 of RFC 3492.
- * https://tools.ietf.org/html/rfc3492#section-3.4
- * @private
- */
- function adapt(delta, numPoints, firstTime) {
- var k = 0;
- delta = firstTime ? floor(delta / damp) : delta >> 1;
- delta += floor(delta / numPoints);
- for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
- delta = floor(delta / baseMinusTMin);
- }
- return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
- }
- /**
- * Converts a Punycode string of ASCII-only symbols to a string of Unicode
- * symbols.
- * @memberOf punycode
- * @param {String} input The Punycode string of ASCII-only symbols.
- * @returns {String} The resulting string of Unicode symbols.
- */
- function decode(input) {
- // Don't use UCS-2
- var output = [],
- inputLength = input.length,
- out,
- i = 0,
- n = initialN,
- bias = initialBias,
- basic,
- j,
- index,
- oldi,
- w,
- k,
- digit,
- t,
- /** Cached calculation results */
- baseMinusT;
- // Handle the basic code points: let `basic` be the number of input code
- // points before the last delimiter, or `0` if there is none, then copy
- // the first basic code points to the output.
- basic = input.lastIndexOf(delimiter);
- if (basic < 0) {
- basic = 0;
- }
- for (j = 0; j < basic; ++j) {
- // if it's not a basic code point
- if (input.charCodeAt(j) >= 0x80) {
- error('not-basic');
- }
- output.push(input.charCodeAt(j));
- }
- // Main decoding loop: start just after the last delimiter if any basic code
- // points were copied; start at the beginning otherwise.
- for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
- // `index` is the index of the next character to be consumed.
- // Decode a generalized variable-length integer into `delta`,
- // which gets added to `i`. The overflow checking is easier
- // if we increase `i` as we go, then subtract off its starting
- // value at the end to obtain `delta`.
- for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
- if (index >= inputLength) {
- error('invalid-input');
- }
- digit = basicToDigit(input.charCodeAt(index++));
- if (digit >= base || digit > floor((maxInt - i) / w)) {
- error('overflow');
- }
- i += digit * w;
- t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
- if (digit < t) {
- break;
- }
- baseMinusT = base - t;
- if (w > floor(maxInt / baseMinusT)) {
- error('overflow');
- }
- w *= baseMinusT;
- }
- out = output.length + 1;
- bias = adapt(i - oldi, out, oldi == 0);
- // `i` was supposed to wrap around from `out` to `0`,
- // incrementing `n` each time, so we'll fix that now:
- if (floor(i / out) > maxInt - n) {
- error('overflow');
- }
- n += floor(i / out);
- i %= out;
- // Insert `n` at position `i` of the output
- output.splice(i++, 0, n);
- }
- return ucs2encode(output);
- }
- /**
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
- * Punycode string of ASCII-only symbols.
- * @memberOf punycode
- * @param {String} input The string of Unicode symbols.
- * @returns {String} The resulting Punycode string of ASCII-only symbols.
- */
- function encode(input) {
- var n,
- delta,
- handledCPCount,
- basicLength,
- bias,
- j,
- m,
- q,
- k,
- t,
- currentValue,
- output = [],
- /** `inputLength` will hold the number of code points in `input`. */
- inputLength,
- /** Cached calculation results */
- handledCPCountPlusOne,
- baseMinusT,
- qMinusT;
- // Convert the input in UCS-2 to Unicode
- input = ucs2decode(input);
- // Cache the length
- inputLength = input.length;
- // Initialize the state
- n = initialN;
- delta = 0;
- bias = initialBias;
- // Handle the basic code points
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue < 0x80) {
- output.push(stringFromCharCode(currentValue));
- }
- }
- handledCPCount = basicLength = output.length;
- // `handledCPCount` is the number of code points that have been handled;
- // `basicLength` is the number of basic code points.
- // Finish the basic string - if it is not empty - with a delimiter
- if (basicLength) {
- output.push(delimiter);
- }
- // Main encoding loop:
- while (handledCPCount < inputLength) {
- // All non-basic code points < n have been handled already. Find the next
- // larger one:
- for (m = maxInt, j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue >= n && currentValue < m) {
- m = currentValue;
- }
- }
- // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
- // but guard against overflow
- handledCPCountPlusOne = handledCPCount + 1;
- if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
- error('overflow');
- }
- delta += (m - n) * handledCPCountPlusOne;
- n = m;
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue < n && ++delta > maxInt) {
- error('overflow');
- }
- if (currentValue == n) {
- // Represent delta as a generalized variable-length integer
- for (q = delta, k = base; /* no condition */; k += base) {
- t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
- if (q < t) {
- break;
- }
- qMinusT = q - t;
- baseMinusT = base - t;
- output.push(
- stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
- );
- q = floor(qMinusT / baseMinusT);
- }
- output.push(stringFromCharCode(digitToBasic(q, 0)));
- bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
- delta = 0;
- ++handledCPCount;
- }
- }
- ++delta;
- ++n;
- }
- return output.join('');
- }
- /**
- * Converts a Punycode string representing a domain name or an email address
- * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
- * it doesn't matter if you call it on a string that has already been
- * converted to Unicode.
- * @memberOf punycode
- * @param {String} input The Punycoded domain name or email address to
- * convert to Unicode.
- * @returns {String} The Unicode representation of the given Punycode
- * string.
- */
- function toUnicode(input) {
- return mapDomain(input, function(string) {
- return regexPunycode.test(string)
- ? decode(string.slice(4).toLowerCase())
- : string;
- });
- }
- /**
- * Converts a Unicode string representing a domain name or an email address to
- * Punycode. Only the non-ASCII parts of the domain name will be converted,
- * i.e. it doesn't matter if you call it with a domain that's already in
- * ASCII.
- * @memberOf punycode
- * @param {String} input The domain name or email address to convert, as a
- * Unicode string.
- * @returns {String} The Punycode representation of the given domain name or
- * email address.
- */
- function toASCII(input) {
- return mapDomain(input, function(string) {
- return regexNonASCII.test(string)
- ? 'xn--' + encode(string)
- : string;
- });
- }
- /*--------------------------------------------------------------------------*/
- /** Define the public API */
- punycode = {
- /**
- * A string representing the current Punycode.js version number.
- * @memberOf punycode
- * @type String
- */
- 'version': '1.4.1',
- /**
- * An object of methods to convert from JavaScript's internal character
- * representation (UCS-2) to Unicode code points, and back.
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
- * @memberOf punycode
- * @type Object
- */
- 'ucs2': {
- 'decode': ucs2decode,
- 'encode': ucs2encode
- },
- 'decode': decode,
- 'encode': encode,
- 'toASCII': toASCII,
- 'toUnicode': toUnicode
- };
- /** Expose `punycode` */
- // Some AMD build optimizers, like r.js, check for specific condition patterns
- // like the following:
- if (
- true
- ) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
- return punycode;
- }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if (freeExports && freeModule) {
- if (module.exports == freeExports) {
- // in Node.js, io.js, or RingoJS v0.8.0+
- freeModule.exports = punycode;
- } else {
- // in Narwhal or RingoJS v0.7.0-
- for (key in punycode) {
- punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
- }
- }
- } else {
- // in Rhino or a web browser
- root.punycode = punycode;
- }
- }(this));
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
- /***/ },
- /* 546 */
- /***/ function(module, exports) {
- "use strict";
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- 'use strict';
- // If obj.hasOwnProperty has been overridden, then calling
- // obj.hasOwnProperty(prop) will break.
- // See: https://github.com/joyent/node/issues/1707
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
- module.exports = function(qs, sep, eq, options) {
- sep = sep || '&';
- eq = eq || '=';
- var obj = {};
- if (typeof qs !== 'string' || qs.length === 0) {
- return obj;
- }
- var regexp = /\+/g;
- qs = qs.split(sep);
- var maxKeys = 1000;
- if (options && typeof options.maxKeys === 'number') {
- maxKeys = options.maxKeys;
- }
- var len = qs.length;
- // maxKeys <= 0 means that we should not limit keys count
- if (maxKeys > 0 && len > maxKeys) {
- len = maxKeys;
- }
- for (var i = 0; i < len; ++i) {
- var x = qs[i].replace(regexp, '%20'),
- idx = x.indexOf(eq),
- kstr, vstr, k, v;
- if (idx >= 0) {
- kstr = x.substr(0, idx);
- vstr = x.substr(idx + 1);
- } else {
- kstr = x;
- vstr = '';
- }
- k = decodeURIComponent(kstr);
- v = decodeURIComponent(vstr);
- if (!hasOwnProperty(obj, k)) {
- obj[k] = v;
- } else if (isArray(obj[k])) {
- obj[k].push(v);
- } else {
- obj[k] = [obj[k], v];
- }
- }
- return obj;
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- /***/ },
- /* 547 */
- /***/ function(module, exports) {
- "use strict";
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- 'use strict';
- var stringifyPrimitive = function(v) {
- switch (typeof v) {
- case 'string':
- return v;
- case 'boolean':
- return v ? 'true' : 'false';
- case 'number':
- return isFinite(v) ? v : '';
- default:
- return '';
- }
- };
- module.exports = function(obj, sep, eq, name) {
- sep = sep || '&';
- eq = eq || '=';
- if (obj === null) {
- obj = undefined;
- }
- if (typeof obj === 'object') {
- return map(objectKeys(obj), function(k) {
- var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
- if (isArray(obj[k])) {
- return map(obj[k], function(v) {
- return ks + encodeURIComponent(stringifyPrimitive(v));
- }).join(sep);
- } else {
- return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
- }
- }).join(sep);
- }
- if (!name) return '';
- return encodeURIComponent(stringifyPrimitive(name)) + eq +
- encodeURIComponent(stringifyPrimitive(obj));
- };
- var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
- function map (xs, f) {
- if (xs.map) return xs.map(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- res.push(f(xs[i], i));
- }
- return res;
- }
- var objectKeys = Object.keys || function (obj) {
- var res = [];
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
- }
- return res;
- };
- /***/ },
- /* 548 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- 'use strict';
- exports.decode = exports.parse = __webpack_require__(546);
- exports.encode = exports.stringify = __webpack_require__(547);
- /***/ },
- /* 549 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(215)
- /***/ },
- /* 550 */
- /***/ function(module, exports, __webpack_require__) {
- var Stream = (function (){
- try {
- return __webpack_require__(9); // hack to fix a circular dependency issue when used with browserify
- } catch(_){}
- }());
- exports = module.exports = __webpack_require__(216);
- exports.Stream = Stream || exports;
- exports.Readable = exports;
- exports.Writable = __webpack_require__(139);
- exports.Duplex = __webpack_require__(55);
- exports.Transform = __webpack_require__(138);
- exports.PassThrough = __webpack_require__(215);
- /***/ },
- /* 551 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(138)
- /***/ },
- /* 552 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(139)
- /***/ },
- /* 553 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global, process) {/**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- !(function(global) {
- "use strict";
- var hasOwn = Object.prototype.hasOwnProperty;
- var undefined; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
- var inModule = typeof module === "object";
- var runtime = global.regeneratorRuntime;
- if (runtime) {
- if (inModule) {
- // If regeneratorRuntime is defined globally and we're in a module,
- // make the exports object identical to regeneratorRuntime.
- module.exports = runtime;
- }
- // Don't bother evaluating the rest of this file if the runtime was
- // already defined globally.
- return;
- }
- // Define the runtime globally (as expected by generated code) as either
- // module.exports (if we're in a module) or a new, empty object.
- runtime = global.regeneratorRuntime = inModule ? module.exports : {};
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided, then outerFn.prototype instanceof Generator.
- var generator = Object.create((outerFn || Generator).prototype);
- var context = new Context(tryLocsList || []);
- // The ._invoke method unifies the implementations of the .next,
- // .throw, and .return methods.
- generator._invoke = makeInvokeMethod(innerFn, self, context);
- return generator;
- }
- runtime.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
- GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
- // Helper for defining the .next, .throw, and .return methods of the
- // Iterator interface in terms of a single ._invoke method.
- function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- prototype[method] = function(arg) {
- return this._invoke(method, arg);
- };
- });
- }
- runtime.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- runtime.mark = function(genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- if (!(toStringTagSymbol in genFun)) {
- genFun[toStringTagSymbol] = "GeneratorFunction";
- }
- }
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- // Within the body of any async function, `await x` is transformed to
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
- // `value instanceof AwaitArgument` to determine if the yielded value is
- // meant to be awaited. Some may consider the name of this method too
- // cutesy, but they are curmudgeons.
- runtime.awrap = function(arg) {
- return new AwaitArgument(arg);
- };
- function AwaitArgument(arg) {
- this.arg = arg;
- }
- function AsyncIterator(generator) {
- function invoke(method, arg, resolve, reject) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- } else {
- var result = record.arg;
- var value = result.value;
- if (value instanceof AwaitArgument) {
- return Promise.resolve(value.arg).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return Promise.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration. If the Promise is rejected, however, the
- // result for this iteration will be rejected with the same
- // reason. Note that rejections of yielded Promises are not
- // thrown back into the generator function, as is the case
- // when an awaited Promise is rejected. This difference in
- // behavior between yield and await is important, because it
- // allows the consumer to decide what to do with the yielded
- // rejection (swallow it and continue, manually .throw it back
- // into the generator, abandon iteration, whatever). With
- // await, by contrast, there is no opportunity to examine the
- // rejection reason outside the generator function, so the
- // only option is to throw it from the await expression, and
- // let the generator function handle the exception.
- result.value = unwrapped;
- resolve(result);
- }, reject);
- }
- }
- if (typeof process === "object" && process.domain) {
- invoke = process.domain.bind(invoke);
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new Promise(function(resolve, reject) {
- invoke(method, arg, resolve, reject);
- });
- }
- return previousPromise =
- // If enqueue has been called before, then we want to wait until
- // all previous Promises have been resolved before calling invoke,
- // so that results are always delivered in the correct order. If
- // enqueue has not been called before, then it is important to
- // call invoke immediately, without waiting on a callback to fire,
- // so that the async generator function has the opportunity to do
- // any necessary setup in a predictable way. This predictability
- // is why the Promise constructor synchronously invokes its
- // executor callback, and why async functions synchronously
- // execute code before the first await. Since we implement simple
- // async functions in terms of async generators, it is especially
- // important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
- }
- // Define the unified helper method that is used to implement .next,
- // .throw, and .return (see defineIteratorMethods).
- this._invoke = enqueue;
- }
- defineIteratorMethods(AsyncIterator.prototype);
- // Note that simple async functions are implemented on top of
- // AsyncIterator objects; they just return a Promise for the value of
- // the final result produced by the iterator.
- runtime.async = function(innerFn, outerFn, self, tryLocsList) {
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList)
- );
- return runtime.isGeneratorFunction(outerFn)
- ? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
- return result.done ? result.value : iter.next();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- if (method === "throw") {
- throw arg;
- }
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- if (method === "return" ||
- (method === "throw" && delegate.iterator[method] === undefined)) {
- // A return or throw (when the delegate iterator has no throw
- // method) always terminates the yield* loop.
- context.delegate = null;
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- var returnMethod = delegate.iterator["return"];
- if (returnMethod) {
- var record = tryCatch(returnMethod, delegate.iterator, arg);
- if (record.type === "throw") {
- // If the return method threw an exception, let that
- // exception prevail over the original return or throw.
- method = "throw";
- arg = record.arg;
- continue;
- }
- }
- if (method === "return") {
- // Continue with the outer return, now that the delegate
- // iterator has been terminated.
- continue;
- }
- }
- var record = tryCatch(
- delegate.iterator[method],
- delegate.iterator,
- arg
- );
- if (record.type === "throw") {
- context.delegate = null;
- // Like returning generator.throw(uncaught), but without the
- // overhead of an extra function call.
- method = "throw";
- arg = record.arg;
- continue;
- }
- // Delegate generator ran and handled its own exceptions so
- // regardless of what the method was, we continue as if it is
- // "next" with an undefined arg.
- method = "next";
- arg = undefined;
- var info = record.arg;
- if (info.done) {
- context[delegate.resultName] = info.value;
- context.next = delegate.nextLoc;
- } else {
- state = GenStateSuspendedYield;
- return info;
- }
- context.delegate = null;
- }
- if (method === "next") {
- // Setting context._sent for legacy support of Babel's
- // function.sent implementation.
- context.sent = context._sent = arg;
- } else if (method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw arg;
- }
- if (context.dispatchException(arg)) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- method = "next";
- arg = undefined;
- }
- } else if (method === "return") {
- context.abrupt("return", arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- var info = {
- value: record.arg,
- done: context.done
- };
- if (record.arg === ContinueSentinel) {
- if (context.delegate && method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- arg = undefined;
- }
- } else {
- return info;
- }
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(arg) call above.
- method = "throw";
- arg = record.arg;
- }
- }
- };
- }
- // Define Generator.prototype.{next,throw,return} in terms of the
- // unified ._invoke helper method.
- defineIteratorMethods(Gp);
- Gp[iteratorSymbol] = function() {
- return this;
- };
- Gp[toStringTagSymbol] = "Generator";
- Gp.toString = function() {
- return "[object Generator]";
- };
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset(true);
- }
- runtime.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- runtime.values = values;
- function doneResult() {
- return { value: undefined, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function(skipTempReset) {
- this.prev = 0;
- this.next = 0;
- // Resetting context._sent for legacy support of Babel's
- // function.sent implementation.
- this.sent = this._sent = undefined;
- this.done = false;
- this.delegate = null;
- this.tryEntries.forEach(resetTryEntry);
- if (!skipTempReset) {
- for (var name in this) {
- // Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
- this[name] = undefined;
- }
- }
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- return !!caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.next = finallyEntry.finallyLoc;
- } else {
- this.complete(record);
- }
- return ContinueSentinel;
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = record.arg;
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- this.complete(entry.completion, entry.afterLoc);
- resetTryEntry(entry);
- return ContinueSentinel;
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- return ContinueSentinel;
- }
- };
- })(
- // Among the various tricks for obtaining a reference to the global
- // object, this seems to be the most reliable technique that does not
- // use indirect eval (which violates Content Security Policy).
- typeof global === "object" ? global :
- typeof window === "object" ? window :
- typeof self === "object" ? self : this
- );
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(4)))
- /***/ },
- /* 554 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/*
- CryptoJS v3.1.2
- code.google.com/p/crypto-js
- (c) 2009-2013 by Jeff Mott. All rights reserved.
- code.google.com/p/crypto-js/wiki/License
- */
- /** @preserve
- (c) 2012 by Cédric Mesnil. All rights reserved.
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- - 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.
- 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.
- */
- // constants table
- var zl = [
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
- ]
- var zr = [
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
- ]
- var sl = [
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
- ]
- var sr = [
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
- ]
- var hl = [0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]
- var hr = [0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]
- function bytesToWords (bytes) {
- var words = []
- for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
- words[b >>> 5] |= bytes[i] << (24 - b % 32)
- }
- return words
- }
- function wordsToBytes (words) {
- var bytes = []
- for (var b = 0; b < words.length * 32; b += 8) {
- bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF)
- }
- return bytes
- }
- function processBlock (H, M, offset) {
- // swap endian
- for (var i = 0; i < 16; i++) {
- var offset_i = offset + i
- var M_offset_i = M[offset_i]
- // Swap
- M[offset_i] = (
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
- )
- }
- // Working variables
- var al, bl, cl, dl, el
- var ar, br, cr, dr, er
- ar = al = H[0]
- br = bl = H[1]
- cr = cl = H[2]
- dr = dl = H[3]
- er = el = H[4]
- // computation
- var t
- for (i = 0; i < 80; i += 1) {
- t = (al + M[offset + zl[i]]) | 0
- if (i < 16) {
- t += f1(bl, cl, dl) + hl[0]
- } else if (i < 32) {
- t += f2(bl, cl, dl) + hl[1]
- } else if (i < 48) {
- t += f3(bl, cl, dl) + hl[2]
- } else if (i < 64) {
- t += f4(bl, cl, dl) + hl[3]
- } else {// if (i<80) {
- t += f5(bl, cl, dl) + hl[4]
- }
- t = t | 0
- t = rotl(t, sl[i])
- t = (t + el) | 0
- al = el
- el = dl
- dl = rotl(cl, 10)
- cl = bl
- bl = t
- t = (ar + M[offset + zr[i]]) | 0
- if (i < 16) {
- t += f5(br, cr, dr) + hr[0]
- } else if (i < 32) {
- t += f4(br, cr, dr) + hr[1]
- } else if (i < 48) {
- t += f3(br, cr, dr) + hr[2]
- } else if (i < 64) {
- t += f2(br, cr, dr) + hr[3]
- } else {// if (i<80) {
- t += f1(br, cr, dr) + hr[4]
- }
- t = t | 0
- t = rotl(t, sr[i])
- t = (t + er) | 0
- ar = er
- er = dr
- dr = rotl(cr, 10)
- cr = br
- br = t
- }
- // intermediate hash value
- t = (H[1] + cl + dr) | 0
- H[1] = (H[2] + dl + er) | 0
- H[2] = (H[3] + el + ar) | 0
- H[3] = (H[4] + al + br) | 0
- H[4] = (H[0] + bl + cr) | 0
- H[0] = t
- }
- function f1 (x, y, z) {
- return ((x) ^ (y) ^ (z))
- }
- function f2 (x, y, z) {
- return (((x) & (y)) | ((~x) & (z)))
- }
- function f3 (x, y, z) {
- return (((x) | (~(y))) ^ (z))
- }
- function f4 (x, y, z) {
- return (((x) & (z)) | ((y) & (~(z))))
- }
- function f5 (x, y, z) {
- return ((x) ^ ((y) | (~(z))))
- }
- function rotl (x, n) {
- return (x << n) | (x >>> (32 - n))
- }
- function ripemd160 (message) {
- var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]
- if (typeof message === 'string') {
- message = new Buffer(message, 'utf8')
- }
- var m = bytesToWords(message)
- var nBitsLeft = message.length * 8
- var nBitsTotal = message.length * 8
- // Add padding
- m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32)
- m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
- (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
- (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
- )
- for (var i = 0; i < m.length; i += 16) {
- processBlock(H, m, i)
- }
- // swap endian
- for (i = 0; i < 5; i++) {
- // shortcut
- var H_i = H[i]
- // Swap
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00)
- }
- var digestbytes = wordsToBytes(H)
- return new Buffer(digestbytes)
- }
- module.exports = ripemd160
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 555 */
- /***/ function(module, exports, __webpack_require__) {
- var Readable = __webpack_require__(9).Readable;
- var PassThrough = __webpack_require__(9).PassThrough;
- function SandwichStream(options) {
- Readable.call(this, options);
- options = options || {};
- this._streamsActive = false;
- this._streamsAdded = false;
- this._streams = [];
- this._currentStream = undefined;
- this._errorsEmitted = false;
- if (options.head) {
- this._head = options.head;
- }
- if (options.tail) {
- this._tail = options.tail;
- }
- if (options.separator) {
- this._separator = options.separator;
- }
- }
- SandwichStream.prototype = Object.create(Readable.prototype, {
- constructor: SandwichStream
- });
- SandwichStream.prototype._read = function () {
- if (!this._streamsActive) {
- this._streamsActive = true;
- this._pushHead();
- this._streamNextStream();
- }
- };
- SandwichStream.prototype.add = function (newStream) {
- if (!this._streamsActive) {
- this._streamsAdded = true;
- this._streams.push(newStream);
- newStream.on('error', this._substreamOnError.bind(this));
- }
- else {
- throw new Error('SandwichStream error adding new stream while streaming');
- }
- };
- SandwichStream.prototype._substreamOnError = function (error) {
- this._errorsEmitted = true;
- this.emit('error', error);
- };
- SandwichStream.prototype._pushHead = function () {
- if (this._head) {
- this.push(this._head);
- }
- };
- SandwichStream.prototype._streamNextStream = function () {
- if (this._nextStream()) {
- this._bindCurrentStreamEvents();
- }
- else {
- this._pushTail();
- this.push(null);
- }
- };
- SandwichStream.prototype._nextStream = function () {
- this._currentStream = this._streams.shift();
- return this._currentStream !== undefined;
- };
- SandwichStream.prototype._bindCurrentStreamEvents = function () {
- this._currentStream.on('readable', this._currentStreamOnReadable.bind(this));
- this._currentStream.on('end', this._currentStreamOnEnd.bind(this));
- };
- SandwichStream.prototype._currentStreamOnReadable = function () {
- this.push(this._currentStream.read() || '');
- };
- SandwichStream.prototype._currentStreamOnEnd = function () {
- this._pushSeparator();
- this._streamNextStream();
- };
- SandwichStream.prototype._pushSeparator = function () {
- if (this._streams.length > 0 && this._separator) {
- this.push(this._separator);
- }
- };
- SandwichStream.prototype._pushTail = function () {
- if (this._tail) {
- this.push(this._tail);
- }
- };
- function sandwichStream(options) {
- var stream = new SandwichStream(options);
- return stream;
- }
- sandwichStream.SandwichStream = SandwichStream;
- module.exports = sandwichStream;
- /***/ },
- /* 556 */
- /***/ function(module, exports, __webpack_require__) {
- var exports = module.exports = function SHA (algorithm) {
- algorithm = algorithm.toLowerCase()
- var Algorithm = exports[algorithm]
- if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
- return new Algorithm()
- }
- exports.sha = __webpack_require__(557)
- exports.sha1 = __webpack_require__(558)
- exports.sha224 = __webpack_require__(559)
- exports.sha256 = __webpack_require__(217)
- exports.sha384 = __webpack_require__(560)
- exports.sha512 = __webpack_require__(218)
- /***/ },
- /* 557 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
- * in FIPS PUB 180-1
- * This source code is derived from sha1.js of the same repository.
- * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
- * operation was added.
- */
- var inherits = __webpack_require__(2)
- var Hash = __webpack_require__(65)
- var K = [
- 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
- ]
- var W = new Array(80)
- function Sha () {
- this.init()
- this._w = W
- Hash.call(this, 64, 56)
- }
- inherits(Sha, Hash)
- Sha.prototype.init = function () {
- this._a = 0x67452301
- this._b = 0xefcdab89
- this._c = 0x98badcfe
- this._d = 0x10325476
- this._e = 0xc3d2e1f0
- return this
- }
- function rotl5 (num) {
- return (num << 5) | (num >>> 27)
- }
- function rotl30 (num) {
- return (num << 30) | (num >>> 2)
- }
- function ft (s, b, c, d) {
- if (s === 0) return (b & c) | ((~b) & d)
- if (s === 2) return (b & c) | (b & d) | (c & d)
- return b ^ c ^ d
- }
- Sha.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
- for (var j = 0; j < 80; ++j) {
- var s = ~~(j / 20)
- var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
- e = d
- d = c
- c = rotl30(b)
- b = a
- a = t
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- }
- Sha.prototype._hash = function () {
- var H = new Buffer(20)
- H.writeInt32BE(this._a | 0, 0)
- H.writeInt32BE(this._b | 0, 4)
- H.writeInt32BE(this._c | 0, 8)
- H.writeInt32BE(this._d | 0, 12)
- H.writeInt32BE(this._e | 0, 16)
- return H
- }
- module.exports = Sha
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 558 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
- * in FIPS PUB 180-1
- * Version 2.1a Copyright Paul Johnston 2000 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for details.
- */
- var inherits = __webpack_require__(2)
- var Hash = __webpack_require__(65)
- var K = [
- 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
- ]
- var W = new Array(80)
- function Sha1 () {
- this.init()
- this._w = W
- Hash.call(this, 64, 56)
- }
- inherits(Sha1, Hash)
- Sha1.prototype.init = function () {
- this._a = 0x67452301
- this._b = 0xefcdab89
- this._c = 0x98badcfe
- this._d = 0x10325476
- this._e = 0xc3d2e1f0
- return this
- }
- function rotl1 (num) {
- return (num << 1) | (num >>> 31)
- }
- function rotl5 (num) {
- return (num << 5) | (num >>> 27)
- }
- function rotl30 (num) {
- return (num << 30) | (num >>> 2)
- }
- function ft (s, b, c, d) {
- if (s === 0) return (b & c) | ((~b) & d)
- if (s === 2) return (b & c) | (b & d) | (c & d)
- return b ^ c ^ d
- }
- Sha1.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
- for (var j = 0; j < 80; ++j) {
- var s = ~~(j / 20)
- var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
- e = d
- d = c
- c = rotl30(b)
- b = a
- a = t
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- }
- Sha1.prototype._hash = function () {
- var H = new Buffer(20)
- H.writeInt32BE(this._a | 0, 0)
- H.writeInt32BE(this._b | 0, 4)
- H.writeInt32BE(this._c | 0, 8)
- H.writeInt32BE(this._d | 0, 12)
- H.writeInt32BE(this._e | 0, 16)
- return H
- }
- module.exports = Sha1
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 559 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {/**
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
- * in FIPS 180-2
- * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- *
- */
- var inherits = __webpack_require__(2)
- var Sha256 = __webpack_require__(217)
- var Hash = __webpack_require__(65)
- var W = new Array(64)
- function Sha224 () {
- this.init()
- this._w = W // new Array(64)
- Hash.call(this, 64, 56)
- }
- inherits(Sha224, Sha256)
- Sha224.prototype.init = function () {
- this._a = 0xc1059ed8
- this._b = 0x367cd507
- this._c = 0x3070dd17
- this._d = 0xf70e5939
- this._e = 0xffc00b31
- this._f = 0x68581511
- this._g = 0x64f98fa7
- this._h = 0xbefa4fa4
- return this
- }
- Sha224.prototype._hash = function () {
- var H = new Buffer(28)
- H.writeInt32BE(this._a, 0)
- H.writeInt32BE(this._b, 4)
- H.writeInt32BE(this._c, 8)
- H.writeInt32BE(this._d, 12)
- H.writeInt32BE(this._e, 16)
- H.writeInt32BE(this._f, 20)
- H.writeInt32BE(this._g, 24)
- return H
- }
- module.exports = Sha224
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 560 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2)
- var SHA512 = __webpack_require__(218)
- var Hash = __webpack_require__(65)
- var W = new Array(160)
- function Sha384 () {
- this.init()
- this._w = W
- Hash.call(this, 128, 112)
- }
- inherits(Sha384, SHA512)
- Sha384.prototype.init = function () {
- this._ah = 0xcbbb9d5d
- this._bh = 0x629a292a
- this._ch = 0x9159015a
- this._dh = 0x152fecd8
- this._eh = 0x67332667
- this._fh = 0x8eb44a87
- this._gh = 0xdb0c2e0d
- this._hh = 0x47b5481d
- this._al = 0xc1059ed8
- this._bl = 0x367cd507
- this._cl = 0x3070dd17
- this._dl = 0xf70e5939
- this._el = 0xffc00b31
- this._fl = 0x68581511
- this._gl = 0x64f98fa7
- this._hl = 0xbefa4fa4
- return this
- }
- Sha384.prototype._hash = function () {
- var H = new Buffer(48)
- function writeInt64BE (h, l, offset) {
- H.writeInt32BE(h, offset)
- H.writeInt32BE(l, offset + 4)
- }
- writeInt64BE(this._ah, this._al, 0)
- writeInt64BE(this._bh, this._bl, 8)
- writeInt64BE(this._ch, this._cl, 16)
- writeInt64BE(this._dh, this._dl, 24)
- writeInt64BE(this._eh, this._el, 32)
- writeInt64BE(this._fh, this._fl, 40)
- return H
- }
- module.exports = Sha384
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
- /***/ },
- /* 561 */
- /***/ function(module, exports, __webpack_require__) {
- var varint = __webpack_require__(564)
- exports.encode = function encode (v, b, o) {
- v = v >= 0 ? v*2 : v*-2 - 1
- var r = varint.encode(v, b, o)
- encode.bytes = varint.encode.bytes
- return r
- }
- exports.decode = function decode (b, o) {
- var v = varint.decode(b, o)
- decode.bytes = varint.decode.bytes
- return v & 1 ? (v+1) / -2 : v / 2
- }
- exports.encodingLength = function (v) {
- return varint.encodingLength(v >= 0 ? v*2 : v*-2 - 1)
- }
- /***/ },
- /* 562 */
- /***/ function(module, exports) {
- module.exports = read
- var MSB = 0x80
- , REST = 0x7F
- function read(buf, offset) {
- var res = 0
- , offset = offset || 0
- , shift = 0
- , counter = offset
- , b
- , l = buf.length
-
- do {
- if(counter >= l) {
- read.bytesRead = 0
- return undefined
- }
- b = buf[counter++]
- res += shift < 28
- ? (b & REST) << shift
- : (b & REST) * Math.pow(2, shift)
- shift += 7
- } while (b >= MSB)
-
- read.bytes = counter - offset
-
- return res
- }
- /***/ },
- /* 563 */
- /***/ function(module, exports) {
- module.exports = encode
- var MSB = 0x80
- , REST = 0x7F
- , MSBALL = ~REST
- , INT = Math.pow(2, 31)
- function encode(num, out, offset) {
- out = out || []
- offset = offset || 0
- var oldOffset = offset
- while(num >= INT) {
- out[offset++] = (num & 0xFF) | MSB
- num /= 128
- }
- while(num & MSBALL) {
- out[offset++] = (num & 0xFF) | MSB
- num >>>= 7
- }
- out[offset] = num | 0
-
- encode.bytes = offset - oldOffset + 1
-
- return out
- }
- /***/ },
- /* 564 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = {
- encode: __webpack_require__(563)
- , decode: __webpack_require__(562)
- , encodingLength: __webpack_require__(565)
- }
- /***/ },
- /* 565 */
- /***/ function(module, exports) {
- var N1 = Math.pow(2, 7)
- var N2 = Math.pow(2, 14)
- var N3 = Math.pow(2, 21)
- var N4 = Math.pow(2, 28)
- var N5 = Math.pow(2, 35)
- var N6 = Math.pow(2, 42)
- var N7 = Math.pow(2, 49)
- module.exports = function (value) {
- return (
- value < N1 ? 1
- : value < N2 ? 2
- : value < N3 ? 3
- : value < N4 ? 4
- : value < N5 ? 5
- : value < N6 ? 6
- : value < N7 ? 7
- : 8
- )
- }
- /***/ },
- /* 566 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /*
- Copyright (c) 2014, Matteo Collina <[email protected]>
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
- 'use strict';
- var through = __webpack_require__(572)
- function transform(chunk, enc, cb) {
- var list = chunk.toString('utf8').split(this.matcher)
- , remaining = list.pop()
- , i
- if (list.length >= 1) {
- push(this, this.mapper((this._last + list.shift())))
- } else {
- remaining = this._last + remaining
- }
- for (i = 0; i < list.length; i++) {
- push(this, this.mapper(list[i]))
- }
- this._last = remaining
- cb()
- }
- function flush(cb) {
- if (this._last)
- push(this, this.mapper(this._last))
- cb()
- }
- function push(self, val) {
- if (val !== undefined)
- self.push(val)
- }
- function noop(incoming) {
- return incoming
- }
- function split(matcher, mapper, options) {
- if (typeof matcher === 'object' && !(matcher instanceof RegExp)) {
- options = matcher
- matcher = null
- }
- if (typeof matcher === 'function') {
- mapper = matcher
- matcher = null
- }
- options = options || {}
- var stream = through(options, transform, flush)
- // this stream is in objectMode only in the readable part
- stream._readableState.objectMode = true;
- stream._last = ''
- stream.matcher = matcher || /\r?\n/
- stream.mapper = mapper || noop
- return stream
- }
- module.exports = split
- /***/ },
- /* 567 */
- /***/ function(module, exports) {
- module.exports = Array.isArray || function (arr) {
- return Object.prototype.toString.call(arr) == '[object Array]';
- };
- /***/ },
- /* 568 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Readable;
- /*<replacement>*/
- var isArray = __webpack_require__(567);
- /*</replacement>*/
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- var EE = __webpack_require__(30).EventEmitter;
- /*<replacement>*/
- if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- var Stream = __webpack_require__(9);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var StringDecoder;
- util.inherits(Readable, Stream);
- function ReadableState(options, stream) {
- options = options || {};
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.buffer = [];
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = false;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // In streams that never have any data, and do push(null) right away,
- // the consumer can miss the 'end' event if they do some I/O before
- // consuming the stream. So, we don't emit('end') until some reading
- // happens.
- this.calledRead = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, becuase any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder)
- StringDecoder = __webpack_require__(38).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- function Readable(options) {
- if (!(this instanceof Readable))
- return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function(chunk, encoding) {
- var state = this._readableState;
- if (typeof chunk === 'string' && !state.objectMode) {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = new Buffer(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function(chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null || chunk === undefined) {
- state.reading = false;
- if (!state.ended)
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var e = new Error('stream.unshift() after end event');
- stream.emit('error', e);
- } else {
- if (state.decoder && !addToFront && !encoding)
- chunk = state.decoder.write(chunk);
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) {
- state.buffer.unshift(chunk);
- } else {
- state.reading = false;
- state.buffer.push(chunk);
- }
- if (state.needReadable)
- emitReadable(stream);
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended &&
- (state.needReadable ||
- state.length < state.highWaterMark ||
- state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function(enc) {
- if (!StringDecoder)
- StringDecoder = __webpack_require__(38).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- };
- // Don't raise the hwm > 128MB
- var MAX_HWM = 0x800000;
- function roundUpToNextPowerOf2(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2
- n--;
- for (var p = 1; p < 32; p <<= 1) n |= n >> p;
- n++;
- }
- return n;
- }
- function howMuchToRead(n, state) {
- if (state.length === 0 && state.ended)
- return 0;
- if (state.objectMode)
- return n === 0 ? 0 : 1;
- if (n === null || isNaN(n)) {
- // only flow one buffer at a time
- if (state.flowing && state.buffer.length)
- return state.buffer[0].length;
- else
- return state.length;
- }
- if (n <= 0)
- return 0;
- // If we're asking for more than the target buffer level,
- // then raise the water mark. Bump up to the next highest
- // power of 2, to prevent increasing it excessively in tiny
- // amounts.
- if (n > state.highWaterMark)
- state.highWaterMark = roundUpToNextPowerOf2(n);
- // don't have that much. return null, unless we've ended.
- if (n > state.length) {
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- } else
- return state.length;
- }
- return n;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function(n) {
- var state = this._readableState;
- state.calledRead = true;
- var nOrig = n;
- var ret;
- if (typeof n !== 'number' || n > 0)
- state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 &&
- state.needReadable &&
- (state.length >= state.highWaterMark || state.ended)) {
- emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- ret = null;
- // In cases where the decoder did not receive enough data
- // to produce a full chunk, then immediately received an
- // EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
- // howMuchToRead will see this and coerce the amount to
- // read to zero (because it's looking at the length of the
- // first <Buffer > in state.buffer), and we'll end up here.
- //
- // This can only happen via state.decoder -- no other venue
- // exists for pushing a zero-length chunk into state.buffer
- // and triggering this behavior. In this case, we return our
- // remaining data and end the stream, if appropriate.
- if (state.length > 0 && state.decoder) {
- ret = fromList(n, state);
- state.length -= ret.length;
- }
- if (state.length === 0)
- endReadable(this);
- return ret;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- // if we currently have less than the highWaterMark, then also read some
- if (state.length - n <= state.highWaterMark)
- doRead = true;
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading)
- doRead = false;
- if (doRead) {
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0)
- state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- }
- // If _read called its callback synchronously, then `reading`
- // will be false, and we need to re-evaluate how much data we
- // can return to the user.
- if (doRead && !state.reading)
- n = howMuchToRead(nOrig, state);
- if (n > 0)
- ret = fromList(n, state);
- else
- ret = null;
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- }
- state.length -= n;
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (state.length === 0 && !state.ended)
- state.needReadable = true;
- // If we happened to read() exactly the remaining amount in the
- // buffer, and the EOF has been seen at this point, then make sure
- // that we emit 'end' on the very next tick.
- if (state.ended && !state.endEmitted && state.length === 0)
- endReadable(this);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) &&
- 'string' !== typeof chunk &&
- chunk !== null &&
- chunk !== undefined &&
- !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // if we've ended and we have some data left, then emit
- // 'readable' now to make sure it gets picked up.
- if (state.length > 0)
- emitReadable(stream);
- else
- endReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (state.emittedReadable)
- return;
- state.emittedReadable = true;
- if (state.sync)
- process.nextTick(function() {
- emitReadable_(stream);
- });
- else
- emitReadable_(stream);
- }
- function emitReadable_(stream) {
- stream.emit('readable');
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- process.nextTick(function() {
- maybeReadMore_(stream, state);
- });
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended &&
- state.length < state.highWaterMark) {
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;
- else
- len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function(n) {
- this.emit('error', new Error('not implemented'));
- };
- Readable.prototype.pipe = function(dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
- dest !== process.stdout &&
- dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted)
- process.nextTick(endFn);
- else
- src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- if (readable !== src) return;
- cleanup();
- }
- function onend() {
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- function cleanup() {
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (!dest._writableState || dest._writableState.needDrain)
- ondrain();
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- unpipe();
- dest.removeListener('error', onerror);
- if (EE.listenerCount(dest, 'error') === 0)
- dest.emit('error', er);
- }
- // This is a brutally ugly hack to make sure that our error handler
- // is attached before any userland ones. NEVER DO THIS.
- 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];
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- // the handler that waits for readable events after all
- // the data gets sucked out in flow.
- // This would be easier to follow with a .once() handler
- // in flow(), but that is too slow.
- this.on('readable', pipeOnReadable);
- state.flowing = true;
- process.nextTick(function() {
- flow(src);
- });
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function() {
- var dest = this;
- var state = src._readableState;
- state.awaitDrain--;
- if (state.awaitDrain === 0)
- flow(src);
- };
- }
- function flow(src) {
- var state = src._readableState;
- var chunk;
- state.awaitDrain = 0;
- function write(dest, i, list) {
- var written = dest.write(chunk);
- if (false === written) {
- state.awaitDrain++;
- }
- }
- while (state.pipesCount && null !== (chunk = src.read())) {
- if (state.pipesCount === 1)
- write(state.pipes, 0, null);
- else
- forEach(state.pipes, write);
- src.emit('data', chunk);
- // if anyone needs a drain, then we have to wait for that.
- if (state.awaitDrain > 0)
- return;
- }
- // if every destination was unpiped, either before entering this
- // function, or in the while loop, then stop flowing.
- //
- // NB: This is a pretty rare edge case.
- if (state.pipesCount === 0) {
- state.flowing = false;
- // if there were data event listeners added, then switch to old mode.
- if (EE.listenerCount(src, 'data') > 0)
- emitDataEvents(src);
- return;
- }
- // at this point, no one needed a drain, so we just ran out of data
- // on the next readable event, start it over again.
- state.ranOut = true;
- }
- function pipeOnReadable() {
- if (this._readableState.ranOut) {
- this._readableState.ranOut = false;
- flow(this);
- }
- }
- Readable.prototype.unpipe = function(dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0)
- return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes)
- return this;
- if (!dest)
- dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- this.removeListener('readable', pipeOnReadable);
- state.flowing = false;
- if (dest)
- dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- this.removeListener('readable', pipeOnReadable);
- state.flowing = false;
- for (var i = 0; i < len; i++)
- dests[i].emit('unpipe', this);
- return this;
- }
- // try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1)
- return this;
- state.pipes.splice(i, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1)
- state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function(ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- if (ev === 'data' && !this._readableState.flowing)
- emitDataEvents(this);
- if (ev === 'readable' && this.readable) {
- var state = this._readableState;
- if (!state.readableListening) {
- state.readableListening = true;
- state.emittedReadable = false;
- state.needReadable = true;
- if (!state.reading) {
- this.read(0);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function() {
- emitDataEvents(this);
- this.read(0);
- this.emit('resume');
- };
- Readable.prototype.pause = function() {
- emitDataEvents(this, true);
- this.emit('pause');
- };
- function emitDataEvents(stream, startPaused) {
- var state = stream._readableState;
- if (state.flowing) {
- // https://github.com/isaacs/readable-stream/issues/16
- throw new Error('Cannot switch to old mode now.');
- }
- var paused = startPaused || false;
- var readable = false;
- // convert to an old-style stream.
- stream.readable = true;
- stream.pipe = Stream.prototype.pipe;
- stream.on = stream.addListener = Stream.prototype.on;
- stream.on('readable', function() {
- readable = true;
- var c;
- while (!paused && (null !== (c = stream.read())))
- stream.emit('data', c);
- if (c === null) {
- readable = false;
- stream._readableState.needReadable = true;
- }
- });
- stream.pause = function() {
- paused = true;
- this.emit('pause');
- };
- stream.resume = function() {
- paused = false;
- if (readable)
- process.nextTick(function() {
- stream.emit('readable');
- });
- else
- this.read(0);
- this.emit('resume');
- };
- // now make it start, just in case it hadn't already.
- stream.emit('readable');
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function(stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function() {
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length)
- self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function(chunk) {
- if (state.decoder)
- chunk = state.decoder.write(chunk);
- // don't skip over falsy values in objectMode
- //if (state.objectMode && util.isNullOrUndefined(chunk))
- if (state.objectMode && (chunk === null || chunk === undefined))
- return;
- else if (!state.objectMode && (!chunk || !chunk.length))
- return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (typeof stream[i] === 'function' &&
- typeof this[i] === 'undefined') {
- this[i] = function(method) { return function() {
- return stream[method].apply(stream, arguments);
- }}(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function(ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function(n) {
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- function fromList(n, state) {
- var list = state.buffer;
- var length = state.length;
- var stringMode = !!state.decoder;
- var objectMode = !!state.objectMode;
- var ret;
- // nothing in the list, definitely empty.
- if (list.length === 0)
- return null;
- if (length === 0)
- ret = null;
- else if (objectMode)
- ret = list.shift();
- else if (!n || n >= length) {
- // read it all, truncate the array.
- if (stringMode)
- ret = list.join('');
- else
- ret = Buffer.concat(list, length);
- list.length = 0;
- } else {
- // read just some of it.
- if (n < list[0].length) {
- // just take a part of the first list item.
- // slice is the same for buffers and strings.
- var buf = list[0];
- ret = buf.slice(0, n);
- list[0] = buf.slice(n);
- } else if (n === list[0].length) {
- // first list is a perfect match
- ret = list.shift();
- } else {
- // complex case.
- // we have enough to cover it, but it spans past the first buffer.
- if (stringMode)
- ret = '';
- else
- ret = new Buffer(n);
- var c = 0;
- for (var i = 0, l = list.length; i < l && c < n; i++) {
- var buf = list[0];
- var cpy = Math.min(n - c, buf.length);
- if (stringMode)
- ret += buf.slice(0, cpy);
- else
- buf.copy(ret, c, 0, cpy);
- if (cpy < buf.length)
- list[0] = buf.slice(cpy);
- else
- list.shift();
- c += cpy;
- }
- }
- }
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0)
- throw new Error('endReadable called on non-empty stream');
- if (!state.endEmitted && state.calledRead) {
- state.ended = true;
- process.nextTick(function() {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- });
- }
- }
- function forEach (xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf (xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 569 */
- /***/ function(module, exports, __webpack_require__) {
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- module.exports = Transform;
- var Duplex = __webpack_require__(219);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(options, stream) {
- this.afterTransform = function(er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb)
- return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (data !== null && data !== undefined)
- stream.push(data);
- if (cb)
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform))
- return new Transform(options);
- Duplex.call(this, options);
- var ts = this._transformState = new TransformState(options, this);
- // when the writable side finishes, then flush out anything remaining.
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- this.once('finish', function() {
- if ('function' === typeof this._flush)
- this._flush(function(er) {
- done(stream, er);
- });
- else
- done(stream);
- });
- }
- Transform.prototype.push = function(chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function(chunk, encoding, cb) {
- throw new Error('not implemented');
- };
- Transform.prototype._write = function(chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform ||
- rs.needReadable ||
- rs.length < rs.highWaterMark)
- this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function(n) {
- var ts = this._transformState;
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er) {
- if (er)
- return stream.emit('error', er);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var rs = stream._readableState;
- var ts = stream._transformState;
- if (ws.length)
- throw new Error('calling transform done when ws.length != 0');
- if (ts.transforming)
- throw new Error('calling transform done when still transforming');
- return stream.push(null);
- }
- /***/ },
- /* 570 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // A bit simpler than readable streams.
- // Implement an async ._write(chunk, cb), and it'll handle all
- // the drain event emission and buffering.
- module.exports = Writable;
- /*<replacement>*/
- var Buffer = __webpack_require__(1).Buffer;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- var Stream = __webpack_require__(9);
- util.inherits(Writable, Stream);
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- }
- function WritableState(options, stream) {
- options = options || {};
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, becuase any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function(er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.buffer = [];
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- }
- function Writable(options) {
- var Duplex = __webpack_require__(219);
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex))
- return new Writable(options);
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function() {
- this.emit('error', new Error('Cannot pipe. Not readable.'));
- };
- function writeAfterEnd(stream, state, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- if (!Buffer.isBuffer(chunk) &&
- 'string' !== typeof chunk &&
- chunk !== null &&
- chunk !== undefined &&
- !state.objectMode) {
- var er = new TypeError('Invalid non-string/buffer chunk');
- stream.emit('error', er);
- process.nextTick(function() {
- cb(er);
- });
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function(chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (Buffer.isBuffer(chunk))
- encoding = 'buffer';
- else if (!encoding)
- encoding = state.defaultEncoding;
- if (typeof cb !== 'function')
- cb = function() {};
- if (state.ended)
- writeAfterEnd(this, state, cb);
- else if (validChunk(this, state, chunk, cb))
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- return ret;
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode &&
- state.decodeStrings !== false &&
- typeof chunk === 'string') {
- chunk = new Buffer(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk))
- encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret)
- state.needDrain = true;
- if (state.writing)
- state.buffer.push(new WriteReq(chunk, encoding, cb));
- else
- doWrite(stream, state, len, chunk, encoding, cb);
- return ret;
- }
- function doWrite(stream, state, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- if (sync)
- process.nextTick(function() {
- cb(er);
- });
- else
- cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er)
- onwriteError(stream, state, sync, er, cb);
- else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(stream, state);
- if (!finished && !state.bufferProcessing && state.buffer.length)
- clearBuffer(stream, state);
- if (sync) {
- process.nextTick(function() {
- afterWrite(stream, state, finished, cb);
- });
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished)
- onwriteDrain(stream, state);
- cb();
- if (finished)
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- for (var c = 0; c < state.buffer.length; c++) {
- var entry = state.buffer[c];
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, len, chunk, encoding, cb);
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- c++;
- break;
- }
- }
- state.bufferProcessing = false;
- if (c < state.buffer.length)
- state.buffer = state.buffer.slice(c);
- else
- state.buffer.length = 0;
- }
- Writable.prototype._write = function(chunk, encoding, cb) {
- cb(new Error('not implemented'));
- };
- Writable.prototype.end = function(chunk, encoding, cb) {
- var state = this._writableState;
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (typeof chunk !== 'undefined' && chunk !== null)
- this.write(chunk, encoding);
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished)
- endWritable(this, state, cb);
- };
- function needFinish(stream, state) {
- return (state.ending &&
- state.length === 0 &&
- !state.finished &&
- !state.writing);
- }
- function finishMaybe(stream, state) {
- var need = needFinish(stream, state);
- if (need) {
- state.finished = true;
- stream.emit('finish');
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished)
- process.nextTick(cb);
- else
- stream.once('finish', cb);
- }
- state.ended = true;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 571 */
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(569)
- /***/ },
- /* 572 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process) {var Transform = __webpack_require__(571)
- , inherits = __webpack_require__(44).inherits
- , xtend = __webpack_require__(98)
- function DestroyableTransform(opts) {
- Transform.call(this, opts)
- this._destroyed = false
- }
- inherits(DestroyableTransform, Transform)
- DestroyableTransform.prototype.destroy = function(err) {
- if (this._destroyed) return
- this._destroyed = true
-
- var self = this
- process.nextTick(function() {
- if (err)
- self.emit('error', err)
- self.emit('close')
- })
- }
- // a noop _transform function
- function noop (chunk, enc, callback) {
- callback(null, chunk)
- }
- // create a new export function, used by both the main export and
- // the .ctor export, contains common logic for dealing with arguments
- function through2 (construct) {
- return function (options, transform, flush) {
- if (typeof options == 'function') {
- flush = transform
- transform = options
- options = {}
- }
- if (typeof transform != 'function')
- transform = noop
- if (typeof flush != 'function')
- flush = null
- return construct(options, transform, flush)
- }
- }
- // main export, just make me a transform stream!
- module.exports = through2(function (options, transform, flush) {
- var t2 = new DestroyableTransform(options)
- t2._transform = transform
- if (flush)
- t2._flush = flush
- return t2
- })
- // make me a reusable prototype that I can `new`, or implicitly `new`
- // with a constructor call
- module.exports.ctor = through2(function (options, transform, flush) {
- function Through2 (override) {
- if (!(this instanceof Through2))
- return new Through2(override)
- this.options = xtend(options, override)
- DestroyableTransform.call(this, this.options)
- }
- inherits(Through2, DestroyableTransform)
- Through2.prototype._transform = transform
- if (flush)
- Through2.prototype._flush = flush
- return Through2
- })
- module.exports.obj = through2(function (options, transform, flush) {
- var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
- t2._transform = transform
- if (flush)
- t2._flush = flush
- return t2
- })
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
- /***/ },
- /* 573 */
- /***/ function(module, exports, __webpack_require__) {
- //! stable.js 0.1.5, https://github.com/Two-Screen/stable
- //! © 2014 Angry Bytes and contributors. MIT licensed.
- (function() {
- // A stable array sort, because `Array#sort()` is not guaranteed stable.
- // This is an implementation of merge sort, without recursion.
- var stable = function(arr, comp) {
- return exec(arr.slice(), comp);
- };
- stable.inplace = function(arr, comp) {
- var result = exec(arr, comp);
- // This simply copies back if the result isn't in the original array,
- // which happens on an odd number of passes.
- if (result !== arr) {
- pass(result, null, arr.length, arr);
- }
- return arr;
- };
- // Execute the sort using the input array and a second buffer as work space.
- // Returns one of those two, containing the final result.
- function exec(arr, comp) {
- if (typeof(comp) !== 'function') {
- comp = function(a, b) {
- return String(a).localeCompare(b);
- };
- }
- // Short-circuit when there's nothing to sort.
- var len = arr.length;
- if (len <= 1) {
- return arr;
- }
- // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
- // Chunks are the size of the left or right hand in merge sort.
- // Stop when the left-hand covers all of the array.
- var buffer = new Array(len);
- for (var chk = 1; chk < len; chk *= 2) {
- pass(arr, comp, chk, buffer);
- var tmp = arr;
- arr = buffer;
- buffer = tmp;
- }
- return arr;
- }
- // Run a single pass with the given chunk size.
- var pass = function(arr, comp, chk, result) {
- var len = arr.length;
- var i = 0;
- // Step size / double chunk size.
- var dbl = chk * 2;
- // Bounds of the left and right chunks.
- var l, r, e;
- // Iterators over the left and right chunk.
- var li, ri;
- // Iterate over pairs of chunks.
- for (l = 0; l < len; l += dbl) {
- r = l + chk;
- e = r + chk;
- if (r > len) r = len;
- if (e > len) e = len;
- // Iterate both chunks in parallel.
- li = l;
- ri = r;
- while (true) {
- // Compare the chunks.
- if (li < r && ri < e) {
- // This works for a regular `sort()` compatible comparator,
- // but also for a simple comparator like: `a > b`
- if (comp(arr[li], arr[ri]) <= 0) {
- result[i++] = arr[li++];
- }
- else {
- result[i++] = arr[ri++];
- }
- }
- // Nothing to compare, just flush what's left.
- else if (li < r) {
- result[i++] = arr[li++];
- }
- else if (ri < e) {
- result[i++] = arr[ri++];
- }
- // Both iterators are at the chunk ends.
- else {
- break;
- }
- }
- }
- };
- // Export using CommonJS or to the window.
- if (true) {
- module.exports = stable;
- }
- else {
- window.stable = stable;
- }
- })();
- /***/ },
- /* 574 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(221)
- var inherits = __webpack_require__(2)
- var response = __webpack_require__(575)
- var stream = __webpack_require__(225)
- var toArrayBuffer = __webpack_require__(577)
- var IncomingMessage = response.IncomingMessage
- var rStates = response.readyStates
- function decideMode (preferBinary) {
- if (capability.fetch) {
- return 'fetch'
- } else if (capability.mozchunkedarraybuffer) {
- return 'moz-chunked-arraybuffer'
- } else if (capability.msstream) {
- return 'ms-stream'
- } else if (capability.arraybuffer && preferBinary) {
- return 'arraybuffer'
- } else if (capability.vbArray && preferBinary) {
- return 'text:vbarray'
- } else {
- return 'text'
- }
- }
- var ClientRequest = module.exports = function (opts) {
- var self = this
- stream.Writable.call(self)
- self._opts = opts
- self._body = []
- self._headers = {}
- if (opts.auth)
- self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
- Object.keys(opts.headers).forEach(function (name) {
- self.setHeader(name, opts.headers[name])
- })
- var preferBinary
- if (opts.mode === 'prefer-streaming') {
- // If streaming is a high priority but binary compatibility and
- // the accuracy of the 'content-type' header aren't
- preferBinary = false
- } else if (opts.mode === 'allow-wrong-content-type') {
- // If streaming is more important than preserving the 'content-type' header
- preferBinary = !capability.overrideMimeType
- } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
- // Use binary if text streaming may corrupt data or the content-type header, or for speed
- preferBinary = true
- } else {
- throw new Error('Invalid value for opts.mode')
- }
- self._mode = decideMode(preferBinary)
- self.on('finish', function () {
- self._onFinish()
- })
- }
- inherits(ClientRequest, stream.Writable)
- ClientRequest.prototype.setHeader = function (name, value) {
- var self = this
- var lowerName = name.toLowerCase()
- // This check is not necessary, but it prevents warnings from browsers about setting unsafe
- // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
- // http-browserify did it, so I will too.
- if (unsafeHeaders.indexOf(lowerName) !== -1)
- return
- self._headers[lowerName] = {
- name: name,
- value: value
- }
- }
- ClientRequest.prototype.getHeader = function (name) {
- var self = this
- return self._headers[name.toLowerCase()].value
- }
- ClientRequest.prototype.removeHeader = function (name) {
- var self = this
- delete self._headers[name.toLowerCase()]
- }
- ClientRequest.prototype._onFinish = function () {
- var self = this
- if (self._destroyed)
- return
- var opts = self._opts
- var headersObj = self._headers
- var body
- if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
- if (capability.blobConstructor) {
- body = new global.Blob(self._body.map(function (buffer) {
- return toArrayBuffer(buffer)
- }), {
- type: (headersObj['content-type'] || {}).value || ''
- })
- } else {
- // get utf8 string
- body = Buffer.concat(self._body).toString()
- }
- }
- if (self._mode === 'fetch') {
- var headers = Object.keys(headersObj).map(function (name) {
- return [headersObj[name].name, headersObj[name].value]
- })
- global.fetch(self._opts.url, {
- method: self._opts.method,
- headers: headers,
- body: body,
- mode: 'cors',
- credentials: opts.withCredentials ? 'include' : 'same-origin'
- }).then(function (response) {
- self._fetchResponse = response
- self._connect()
- }, function (reason) {
- self.emit('error', reason)
- })
- } else {
- var xhr = self._xhr = new global.XMLHttpRequest()
- try {
- xhr.open(self._opts.method, self._opts.url, true)
- } catch (err) {
- process.nextTick(function () {
- self.emit('error', err)
- })
- return
- }
- // Can't set responseType on really old browsers
- if ('responseType' in xhr)
- xhr.responseType = self._mode.split(':')[0]
- if ('withCredentials' in xhr)
- xhr.withCredentials = !!opts.withCredentials
- if (self._mode === 'text' && 'overrideMimeType' in xhr)
- xhr.overrideMimeType('text/plain; charset=x-user-defined')
- Object.keys(headersObj).forEach(function (name) {
- xhr.setRequestHeader(headersObj[name].name, headersObj[name].value)
- })
- self._response = null
- xhr.onreadystatechange = function () {
- switch (xhr.readyState) {
- case rStates.LOADING:
- case rStates.DONE:
- self._onXHRProgress()
- break
- }
- }
- // Necessary for streaming in Firefox, since xhr.response is ONLY defined
- // in onprogress, not in onreadystatechange with xhr.readyState = 3
- if (self._mode === 'moz-chunked-arraybuffer') {
- xhr.onprogress = function () {
- self._onXHRProgress()
- }
- }
- xhr.onerror = function () {
- if (self._destroyed)
- return
- self.emit('error', new Error('XHR error'))
- }
- try {
- xhr.send(body)
- } catch (err) {
- process.nextTick(function () {
- self.emit('error', err)
- })
- return
- }
- }
- }
- /**
- * Checks if xhr.status is readable and non-zero, indicating no error.
- * Even though the spec says it should be available in readyState 3,
- * accessing it throws an exception in IE8
- */
- function statusValid (xhr) {
- try {
- var status = xhr.status
- return (status !== null && status !== 0)
- } catch (e) {
- return false
- }
- }
- ClientRequest.prototype._onXHRProgress = function () {
- var self = this
- if (!statusValid(self._xhr) || self._destroyed)
- return
- if (!self._response)
- self._connect()
- self._response._onXHRProgress()
- }
- ClientRequest.prototype._connect = function () {
- var self = this
- if (self._destroyed)
- return
- self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode)
- self.emit('response', self._response)
- }
- ClientRequest.prototype._write = function (chunk, encoding, cb) {
- var self = this
- self._body.push(chunk)
- cb()
- }
- ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
- var self = this
- self._destroyed = true
- if (self._response)
- self._response._destroyed = true
- if (self._xhr)
- self._xhr.abort()
- // Currently, there isn't a way to truly abort a fetch.
- // If you like bikeshedding, see https://github.com/whatwg/fetch/issues/27
- }
- ClientRequest.prototype.end = function (data, encoding, cb) {
- var self = this
- if (typeof data === 'function') {
- cb = data
- data = undefined
- }
- stream.Writable.prototype.end.call(self, data, encoding, cb)
- }
- ClientRequest.prototype.flushHeaders = function () {}
- ClientRequest.prototype.setTimeout = function () {}
- ClientRequest.prototype.setNoDelay = function () {}
- ClientRequest.prototype.setSocketKeepAlive = function () {}
- // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
- var unsafeHeaders = [
- 'accept-charset',
- 'accept-encoding',
- 'access-control-request-headers',
- 'access-control-request-method',
- 'connection',
- 'content-length',
- 'cookie',
- 'cookie2',
- 'date',
- 'dnt',
- 'expect',
- 'host',
- 'keep-alive',
- 'origin',
- 'referer',
- 'te',
- 'trailer',
- 'transfer-encoding',
- 'upgrade',
- 'user-agent',
- 'via'
- ]
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(13), __webpack_require__(4)))
- /***/ },
- /* 575 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(221)
- var inherits = __webpack_require__(2)
- var stream = __webpack_require__(225)
- var rStates = exports.readyStates = {
- UNSENT: 0,
- OPENED: 1,
- HEADERS_RECEIVED: 2,
- LOADING: 3,
- DONE: 4
- }
- var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) {
- var self = this
- stream.Readable.call(self)
- self._mode = mode
- self.headers = {}
- self.rawHeaders = []
- self.trailers = {}
- self.rawTrailers = []
- // Fake the 'close' event, but only once 'end' fires
- self.on('end', function () {
- // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
- process.nextTick(function () {
- self.emit('close')
- })
- })
- if (mode === 'fetch') {
- self._fetchResponse = response
- self.url = response.url
- self.statusCode = response.status
- self.statusMessage = response.statusText
- // backwards compatible version of for (<item> of <iterable>):
- // for (var <item>,_i,_it = <iterable>[Symbol.iterator](); <item> = (_i = _it.next()).value,!_i.done;)
- for (var header, _i, _it = response.headers[Symbol.iterator](); header = (_i = _it.next()).value, !_i.done;) {
- self.headers[header[0].toLowerCase()] = header[1]
- self.rawHeaders.push(header[0], header[1])
- }
- // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed
- var reader = response.body.getReader()
- function read () {
- reader.read().then(function (result) {
- if (self._destroyed)
- return
- if (result.done) {
- self.push(null)
- return
- }
- self.push(new Buffer(result.value))
- read()
- })
- }
- read()
- } else {
- self._xhr = xhr
- self._pos = 0
- self.url = xhr.responseURL
- self.statusCode = xhr.status
- self.statusMessage = xhr.statusText
- var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
- headers.forEach(function (header) {
- var matches = header.match(/^([^:]+):\s*(.*)/)
- if (matches) {
- var key = matches[1].toLowerCase()
- if (key === 'set-cookie') {
- if (self.headers[key] === undefined) {
- self.headers[key] = []
- }
- self.headers[key].push(matches[2])
- } else if (self.headers[key] !== undefined) {
- self.headers[key] += ', ' + matches[2]
- } else {
- self.headers[key] = matches[2]
- }
- self.rawHeaders.push(matches[1], matches[2])
- }
- })
- self._charset = 'x-user-defined'
- if (!capability.overrideMimeType) {
- var mimeType = self.rawHeaders['mime-type']
- if (mimeType) {
- var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
- if (charsetMatch) {
- self._charset = charsetMatch[1].toLowerCase()
- }
- }
- if (!self._charset)
- self._charset = 'utf-8' // best guess
- }
- }
- }
- inherits(IncomingMessage, stream.Readable)
- IncomingMessage.prototype._read = function () {}
- IncomingMessage.prototype._onXHRProgress = function () {
- var self = this
- var xhr = self._xhr
- var response = null
- switch (self._mode) {
- case 'text:vbarray': // For IE9
- if (xhr.readyState !== rStates.DONE)
- break
- try {
- // This fails in IE8
- response = new global.VBArray(xhr.responseBody).toArray()
- } catch (e) {}
- if (response !== null) {
- self.push(new Buffer(response))
- break
- }
- // Falls through in IE8
- case 'text':
- try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
- response = xhr.responseText
- } catch (e) {
- self._mode = 'text:vbarray'
- break
- }
- if (response.length > self._pos) {
- var newData = response.substr(self._pos)
- if (self._charset === 'x-user-defined') {
- var buffer = new Buffer(newData.length)
- for (var i = 0; i < newData.length; i++)
- buffer[i] = newData.charCodeAt(i) & 0xff
- self.push(buffer)
- } else {
- self.push(newData, self._charset)
- }
- self._pos = response.length
- }
- break
- case 'arraybuffer':
- if (xhr.readyState !== rStates.DONE)
- break
- response = xhr.response
- self.push(new Buffer(new Uint8Array(response)))
- break
- case 'moz-chunked-arraybuffer': // take whole
- response = xhr.response
- if (xhr.readyState !== rStates.LOADING || !response)
- break
- self.push(new Buffer(new Uint8Array(response)))
- break
- case 'ms-stream':
- response = xhr.response
- if (xhr.readyState !== rStates.LOADING)
- break
- var reader = new global.MSStreamReader()
- reader.onprogress = function () {
- if (reader.result.byteLength > self._pos) {
- self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
- self._pos = reader.result.byteLength
- }
- }
- reader.onload = function () {
- self.push(null)
- }
- // reader.onerror = ??? // TODO: this
- reader.readAsArrayBuffer(response)
- break
- }
- // The ms-stream case handles end separately in reader.onload()
- if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
- self.push(null)
- }
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(1).Buffer, __webpack_require__(13)))
- /***/ },
- /* 576 */
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- // a passthrough stream.
- // basically just the most minimal sort of Transform stream.
- // Every written chunk gets output as-is.
- 'use strict';
- module.exports = PassThrough;
- var Transform = __webpack_require__(223);
- /*<replacement>*/
- var util = __webpack_require__(14);
- util.inherits = __webpack_require__(2);
- /*</replacement>*/
- util.inherits(PassThrough, Transform);
- function PassThrough(options) {
- if (!(this instanceof PassThrough)) return new PassThrough(options);
- Transform.call(this, options);
- }
- PassThrough.prototype._transform = function (chunk, encoding, cb) {
- cb(null, chunk);
- };
- /***/ },
- /* 577 */
- /***/ function(module, exports, __webpack_require__) {
- var Buffer = __webpack_require__(1).Buffer
- module.exports = function (buf) {
- // If the buffer is backed by a Uint8Array, a faster version will work
- if (buf instanceof Uint8Array) {
- // If the buffer isn't a subarray, return the underlying ArrayBuffer
- if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
- return buf.buffer
- } else if (typeof buf.buffer.slice === 'function') {
- // Otherwise we need to get a proper copy
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
- }
- }
- if (Buffer.isBuffer(buf)) {
- // This is the slow version that will work with any Buffer
- // implementation (even in old browsers)
- var arrayCopy = new Uint8Array(buf.length)
- var len = buf.length
- for (var i = 0; i < len; i++) {
- arrayCopy[i] = buf[i]
- }
- return arrayCopy.buffer
- } else {
- throw new Error('Argument must be a Buffer')
- }
- }
- /***/ },
- /* 578 */
- /***/ function(module, exports) {
- "use strict";
- 'use strict';
- module.exports = {
- isString: function(arg) {
- return typeof(arg) === 'string';
- },
- isObject: function(arg) {
- return typeof(arg) === 'object' && arg !== null;
- },
- isNull: function(arg) {
- return arg === null;
- },
- isNullOrUndefined: function(arg) {
- return arg == null;
- }
- };
- /***/ },
- /* 579 */
- /***/ function(module, exports) {
- module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object'
- && typeof arg.copy === 'function'
- && typeof arg.fill === 'function'
- && typeof arg.readUInt8 === 'function';
- }
- /***/ },
- /* 580 */
- /***/ function(module, exports) {
- module.exports = read
- var MSB = 0x80
- , REST = 0x7F
- function read(buf, offset) {
- var res = 0
- , offset = offset || 0
- , shift = 0
- , counter = offset
- , b
- , l = buf.length
- do {
- if(counter >= l) {
- read.bytes = 0
- read.bytesRead = 0 // DEPRECATED
- return undefined
- }
- b = buf[counter++]
- res += shift < 28
- ? (b & REST) << shift
- : (b & REST) * Math.pow(2, shift)
- shift += 7
- } while (b >= MSB)
- read.bytes = counter - offset
- return res
- }
- /***/ },
- /* 581 */
- /***/ function(module, exports) {
- module.exports = encode
- var MSB = 0x80
- , REST = 0x7F
- , MSBALL = ~REST
- , INT = Math.pow(2, 31)
- function encode(num, out, offset) {
- out = out || []
- offset = offset || 0
- var oldOffset = offset
- while(num >= INT) {
- out[offset++] = (num & 0xFF) | MSB
- num /= 128
- }
- while(num & MSBALL) {
- out[offset++] = (num & 0xFF) | MSB
- num >>>= 7
- }
- out[offset] = num | 0
-
- encode.bytes = offset - oldOffset + 1
-
- return out
- }
- /***/ },
- /* 582 */
- /***/ function(module, exports) {
- var N1 = Math.pow(2, 7)
- var N2 = Math.pow(2, 14)
- var N3 = Math.pow(2, 21)
- var N4 = Math.pow(2, 28)
- var N5 = Math.pow(2, 35)
- var N6 = Math.pow(2, 42)
- var N7 = Math.pow(2, 49)
- var N8 = Math.pow(2, 56)
- var N9 = Math.pow(2, 63)
- module.exports = function (value) {
- return (
- value < N1 ? 1
- : value < N2 ? 2
- : value < N3 ? 3
- : value < N4 ? 4
- : value < N5 ? 5
- : value < N6 ? 6
- : value < N7 ? 7
- : value < N8 ? 8
- : value < N9 ? 9
- : 10
- )
- }
- /***/ },
- /* 583 */
- /***/ function(module, exports, __webpack_require__) {
- var indexOf = __webpack_require__(512);
- var Object_keys = function (obj) {
- if (Object.keys) return Object.keys(obj)
- else {
- var res = [];
- for (var key in obj) res.push(key)
- return res;
- }
- };
- var forEach = function (xs, fn) {
- if (xs.forEach) return xs.forEach(fn)
- else for (var i = 0; i < xs.length; i++) {
- fn(xs[i], i, xs);
- }
- };
- var defineProp = (function() {
- try {
- Object.defineProperty({}, '_', {});
- return function(obj, name, value) {
- Object.defineProperty(obj, name, {
- writable: true,
- enumerable: false,
- configurable: true,
- value: value
- })
- };
- } catch(e) {
- return function(obj, name, value) {
- obj[name] = value;
- };
- }
- }());
- var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
- 'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
- 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
- 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
- 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
- function Context() {}
- Context.prototype = {};
- var Script = exports.Script = function NodeScript (code) {
- if (!(this instanceof Script)) return new Script(code);
- this.code = code;
- };
- Script.prototype.runInContext = function (context) {
- if (!(context instanceof Context)) {
- throw new TypeError("needs a 'context' argument.");
- }
-
- var iframe = document.createElement('iframe');
- if (!iframe.style) iframe.style = {};
- iframe.style.display = 'none';
-
- document.body.appendChild(iframe);
-
- var win = iframe.contentWindow;
- var wEval = win.eval, wExecScript = win.execScript;
- if (!wEval && wExecScript) {
- // win.eval() magically appears when this is called in IE:
- wExecScript.call(win, 'null');
- wEval = win.eval;
- }
-
- forEach(Object_keys(context), function (key) {
- win[key] = context[key];
- });
- forEach(globals, function (key) {
- if (context[key]) {
- win[key] = context[key];
- }
- });
-
- var winKeys = Object_keys(win);
- var res = wEval.call(win, this.code);
-
- forEach(Object_keys(win), function (key) {
- // Avoid copying circular objects like `top` and `window` by only
- // updating existing context properties or new properties in the `win`
- // that was only introduced after the eval.
- if (key in context || indexOf(winKeys, key) === -1) {
- context[key] = win[key];
- }
- });
- forEach(globals, function (key) {
- if (!(key in context)) {
- defineProp(context, key, win[key]);
- }
- });
-
- document.body.removeChild(iframe);
-
- return res;
- };
- Script.prototype.runInThisContext = function () {
- return eval(this.code); // maybe...
- };
- Script.prototype.runInNewContext = function (context) {
- var ctx = Script.createContext(context);
- var res = this.runInContext(ctx);
- forEach(Object_keys(ctx), function (key) {
- context[key] = ctx[key];
- });
- return res;
- };
- forEach(Object_keys(Script.prototype), function (name) {
- exports[name] = Script[name] = function (code) {
- var s = Script(code);
- return s[name].apply(s, [].slice.call(arguments, 1));
- };
- });
- exports.createScript = function (code) {
- return exports.Script(code);
- };
- exports.createContext = Script.createContext = function (context) {
- var copy = new Context();
- if(typeof context === 'object') {
- forEach(Object_keys(context), function (key) {
- copy[key] = context[key];
- });
- }
- return copy;
- };
- /***/ },
- /* 584 */
- /***/ function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {var isNode = !global.window
- if (isNode) {
- module.exports = __webpack_require__(587)
- } else {
- module.exports = __webpack_require__(131)
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
- /***/ },
- /* 585 */
- /***/ function(module, exports) {
- /* (ignored) */
- /***/ },
- /* 586 */
- /***/ function(module, exports) {
- /* (ignored) */
- /***/ },
- /* 587 */
- /***/ function(module, exports) {
- /* (ignored) */
- /***/ },
- /* 588 */
- /***/ function(module, exports, __webpack_require__) {
- __webpack_require__(230);
- module.exports = __webpack_require__(229);
- /***/ }
- /******/ ]);
- //# sourceMappingURL=index.js.map
- var EmbarkJS =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId])
- /******/ return installedModules[moduleId].exports;
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ exports: {},
- /******/ id: moduleId,
- /******/ loaded: false
- /******/ };
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/ // Flag the module as loaded
- /******/ module.loaded = true;
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(0);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ function(module, exports) {
- /*jshint esversion: 6 */
- //var Ipfs = require('./ipfs.js');
- var EmbarkJS = {
- };
- EmbarkJS.Contract = function(options) {
- var self = this;
- var i, abiElement;
- this.abi = options.abi;
- this.address = options.address;
- this.code = '0x' + options.code;
- this.web3 = options.web3 || web3;
- var ContractClass = this.web3.eth.contract(this.abi);
- this.eventList = [];
- if (this.abi) {
- for (i = 0; i < this.abi.length; i++) {
- abiElement = this.abi[i];
- if (abiElement.type === 'event') {
- this.eventList.push(abiElement.name);
- }
- }
- }
- var messageEvents = function() {
- this.cb = function() {};
- };
- messageEvents.prototype.then = function(cb) {
- this.cb = cb;
- };
- messageEvents.prototype.error = function(err) {
- return err;
- };
- this._originalContractObject = ContractClass.at(this.address);
- this._methods = Object.getOwnPropertyNames(this._originalContractObject).filter(function (p) {
- // TODO: check for forbidden properties
- if (self.eventList.indexOf(p) >= 0) {
- self[p] = function() {
- var promise = new messageEvents();
- var args = Array.prototype.slice.call(arguments);
- args.push(function(err, result) {
- if (err) {
- promise.error(err);
- } else {
- promise.cb(result);
- }
- });
- self._originalContractObject[p].apply(self._originalContractObject[p], args);
- return promise;
- };
- return true;
- } else if (typeof self._originalContractObject[p] === 'function') {
- self[p] = function(_args) {
- var args = Array.prototype.slice.call(arguments);
- var fn = self._originalContractObject[p];
- var props = self.abi.find((x) => x.name == p);
- var promise = new Promise(function(resolve, reject) {
- args.push(function(err, transaction) {
- promise.tx = transaction;
- if (err) {
- return reject(err);
- }
- var getConfirmation = function() {
- self.web3.eth.getTransactionReceipt(transaction, function(err, receipt) {
- if (err) {
- return reject(err);
- }
- if (receipt !== null) {
- return resolve(receipt);
- }
- setTimeout(getConfirmation, 1000);
- });
- };
- if (typeof(transaction) !== "string" || props.constant) {
- resolve(transaction);
- } else {
- getConfirmation();
- }
- });
- fn.apply(fn, args);
- });
- return promise;
- };
- return true;
- }
- return false;
- });
- };
- EmbarkJS.Contract.prototype.deploy = function(args, _options) {
- var self = this;
- var contractParams;
- var options = _options || {};
- contractParams = args || [];
- contractParams.push({
- from: this.web3.eth.accounts[0],
- data: this.code,
- gas: options.gas || 800000
- });
- var contractObject = this.web3.eth.contract(this.abi);
- var promise = new Promise(function(resolve, reject) {
- contractParams.push(function(err, transaction) {
- if (err) {
- reject(err);
- } else if (transaction.address !== undefined) {
- resolve(new EmbarkJS.Contract({abi: self.abi, code: self.code, address: transaction.address}));
- }
- });
- // returns promise
- // deploys contract
- // wraps it around EmbarkJS.Contract
- contractObject["new"].apply(contractObject, contractParams);
- });
-
- return promise;
- };
- EmbarkJS.IPFS = 'ipfs';
- EmbarkJS.Storage = {
- };
- EmbarkJS.Storage.setProvider = function(provider, options) {
- if (provider === 'ipfs') {
- this.currentStorage = EmbarkJS.Storage.IPFS;
- if (options === undefined) {
- this.ipfsConnection = IpfsApi('localhost', '5001');
- } else {
- this.ipfsConnection = IpfsApi(options.server, options.port);
- }
- } else {
- throw Error('unknown provider');
- }
- };
- EmbarkJS.Storage.saveText = function(text) {
- var self = this;
- if (!this.ipfsConnection) {
- this.setProvider('ipfs');
- }
- var promise = new Promise(function(resolve, reject) {
- self.ipfsConnection.add((new self.ipfsConnection.Buffer(text)), function(err, result) {
- if (err) {
- reject(err);
- } else {
- resolve(result[0].path);
- }
- });
- });
- return promise;
- };
- EmbarkJS.Storage.uploadFile = function(inputSelector) {
- var self = this;
- var file = inputSelector[0].files[0];
- if (file === undefined) {
- throw new Error('no file found');
- }
- if (!this.ipfsConnection) {
- this.setProvider('ipfs');
- }
- var promise = new Promise(function(resolve, reject) {
- var reader = new FileReader();
- reader.onloadend = function() {
- var fileContent = reader.result;
- var buffer = self.ipfsConnection.Buffer.from(fileContent);
- self.ipfsConnection.add(buffer, function(err, result) {
- if (err) {
- reject(err);
- } else {
- resolve(result[0].path);
- }
- });
- };
- reader.readAsArrayBuffer(file);
- });
- return promise;
- };
- EmbarkJS.Storage.get = function(hash) {
- var self = this;
- // TODO: detect type, then convert if needed
- //var ipfsHash = web3.toAscii(hash);
- if (!this.ipfsConnection) {
- this.setProvider('ipfs');
- }
- var promise = new Promise(function(resolve, reject) {
- self.ipfsConnection.object.get([hash]).then(function(node) {
- resolve(node.data);
- });
- });
- return promise;
- };
- EmbarkJS.Storage.getUrl = function(hash) {
- //var ipfsHash = web3.toAscii(hash);
- return 'http://localhost:8080/ipfs/' + hash;
- };
- EmbarkJS.Messages = {
- };
- EmbarkJS.Messages.setProvider = function(provider, options) {
- var self = this;
- var ipfs;
- if (provider === 'whisper') {
- this.currentMessages = EmbarkJS.Messages.Whisper;
- if (typeof variable === 'undefined') {
- if (options === undefined) {
- web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
- } else {
- web3 = new Web3(new Web3.providers.HttpProvider("http://" + options.server + ':' + options.port));
- }
- }
- web3.version.getWhisper(function(err, res) {
- if (err) {
- console.log("whisper not available");
- } else {
- self.currentMessages.identity = web3.shh.newIdentity();
- }
- });
- } else if (provider === 'orbit') {
- this.currentMessages = EmbarkJS.Messages.Orbit;
- if (options === undefined) {
- ipfs = HaadIpfsApi('localhost', '5001');
- } else {
- ipfs = HaadIpfsApi(options.server, options.port);
- }
- this.currentMessages.orbit = new Orbit(ipfs);
- this.currentMessages.orbit.connect(web3.eth.accounts[0]);
- } else {
- throw Error('unknown provider');
- }
- };
- EmbarkJS.Messages.sendMessage = function(options) {
- return this.currentMessages.sendMessage(options);
- };
- EmbarkJS.Messages.listenTo = function(options) {
- return this.currentMessages.listenTo(options);
- };
- EmbarkJS.Messages.Whisper = {
- };
- EmbarkJS.Messages.Whisper.sendMessage = function(options) {
- var topics = options.topic || options.topics;
- var data = options.data || options.payload;
- var identity = options.identity || this.identity || web3.shh.newIdentity();
- var ttl = options.ttl || 100;
- var priority = options.priority || 1000;
- var _topics;
- if (topics === undefined) {
- throw new Error("missing option: topic");
- }
- if (data === undefined) {
- throw new Error("missing option: data");
- }
- // do fromAscii to each topics unless it's already a string
- if (typeof topics === 'string') {
- _topics = [web3.fromAscii(topics)];
- } else {
- // TODO: replace with es6 + babel;
- for (var i = 0; i < topics.length; i++) {
- _topics.push(web3.fromAscii(topics[i]));
- }
- }
- topics = _topics;
- var payload = JSON.stringify(data);
- var message = {
- from: identity,
- topics: topics,
- payload: web3.fromAscii(payload),
- ttl: ttl,
- priority: priority
- };
- return web3.shh.post(message, function() {});
- };
- EmbarkJS.Messages.Whisper.listenTo = function(options) {
- var topics = options.topic || options.topics;
- var _topics = [];
- if (typeof topics === 'string') {
- _topics = [topics];
- } else {
- // TODO: replace with es6 + babel;
- for (var i = 0; i < topics.length; i++) {
- _topics.push(topics[i]);
- }
- }
- topics = _topics;
- var filterOptions = {
- topics: topics
- };
- var messageEvents = function() {
- this.cb = function() {};
- };
- messageEvents.prototype.then = function(cb) {
- this.cb = cb;
- };
- messageEvents.prototype.error = function(err) {
- return err;
- };
- messageEvents.prototype.stop = function() {
- this.filter.stopWatching();
- };
- var promise = new messageEvents();
- var filter = web3.shh.filter(filterOptions, function(err, result) {
- var payload = JSON.parse(web3.toAscii(result.payload));
- var data;
- if (err) {
- promise.error(err);
- } else {
- data = {
- topic: topics,
- data: payload,
- from: result.from,
- time: (new Date(result.sent * 1000))
- };
- promise.cb(payload, data, result);
- }
- });
- promise.filter = filter;
- return promise;
- };
- EmbarkJS.Messages.Orbit = {
- };
- EmbarkJS.Messages.Orbit.sendMessage = function(options) {
- var topics = options.topic || options.topics;
- var data = options.data || options.payload;
- if (topics === undefined) {
- throw new Error("missing option: topic");
- }
- if (data === undefined) {
- throw new Error("missing option: data");
- }
- if (typeof topics === 'string') {
- topics = topics;
- } else {
- // TODO: better to just send to different channels instead
- topics = topics.join(',');
- }
- this.orbit.join(topics);
- var payload = JSON.stringify(data);
- this.orbit.send(topics, data);
- };
- EmbarkJS.Messages.Orbit.listenTo = function(options) {
- var self = this;
- var topics = options.topic || options.topics;
- if (typeof topics === 'string') {
- topics = topics;
- } else {
- topics = topics.join(',');
- }
- this.orbit.join(topics);
- var messageEvents = function() {
- this.cb = function() {};
- };
- messageEvents.prototype.then = function(cb) {
- this.cb = cb;
- };
- messageEvents.prototype.error = function(err) {
- return err;
- };
- var promise = new messageEvents();
- this.orbit.events.on('message', (channel, message) => {
- // TODO: looks like sometimes it's receving messages from all topics
- if (topics !== channel) return;
- self.orbit.getPost(message.payload.value, true).then((post) => {
- var data = {
- topic: channel,
- data: post.content,
- from: post.meta.from.name,
- time: (new Date(post.meta.ts))
- };
- promise.cb(post.content, data, post);
- });
- });
- return promise;
- };
- module.exports = EmbarkJS;
- /***/ }
- /******/ ]);
- if (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {
- web3 = new Web3(web3.currentProvider);
- } else if (typeof Web3 !== 'undefined') {
- web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
- }
- web3.eth.defaultAccount = web3.eth.accounts[0];
- Move = new EmbarkJS.Contract({abi: [], address: '0xe609402b206bc80516cff106b2bc5ab530a0f886', code: '6060604052346000575b60358060166000396000f30060606040525b60005600a165627a7a72305820dc0fd30165702693e33a6777c52dcccacc439e55f147652d92a061e21edf7b000029', gasEstimates: {"creation":[58,10600],"external":{},"internal":{}}});
- 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":{}}});
- EmbarkJS.Storage.setProvider('ipfs', {server: 'localhost', port: '5001'});
- EmbarkJS.Messages.setProvider('whisper');
- /*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
- !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;
- 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){
- 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});
- /*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
- * Licensed under the MIT license
- */
- 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");
- 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);
- // When document is ready initialize app
- $(document).ready(function() {
-
- var filter = web3.eth.filter('latest');
- filter.watch(function(err, res){
- if(!err){
- updateUI();
- }
- else{
- console.error("!!!!!!Error Happened!");
- filter.stopWatching();
- }
- });
- /// INIT Whisper
- web3.Lib.initWhisper()
- .then(function(w){
- web3.Whisper = w;
- });
- createUI();
- updateUI();
- });
- ///////////////////
- /// UI ////////////
- ///////////////////
- var matchhash;
- var maphash;
- var opAccount;
- var selectBox;
- function createUI(){
- selectBox = document.getElementById("accselector");
- for (var i = 0; i<web3.eth.accounts.length; i++){
- var opt = document.createElement('option');
- opt.value = i;
- opt.innerHTML = web3.eth.accounts[i];
- selectBox.appendChild(opt);
- }
- selectBox.onchange = function(){
- web3.eth.defaultAccount = web3.eth.accounts[selectBox.value];
- updateUI(selectBox.value);
- }
- $("#showMapBtn").click(function(){
- updateMapTable(web3.Game.getMapArray());
- });
- $("#createMatchBtn").click(function(){
- var stake = $("#stakeTxt").val();
- createMatch(stake);
- });
- $("#joinMatchBtn").click(function(){
- var stake = parseInt($("#stakeTxt").val());
- var matchhash = $("#matchhashTxt").val();
- joinMatch(stake, matchhash);
- });
- $("#startGameBtn").click(function(){
- startGame();
- });
- $("#sendSelectMoveBtn").click(function(){
- sendSelectMove();
- });
- $("#sendBetMoveBtn").click(function(){
- sendBetMove();
- });
- $("#sendCallMoveBtn").click(function(){
- sendCallMove();
- });
- $("#sendFoldMoveBtn").click(function(){
- sendFoldMove();
- });
- $("#sendProofMoveBtn").click(function(){
- sendProofMove();
- });
- }
- function updateUI(accindex){
- updateForAccount();
- }
- function updateGameUI(state){
- $("#mycoins").html(state.coins[web3.eth.defaultAccount]);
- $("#opcoins").html(state.coins[web3.eth.opponentAccount]);
- $("#pot").html(state.pot);
- $("#round").html(state.round);
-
- $("#mybets").html(state.bets[web3.eth.defaultAccount]);
- $("#opbets").html(state.bets[web3.eth.opponentAccount]);
- var sums = web3.Game.findSums();
- $("#mysum").html(sums[web3.eth.defaultAccount]);
- $("#opsum").html(sums[web3.eth.opponentAccount]);
- updateMapTable(web3.Game.getMapArray(), state);
- // console.log("Selected for me: ");
- // console.log(state.selected[web3.eth.defaultAccount]);
- // console.log("Selected for opponent: ");
- // console.log(state.selected[web3.eth.opponentAccount]);
- }
- function updateForAccount(){
- var ethaddr = web3.eth.defaultAccount;
- $("#ethaddr").html(ethaddr);
- var ethbal = web3.eth.getBalance(ethaddr);
- $("#ethbal").html(web3.fromWei(ethbal, "ether").toNumber());
- var blockNumber = web3.eth.blockNumber;
- $("#block").html("#"+blockNumber);
- dbname = web3.db.DBNAME = "CUSTOMDBFOR"+web3.eth.defaultAccount;
- Padomima.amInMatch().then(function(res){
- $("#inmatch").html(res? "Yes": "No");
- if(res){
- Padomima.getMyMatch().then(function(res){
- matchhash = res;
- $("#matchhash").html(res);
- });
- Padomima.getMyStake().then(function(res){
- res = web3.fromWei(res);
- $("#stakeTxt").val(res);
- });
- Padomima.getMyMap().then(function(res){
- maphash = res;
- $("#maphash").html(res);
- });
- Padomima.getMyOpponent().then(function(res){
- opAccount = res;
- web3.eth.opponentAccount = res;
- $("#opponentHash").html(res);
- });
- }
- });
- }
- function updateMapTable(map,state){
- if(typeof state == "undefined"){
- state = {
- selected:{
- [web3.eth.defaultAccount]:[0,0,0,0,0,0],
- [web3.eth.opponentAccount]:[0,0,0,0,0,0]
- }
- };
- }
-
- state = web3.Game.applyStateRotation(state);
- var mapTable = $("#mapTable")[0];
- if(mapTable.hasChildNodes())
- mapTable.removeChild(mapTable.children[0]);
- var tbody = document.createElement("tbody");
- for(var i=0;i<6;i++){
- var tr = document.createElement("tr");
-
- if(state.selected[web3.eth.defaultAccount][i]){
- $(tr).addClass("green");
- }
- for (var j = 0; j < 6; j++) {
- var td = document.createElement("td");
- td.innerHTML = map[i][j];
- if(web3.Game.haveSelected(j)){
- $(td).addClass("green");
- }
- if(state.selected[web3.eth.opponentAccount][j]){
- $(td).addClass("red");
- }
- if(web3.Game.isMyNumber(i,j)){
- $(td).addClass("my-number");
- }
- if(web3.Game.isOpponentNumber(i,j)){
- $(td).addClass("op-number");
- }
- tr.appendChild(td);
- }
- tbody.appendChild(tr);
- }
- mapTable.appendChild(tbody);
- }
- /////////////////////
- //// CALCULATIONS ///
- /////////////////////
- // function hashToNumbers(hash){
- // var nums = [];
- // hash = hash.substr(2);
- // for(var i=0;i<32;i++){
- // var b = hash.substr(2*i, 2*i+2);
- // nums.push(web3.toDecimal('0x'+b));
- // }
- // return nums;
- // }
- // /////////////////////
- // function calculateMapArray(){
- // console.log("Calculating map array for map hash: " + maphash);
- // var first32Hash = maphash,
- // second32Hash = web3.sha3(first32Hash),
- // third32Hash = web3.sha3(second32Hash);
- // // Make hash to numbers
- // var numbers = hashToNumbers(first32Hash)
- // .concat(hashToNumbers(second32Hash))
- // .concat(hashToNumbers(third32Hash));
- // // init mapArray
- // var maparray = [];
- // for(var i=0;i<6;i++){
- // maparray.push([]);
- // for(var j=0;j<6;j++){
- // maparray[i][j] = i*6 + j + 1;
- // }
- // }
- // ///
- // /// helper local swapPosition
- // function swapPositions(a,b){
- // a = a % 36
- // ai = a % 6;
- // aj = parseInt(a / 6);
-
- // b = b % 36
- // bi = b % 6;
- // bj = parseInt(b / 6);
- // var temp = maparray[ai][aj];
- // maparray[ai][aj] = maparray[bi][bj];
- // maparray[bi][bj] = temp;
- // }
- // ///
- // for(var i=0;i<numbers.length;i++){
- // swapPositions(i, numbers[i]);
- // }
- // ////////////////////////////////
- // console.log(maparray);
- // ////////////////////////////////
- // return maparray;
- // }
- ///////////////////// CUSTOM NET ////
- function createMatch(stake){
- var createMatchData = Padomima.createMatch({value: web3.toWei(stake, 'ether'), gas: 2255200});
- console.log(createMatchData);
- return createMatchData;
- //return web3.eth.sendTransaction({
- // 'from': web3.eth.defaultAccount,
- // 'contractAddress': Padomima.address,
- // 'to': Padomima.address,
- // 'value':web3.toWei(stake, 'ether'),
- // 'data': createMatchData,
- // 'gas': 4000000
- // });
- }
- function joinMatch(stake, h){
- var joinMatchData = Padomima.joinMatch(h , {value: web3.toWei(stake, 'ether'), gas: 2255200});
- console.log(joinMatchData);
- return web3.eth.sendTransaction({
- 'from': web3.eth.defaultAccount,
- 'contractAddress': Padomima.address,
- 'to': Padomima.address,
- 'value':web3.toWei(stake, 'ether'),
- 'data': joinMatchData,
- 'gas': 4000000
- });
- }
- function getMatch(){
- Padomima.getMyMatch().then(function(res){
- console.log("MY Match Hash: " );
- console.log(res);
- });
- }
- function getMap(){
- Padomima.getMyMap().then(function(res){
- console.log("MY Map Hash: " );
- console.log(res);
- });
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- /////////// START GAME PHASE ///////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- var dbname = web3.db.DBNAME = "CUSTOMDBFOR"+web3.eth.defaultAccount;
- function getDB(key){
- return web3.db.getString(dbname,key);
- }
- function getDBJSON(key){
- return JSON.parse(web3.db.getString(dbname,key));
- }
- function saveDBJSON(d){
- return;
- if(!web3.db.getString(dbname,"currentIndex"))
- web3.db.putString(dbname,"currentIndex","0");
- var cid = getDB("currentIndex");
- web3.db.putString(dbname, "Index" + cid, JSON.stringify(d));
- web3.db.putString(dbname, "currentIndex", ""+(parseInt(cid)+1) );
- }
- function saveDB(key, data){
- web3.db.putString(dbname, key, data);
- }
- function saveACK(data){
- // save ACK and mark it on UI
- saveDBJSON({
- who : web3.eth.defaultAccount,
- ack : data,
- opponent: opAccount
- });
- // update Current Game State to the next one because we have all the SIGNED information needed until here!
- return;
- }
- function saveOpponentMove(data){
- // save move and mark it on UI
- saveDBJSON({
- who : opAccount,
- ack : data
- });
- return;
- }
- function moveRecieved(data){
- console.log("Recieved Data from Game Channel:");
- console.log(data);
- if(web3.Game.performMove(data))
- return data;
- //web3.Game.communicateState();
- return false;
- }
- function stateHandler(){
- console.log("State changed!");
- console.log(web3.Game.getState());
- updateGameUI(web3.Game.getState());
- }
- function roundHandler(){
- console.log("Round changed!");
- updateGameUI(web3.Game.getState());
- }
- function startGame() {
- // body...
- $("#GameUI").removeClass("hidden");
- // Establish whisper connection //
- // web3.Lib.initWhisper(maphash.substr(2))
- // .then(function(w){
- // w.setFunction(moveRecieved);
- // web3.GWhisper = w;
- // });
- web3.NetLib.init();
- web3.NetLib.setChannel(maphash.substr(2));
- web3.NetLib.setSolo(web3.eth.opponentAccount);
- //web3.NetLib.addInterceptor(web3.Game.getStateInterceptor());
- web3.NetLib.setSoloInterceptor();
- web3.NetLib.setProofInterceptor();
-
- web3.NetLib.addInterceptor(moveRecieved);
- web3.NetLib.startListening();
- web3.Game.init(maphash);
- web3.Game.setOnStateChange(stateHandler);
- web3.Game.setOnRoundChange(roundHandler);
- Padomima.getMapRotation().then(function(res){
- web3.Game.setMapRotation(res);
- updateMapTable(web3.Game.getMapArray());
- web3.Game.loadFromDB();
- updateGameUI(web3.Game.getState());
- });
- }
- function sendSelectMove(){
- var mycol = parseInt($("#columnForMe").val())-1;
- var opcol = parseInt($("#columnForOp").val())-1;
- var move = web3.Game.createSelectMove(mycol,opcol);
- web3.Game.performMove(move.move);
- web3.NetLib.sendPacketWaitForVerification(move.move);
- web3.Game.saveProof(move.proof.data.selectIndex % 4, move.proof);
- // var move = web3.sha3(''+mycolR).substr(2) + "+" + web3.sha3(''+opcolR).substr(2);
- // var moveSignature = web3.Lib.signData(web3.eth.defaultAccount, move);
-
- // console.log("Move Signature : ");
- // console.log(moveSignature);
-
- // console.log("Verifying locally...");
- // var ver = web3.Lib.verifySignature(web3.eth.defaultAccount, moveSignature);
- // console.log(ver);
- // Send through Whisper
- //web3.GWhisper.send({ who: web3.eth.defaultAccount, signature : moveSignature })
- }
- function sendBetMove(){
- var am = parseInt($("#amount").val());
- var move = web3.Game.createBetMove(am);
- if(web3.Game.performMove(move))
- web3.NetLib.sendPacketWaitForVerification(move);
- }
- function sendCallMove(){
- var move = web3.Game.createCallMove();
- if(web3.Game.performMove(move))
- web3.NetLib.sendPacketWaitForVerification(move);
- }
- function sendFoldMove(){
- var move = web3.Game.createFoldMove();
- if(web3.Game.performMove(move))
- web3.NetLib.sendPacketWaitForVerification(move);
- }
- function sendProofMove(){
- var proofnum = parseInt($("#proofCol").val());
- var move = web3.Game.getProofMove(proofnum);
- if(web3.Game.performMove(move))
- web3.NetLib.sendPacketWaitForVerification(move);
- }
- /////////////////////////////////////////////////////////////////////////////
- /////////////// GAME HELPERS /////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- function findRandomBigNumber(num){
- var randomNumber = Math.floor(10000000000 + Math.random() * 90000000000);
- while(randomNumber % 6 != num){
- randomNumber++;
- }
- // console.log("Random Big Number for : " + num);
- // console.log(randomNumber);
- return randomNumber;
- }
- function printMoveStack(){
- console.log("---- Move Stack --------");
- var cid = getDB("currentIndex");
- for( var i = 0; i < cid; i ++ ){
- console.log(getDBJSON("Index" + i));
- }
- console.log("------------------------");
- }
- (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){
- web3.Utils = require("./index.js");
- },{"./index.js":2}],2:[function(require,module,exports){
- (function (Buffer){
- const createKeccakHash = require('keccak')
- const secp256k1 = require('secp256k1')
- const assert = require('assert')
- const rlp = require('rlp')
- const BN = require('bn.js')
- const createHash = require('create-hash')
- Object.assign(exports, require('ethjs-util'))
- /**
- * the max integer that this VM can handle (a ```BN```)
- * @var {BN} MAX_INTEGER
- */
- exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)
- /**
- * 2^256 (a ```BN```)
- * @var {BN} TWO_POW256
- */
- exports.TWO_POW256 = new BN('10000000000000000000000000000000000000000000000000000000000000000', 16)
- /**
- * SHA3-256 hash of null (a ```String```)
- * @var {String} SHA3_NULL_S
- */
- exports.SHA3_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
- /**
- * SHA3-256 hash of null (a ```Buffer```)
- * @var {Buffer} SHA3_NULL
- */
- exports.SHA3_NULL = Buffer.from(exports.SHA3_NULL_S, 'hex')
- /**
- * SHA3-256 of an RLP of an empty array (a ```String```)
- * @var {String} SHA3_RLP_ARRAY_S
- */
- exports.SHA3_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
- /**
- * SHA3-256 of an RLP of an empty array (a ```Buffer```)
- * @var {Buffer} SHA3_RLP_ARRAY
- */
- exports.SHA3_RLP_ARRAY = Buffer.from(exports.SHA3_RLP_ARRAY_S, 'hex')
- /**
- * SHA3-256 hash of the RLP of null (a ```String```)
- * @var {String} SHA3_RLP_S
- */
- exports.SHA3_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
- /**
- * SHA3-256 hash of the RLP of null (a ```Buffer```)
- * @var {Buffer} SHA3_RLP
- */
- exports.SHA3_RLP = Buffer.from(exports.SHA3_RLP_S, 'hex')
- /**
- * [`BN`](https://github.com/indutny/bn.js)
- * @var {Function}
- */
- exports.BN = BN
- /**
- * [`rlp`](https://github.com/ethereumjs/rlp)
- * @var {Function}
- */
- exports.rlp = rlp
- /**
- * [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)
- * @var {Object}
- */
- exports.secp256k1 = secp256k1
- /**
- * Returns a buffer filled with 0s
- * @method zeros
- * @param {Number} bytes the number of bytes the buffer should be
- * @return {Buffer}
- */
- exports.zeros = function (bytes) {
- return Buffer.allocUnsafe(bytes).fill(0)
- }
- /**
- * Left Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
- * Or it truncates the beginning if it exceeds.
- * @method lsetLength
- * @param {Buffer|Array} msg the value to pad
- * @param {Number} length the number of bytes the output should be
- * @param {Boolean} [right=false] whether to start padding form the left or right
- * @return {Buffer|Array}
- */
- exports.setLengthLeft = exports.setLength = function (msg, length, right) {
- var buf = exports.zeros(length)
- msg = exports.toBuffer(msg)
- if (right) {
- if (msg.length < length) {
- msg.copy(buf)
- return buf
- }
- return msg.slice(0, length)
- } else {
- if (msg.length < length) {
- msg.copy(buf, length - msg.length)
- return buf
- }
- return msg.slice(-length)
- }
- }
- /**
- * Right Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
- * Or it truncates the beginning if it exceeds.
- * @param {Buffer|Array} msg the value to pad
- * @param {Number} length the number of bytes the output should be
- * @return {Buffer|Array}
- */
- exports.setLengthRight = function (msg, length) {
- return exports.setLength(msg, length, true)
- }
- /**
- * Trims leading zeros from a `Buffer` or an `Array`
- * @param {Buffer|Array|String} a
- * @return {Buffer|Array|String}
- */
- exports.unpad = exports.stripZeros = function (a) {
- a = exports.stripHexPrefix(a)
- var first = a[0]
- while (a.length > 0 && first.toString() === '0') {
- a = a.slice(1)
- first = a[0]
- }
- return a
- }
- /**
- * 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.
- * @param {*} v the value
- */
- exports.toBuffer = function (v) {
- if (!Buffer.isBuffer(v)) {
- if (Array.isArray(v)) {
- v = Buffer.from(v)
- } else if (typeof v === 'string') {
- if (exports.isHexPrefixed(v)) {
- v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), 'hex')
- } else {
- v = Buffer.from(v)
- }
- } else if (typeof v === 'number') {
- v = exports.intToBuffer(v)
- } else if (v === null || v === undefined) {
- v = Buffer.allocUnsafe(0)
- } else if (v.toArray) {
- // converts a BN to a Buffer
- v = Buffer.from(v.toArray())
- } else {
- throw new Error('invalid type')
- }
- }
- return v
- }
- /**
- * Converts a `Buffer` to a `Number`
- * @param {Buffer} buf
- * @return {Number}
- * @throws If the input number exceeds 53 bits.
- */
- exports.bufferToInt = function (buf) {
- return new BN(exports.toBuffer(buf)).toNumber()
- }
- /**
- * Converts a `Buffer` into a hex `String`
- * @param {Buffer} buf
- * @return {String}
- */
- exports.bufferToHex = function (buf) {
- buf = exports.toBuffer(buf)
- return '0x' + buf.toString('hex')
- }
- /**
- * Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers.
- * @param {Buffer} num
- * @return {BN}
- */
- exports.fromSigned = function (num) {
- return new BN(num).fromTwos(256)
- }
- /**
- * Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers.
- * @param {BN} num
- * @return {Buffer}
- */
- exports.toUnsigned = function (num) {
- return Buffer.from(num.toTwos(256).toArray())
- }
- /**
- * Creates SHA-3 hash of the input
- * @param {Buffer|Array|String|Number} a the input data
- * @param {Number} [bits=256] the SHA width
- * @return {Buffer}
- */
- exports.sha3 = function (a, bits) {
- a = exports.toBuffer(a)
- if (!bits) bits = 256
- return createKeccakHash('keccak' + bits).update(a).digest()
- }
- /**
- * Creates SHA256 hash of the input
- * @param {Buffer|Array|String|Number} a the input data
- * @return {Buffer}
- */
- exports.sha256 = function (a) {
- a = exports.toBuffer(a)
- return createHash('sha256').update(a).digest()
- }
- /**
- * Creates RIPEMD160 hash of the input
- * @param {Buffer|Array|String|Number} a the input data
- * @param {Boolean} padded whether it should be padded to 256 bits or not
- * @return {Buffer}
- */
- exports.ripemd160 = function (a, padded) {
- a = exports.toBuffer(a)
- var hash = createHash('rmd160').update(a).digest()
- if (padded === true) {
- return exports.setLength(hash, 32)
- } else {
- return hash
- }
- }
- /**
- * Creates SHA-3 hash of the RLP encoded version of the input
- * @param {Buffer|Array|String|Number} a the input data
- * @return {Buffer}
- */
- exports.rlphash = function (a) {
- return exports.sha3(rlp.encode(a))
- }
- /**
- * Checks if the private key satisfies the rules of the curve secp256k1.
- * @param {Buffer} privateKey
- * @return {Boolean}
- */
- exports.isValidPrivate = function (privateKey) {
- return secp256k1.privateKeyVerify(privateKey)
- }
- /**
- * Checks if the public key satisfies the rules of the curve secp256k1
- * and the requirements of Ethereum.
- * @param {Buffer} publicKey The two points of an uncompressed key, unless sanitize is enabled
- * @param {Boolean} [sanitize=false] Accept public keys in other formats
- * @return {Boolean}
- */
- exports.isValidPublic = function (publicKey, sanitize) {
- if (publicKey.length === 64) {
- // Convert to SEC1 for secp256k1
- return secp256k1.publicKeyVerify(Buffer.concat([ Buffer.from([4]), publicKey ]))
- }
- if (!sanitize) {
- return false
- }
- return secp256k1.publicKeyVerify(publicKey)
- }
- /**
- * Returns the ethereum address of a given public key.
- * Accepts "Ethereum public keys" and SEC1 encoded keys.
- * @param {Buffer} pubKey The two points of an uncompressed key, unless sanitize is enabled
- * @param {Boolean} [sanitize=false] Accept public keys in other formats
- * @return {Buffer}
- */
- exports.pubToAddress = exports.publicToAddress = function (pubKey, sanitize) {
- pubKey = exports.toBuffer(pubKey)
- if (sanitize && (pubKey.length !== 64)) {
- pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
- }
- assert(pubKey.length === 64)
- // Only take the lower 160bits of the hash
- return exports.sha3(pubKey).slice(-20)
- }
- /**
- * Returns the ethereum public key of a given private key
- * @param {Buffer} privateKey A private key must be 256 bits wide
- * @return {Buffer}
- */
- var privateToPublic = exports.privateToPublic = function (privateKey) {
- privateKey = exports.toBuffer(privateKey)
- // skip the type flag and use the X, Y points
- return secp256k1.publicKeyCreate(privateKey, false).slice(1)
- }
- /**
- * Converts a public key to the Ethereum format.
- * @param {Buffer} publicKey
- * @return {Buffer}
- */
- exports.importPublic = function (publicKey) {
- publicKey = exports.toBuffer(publicKey)
- if (publicKey.length !== 64) {
- publicKey = secp256k1.publicKeyConvert(publicKey, false).slice(1)
- }
- return publicKey
- }
- /**
- * ECDSA sign
- * @param {Buffer} msgHash
- * @param {Buffer} privateKey
- * @return {Object}
- */
- exports.ecsign = function (msgHash, privateKey) {
- var sig = secp256k1.sign(msgHash, privateKey)
- var ret = {}
- ret.r = sig.signature.slice(0, 32)
- ret.s = sig.signature.slice(32, 64)
- ret.v = sig.recovery + 27
- return ret
- }
- /**
- * Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call.
- * The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign`
- * call for a given `message`, or fed to `ecrecover` along with a signature to recover the public key
- * used to produce the signature.
- * @param message
- * @returns {Buffer} hash
- */
- exports.hashPersonalMessage = function (message) {
- var prefix = exports.toBuffer('\u0019Ethereum Signed Message:\n' + message.length.toString())
- return exports.sha3(Buffer.concat([prefix, message]))
- }
- /**
- * ECDSA public key recovery from signature
- * @param {Buffer} msgHash
- * @param {Number} v
- * @param {Buffer} r
- * @param {Buffer} s
- * @return {Buffer} publicKey
- */
- exports.ecrecover = function (msgHash, v, r, s) {
- var signature = Buffer.concat([exports.setLength(r, 32), exports.setLength(s, 32)], 64)
- var recovery = v - 27
- if (recovery !== 0 && recovery !== 1) {
- throw new Error('Invalid signature v value')
- }
- var senderPubKey = secp256k1.recover(msgHash, signature, recovery)
- return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
- }
- /**
- * Convert signature parameters into the format of `eth_sign` RPC method
- * @param {Number} v
- * @param {Buffer} r
- * @param {Buffer} s
- * @return {String} sig
- */
- exports.toRpcSig = function (v, r, s) {
- // NOTE: with potential introduction of chainId this might need to be updated
- if (v !== 27 && v !== 28) {
- throw new Error('Invalid recovery id')
- }
- // geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
- // FIXME: this might change in the future - https://github.com/ethereum/go-ethereum/issues/2053
- return exports.bufferToHex(Buffer.concat([
- exports.setLengthLeft(r, 32),
- exports.setLengthLeft(s, 32),
- exports.toBuffer(v - 27)
- ]))
- }
- /**
- * Convert signature format of the `eth_sign` RPC method to signature parameters
- * NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
- * @param {String} sig
- * @return {Object}
- */
- exports.fromRpcSig = function (sig) {
- sig = exports.toBuffer(sig)
- // NOTE: with potential introduction of chainId this might need to be updated
- if (sig.length !== 65) {
- throw new Error('Invalid signature length')
- }
- var v = sig[64]
- // support both versions of `eth_sign` responses
- if (v < 27) {
- v += 27
- }
- return {
- v: v,
- r: sig.slice(0, 32),
- s: sig.slice(32, 64)
- }
- }
- /**
- * Returns the ethereum address of a given private key
- * @param {Buffer} privateKey A private key must be 256 bits wide
- * @return {Buffer}
- */
- exports.privateToAddress = function (privateKey) {
- return exports.publicToAddress(privateToPublic(privateKey))
- }
- /**
- * Checks if the address is a valid. Accepts checksummed addresses too
- * @param {String} address
- * @return {Boolean}
- */
- exports.isValidAddress = function (address) {
- return /^0x[0-9a-fA-F]{40}$/i.test(address)
- }
- /**
- * Returns a checksummed address
- * @param {String} address
- * @return {String}
- */
- exports.toChecksumAddress = function (address) {
- address = exports.stripHexPrefix(address).toLowerCase()
- var hash = exports.sha3(address).toString('hex')
- var ret = '0x'
- for (var i = 0; i < address.length; i++) {
- if (parseInt(hash[i], 16) >= 8) {
- ret += address[i].toUpperCase()
- } else {
- ret += address[i]
- }
- }
- return ret
- }
- /**
- * Checks if the address is a valid checksummed address
- * @param {Buffer} address
- * @return {Boolean}
- */
- exports.isValidChecksumAddress = function (address) {
- return exports.isValidAddress(address) && (exports.toChecksumAddress(address) === address)
- }
- /**
- * Generates an address of a newly created contract
- * @param {Buffer} from the address which is creating this new address
- * @param {Buffer} nonce the nonce of the from account
- * @return {Buffer}
- */
- exports.generateAddress = function (from, nonce) {
- from = exports.toBuffer(from)
- nonce = new BN(nonce)
- if (nonce.isZero()) {
- // in RLP we want to encode null in the case of zero nonce
- // read the RLP documentation for an answer if you dare
- nonce = null
- } else {
- nonce = Buffer.from(nonce.toArray())
- }
- // Only take the lower 160bits of the hash
- return exports.rlphash([from, nonce]).slice(-20)
- }
- /**
- * Returns true if the supplied address belongs to a precompiled account
- * @param {Buffer|String} address
- * @return {Boolean}
- */
- exports.isPrecompiled = function (address) {
- var a = exports.unpad(address)
- return a.length === 1 && a[0] > 0 && a[0] < 5
- }
- /**
- * Adds "0x" to a given `String` if it does not already start with "0x"
- * @param {String} str
- * @return {String}
- */
- exports.addHexPrefix = function (str) {
- if (typeof str !== 'string') {
- return str
- }
- return exports.isHexPrefixed(str) ? str : '0x' + str
- }
- /**
- * Validate ECDSA signature
- * @method isValidSignature
- * @param {Buffer} v
- * @param {Buffer} r
- * @param {Buffer} s
- * @param {Boolean} [homestead=true]
- * @return {Boolean}
- */
- exports.isValidSignature = function (v, r, s, homestead) {
- const SECP256K1_N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16)
- const SECP256K1_N = new BN('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 16)
- if (r.length !== 32 || s.length !== 32) {
- return false
- }
- if (v !== 27 && v !== 28) {
- return false
- }
- r = new BN(r)
- s = new BN(s)
- if (r.isZero() || r.gt(SECP256K1_N) || s.isZero() || s.gt(SECP256K1_N)) {
- return false
- }
- if ((homestead === false) && (new BN(s).cmp(SECP256K1_N_DIV_2) === 1)) {
- return false
- }
- return true
- }
- /**
- * Converts a `Buffer` or `Array` to JSON
- * @param {Buffer|Array} ba
- * @return {Array|String|null}
- */
- exports.baToJSON = function (ba) {
- if (Buffer.isBuffer(ba)) {
- return '0x' + ba.toString('hex')
- } else if (ba instanceof Array) {
- var array = []
- for (var i = 0; i < ba.length; i++) {
- array.push(exports.baToJSON(ba[i]))
- }
- return array
- }
- }
- /**
- * Defines properties on a `Object`. It make the assumption that underlying data is binary.
- * @param {Object} self the `Object` to define properties on
- * @param {Array} fields an array fields to define. Fields can contain:
- * * `name` - the name of the properties
- * * `length` - the number of bytes the field can have
- * * `allowLess` - if the field can be less than the length
- * * `allowEmpty`
- * @param {*} data data to be validated against the definitions
- */
- exports.defineProperties = function (self, fields, data) {
- self.raw = []
- self._fields = []
- // attach the `toJSON`
- self.toJSON = function (label) {
- if (label) {
- var obj = {}
- self._fields.forEach(function (field) {
- obj[field] = '0x' + self[field].toString('hex')
- })
- return obj
- }
- return exports.baToJSON(this.raw)
- }
- self.serialize = function serialize () {
- return rlp.encode(self.raw)
- }
- fields.forEach(function (field, i) {
- self._fields.push(field.name)
- function getter () {
- return self.raw[i]
- }
- function setter (v) {
- v = exports.toBuffer(v)
- if (v.toString('hex') === '00' && !field.allowZero) {
- v = Buffer.allocUnsafe(0)
- }
- if (field.allowLess && field.length) {
- v = exports.stripZeros(v)
- assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes')
- } else if (!(field.allowZero && v.length === 0) && field.length) {
- assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length)
- }
- self.raw[i] = v
- }
- Object.defineProperty(self, field.name, {
- enumerable: true,
- configurable: true,
- get: getter,
- set: setter
- })
- if (field.default) {
- self[field.name] = field.default
- }
- // attach alias
- if (field.alias) {
- Object.defineProperty(self, field.alias, {
- enumerable: false,
- configurable: true,
- set: setter,
- get: getter
- })
- }
- })
- // if the constuctor is passed data
- if (data) {
- if (typeof data === 'string') {
- data = Buffer.from(exports.stripHexPrefix(data), 'hex')
- }
- if (Buffer.isBuffer(data)) {
- data = rlp.decode(data)
- }
- if (Array.isArray(data)) {
- if (data.length > self._fields.length) {
- throw (new Error('wrong number of fields in data'))
- }
- // make sure all the items are buffers
- data.forEach(function (d, i) {
- self[self._fields[i]] = exports.toBuffer(d)
- })
- } else if (typeof data === 'object') {
- const keys = Object.keys(data)
- fields.forEach(function (field) {
- if (keys.indexOf(field.name) !== -1) self[field.name] = data[field.name]
- if (keys.indexOf(field.alias) !== -1) self[field.alias] = data[field.alias]
- })
- } else {
- throw new Error('invalid data')
- }
- }
- }
- }).call(this,require("buffer").Buffer)
- },{"assert":61,"bn.js":4,"buffer":65,"create-hash":7,"ethjs-util":26,"keccak":36,"rlp":45,"secp256k1":46}],3:[function(require,module,exports){
- (function (Buffer){
- // Reference https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
- // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
- // NOTE: SIGHASH byte ignored AND restricted, truncate before use
- function check (buffer) {
- if (buffer.length < 8) return false
- if (buffer.length > 72) return false
- if (buffer[0] !== 0x30) return false
- if (buffer[1] !== buffer.length - 2) return false
- if (buffer[2] !== 0x02) return false
- var lenR = buffer[3]
- if (lenR === 0) return false
- if (5 + lenR >= buffer.length) return false
- if (buffer[4 + lenR] !== 0x02) return false
- var lenS = buffer[5 + lenR]
- if (lenS === 0) return false
- if ((6 + lenR + lenS) !== buffer.length) return false
- if (buffer[4] & 0x80) return false
- if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) return false
- if (buffer[lenR + 6] & 0x80) return false
- if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) return false
- return true
- }
- function decode (buffer) {
- if (buffer.length < 8) throw new Error('DER sequence length is too short')
- if (buffer.length > 72) throw new Error('DER sequence length is too long')
- if (buffer[0] !== 0x30) throw new Error('Expected DER sequence')
- if (buffer[1] !== buffer.length - 2) throw new Error('DER sequence length is invalid')
- if (buffer[2] !== 0x02) throw new Error('Expected DER integer')
- var lenR = buffer[3]
- if (lenR === 0) throw new Error('R length is zero')
- if (5 + lenR >= buffer.length) throw new Error('R length is too long')
- if (buffer[4 + lenR] !== 0x02) throw new Error('Expected DER integer (2)')
- var lenS = buffer[5 + lenR]
- if (lenS === 0) throw new Error('S length is zero')
- if ((6 + lenR + lenS) !== buffer.length) throw new Error('S length is invalid')
- if (buffer[4] & 0x80) throw new Error('R value is negative')
- if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) throw new Error('R value excessively padded')
- if (buffer[lenR + 6] & 0x80) throw new Error('S value is negative')
- if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) throw new Error('S value excessively padded')
- // non-BIP66 - extract R, S values
- return {
- r: buffer.slice(4, 4 + lenR),
- s: buffer.slice(6 + lenR)
- }
- }
- /*
- * Expects r and s to be positive DER integers.
- *
- * The DER format uses the most significant bit as a sign bit (& 0x80).
- * If the significant bit is set AND the integer is positive, a 0x00 is prepended.
- *
- * Examples:
- *
- * 0 => 0x00
- * 1 => 0x01
- * -1 => 0xff
- * 127 => 0x7f
- * -127 => 0x81
- * 128 => 0x0080
- * -128 => 0x80
- * 255 => 0x00ff
- * -255 => 0xff01
- * 16300 => 0x3fac
- * -16300 => 0xc054
- * 62300 => 0x00f35c
- * -62300 => 0xff0ca4
- */
- function encode (r, s) {
- var lenR = r.length
- var lenS = s.length
- if (lenR === 0) throw new Error('R length is zero')
- if (lenS === 0) throw new Error('S length is zero')
- if (lenR > 33) throw new Error('R length is too long')
- if (lenS > 33) throw new Error('S length is too long')
- if (r[0] & 0x80) throw new Error('R value is negative')
- if (s[0] & 0x80) throw new Error('S value is negative')
- if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) throw new Error('R value excessively padded')
- if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) throw new Error('S value excessively padded')
- var signature = new Buffer(6 + lenR + lenS)
- // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
- signature[0] = 0x30
- signature[1] = signature.length - 2
- signature[2] = 0x02
- signature[3] = r.length
- r.copy(signature, 4)
- signature[4 + lenR] = 0x02
- signature[5 + lenR] = s.length
- s.copy(signature, 6 + lenR)
- return signature
- }
- module.exports = {
- check: check,
- decode: decode,
- encode: encode
- }
- }).call(this,require("buffer").Buffer)
- },{"buffer":65}],4:[function(require,module,exports){
- (function (module, exports) {
- 'use strict';
- // Utils
- function assert (val, msg) {
- if (!val) throw new Error(msg || 'Assertion failed');
- }
- // Could use `inherits` module, but don't want to move from single file
- // architecture yet.
- function inherits (ctor, superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
- }
- // BN
- function BN (number, base, endian) {
- if (BN.isBN(number)) {
- return number;
- }
- this.negative = 0;
- this.words = null;
- this.length = 0;
- // Reduction context
- this.red = null;
- if (number !== null) {
- if (base === 'le' || base === 'be') {
- endian = base;
- base = 10;
- }
- this._init(number || 0, base || 10, endian || 'be');
- }
- }
- if (typeof module === 'object') {
- module.exports = BN;
- } else {
- exports.BN = BN;
- }
- BN.BN = BN;
- BN.wordSize = 26;
- var Buffer;
- try {
- Buffer = require('buf' + 'fer').Buffer;
- } catch (e) {
- }
- BN.isBN = function isBN (num) {
- if (num instanceof BN) {
- return true;
- }
- return num !== null && typeof num === 'object' &&
- num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
- };
- BN.max = function max (left, right) {
- if (left.cmp(right) > 0) return left;
- return right;
- };
- BN.min = function min (left, right) {
- if (left.cmp(right) < 0) return left;
- return right;
- };
- BN.prototype._init = function init (number, base, endian) {
- if (typeof number === 'number') {
- return this._initNumber(number, base, endian);
- }
- if (typeof number === 'object') {
- return this._initArray(number, base, endian);
- }
- if (base === 'hex') {
- base = 16;
- }
- assert(base === (base | 0) && base >= 2 && base <= 36);
- number = number.toString().replace(/\s+/g, '');
- var start = 0;
- if (number[0] === '-') {
- start++;
- }
- if (base === 16) {
- this._parseHex(number, start);
- } else {
- this._parseBase(number, base, start);
- }
- if (number[0] === '-') {
- this.negative = 1;
- }
- this.strip();
- if (endian !== 'le') return;
- this._initArray(this.toArray(), base, endian);
- };
- BN.prototype._initNumber = function _initNumber (number, base, endian) {
- if (number < 0) {
- this.negative = 1;
- number = -number;
- }
- if (number < 0x4000000) {
- this.words = [ number & 0x3ffffff ];
- this.length = 1;
- } else if (number < 0x10000000000000) {
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff
- ];
- this.length = 2;
- } else {
- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
- this.words = [
- number & 0x3ffffff,
- (number / 0x4000000) & 0x3ffffff,
- 1
- ];
- this.length = 3;
- }
- if (endian !== 'le') return;
- // Reverse the bytes
- this._initArray(this.toArray(), base, endian);
- };
- BN.prototype._initArray = function _initArray (number, base, endian) {
- // Perhaps a Uint8Array
- assert(typeof number.length === 'number');
- if (number.length <= 0) {
- this.words = [ 0 ];
- this.length = 1;
- return this;
- }
- this.length = Math.ceil(number.length / 3);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- var j, w;
- var off = 0;
- if (endian === 'be') {
- for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
- w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- } else if (endian === 'le') {
- for (i = 0, j = 0; i < number.length; i += 3) {
- w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- }
- return this.strip();
- };
- function parseHex (str, start, end) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
- r <<= 4;
- // 'a' - 'f'
- if (c >= 49 && c <= 54) {
- r |= c - 49 + 0xa;
- // 'A' - 'F'
- } else if (c >= 17 && c <= 22) {
- r |= c - 17 + 0xa;
- // '0' - '9'
- } else {
- r |= c & 0xf;
- }
- }
- return r;
- }
- BN.prototype._parseHex = function _parseHex (number, start) {
- // Create possibly bigger array to ensure that it fits the number
- this.length = Math.ceil((number.length - start) / 6);
- this.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- this.words[i] = 0;
- }
- var j, w;
- // Scan 24-bit chunks and add them to the number
- var off = 0;
- for (i = number.length - 6, j = 0; i >= start; i -= 6) {
- w = parseHex(number, i, i + 6);
- this.words[j] |= (w << off) & 0x3ffffff;
- // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
- off += 24;
- if (off >= 26) {
- off -= 26;
- j++;
- }
- }
- if (i + 6 !== start) {
- w = parseHex(number, start, i + 6);
- this.words[j] |= (w << off) & 0x3ffffff;
- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
- }
- this.strip();
- };
- function parseBase (str, start, end, mul) {
- var r = 0;
- var len = Math.min(str.length, end);
- for (var i = start; i < len; i++) {
- var c = str.charCodeAt(i) - 48;
- r *= mul;
- // 'a'
- if (c >= 49) {
- r += c - 49 + 0xa;
- // 'A'
- } else if (c >= 17) {
- r += c - 17 + 0xa;
- // '0' - '9'
- } else {
- r += c;
- }
- }
- return r;
- }
- BN.prototype._parseBase = function _parseBase (number, base, start) {
- // Initialize as zero
- this.words = [ 0 ];
- this.length = 1;
- // Find length of limb in base
- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
- limbLen++;
- }
- limbLen--;
- limbPow = (limbPow / base) | 0;
- var total = number.length - start;
- var mod = total % limbLen;
- var end = Math.min(total, total - mod) + start;
- var word = 0;
- for (var i = start; i < end; i += limbLen) {
- word = parseBase(number, i, i + limbLen, base);
- this.imuln(limbPow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- if (mod !== 0) {
- var pow = 1;
- word = parseBase(number, i, number.length, base);
- for (i = 0; i < mod; i++) {
- pow *= base;
- }
- this.imuln(pow);
- if (this.words[0] + word < 0x4000000) {
- this.words[0] += word;
- } else {
- this._iaddn(word);
- }
- }
- };
- BN.prototype.copy = function copy (dest) {
- dest.words = new Array(this.length);
- for (var i = 0; i < this.length; i++) {
- dest.words[i] = this.words[i];
- }
- dest.length = this.length;
- dest.negative = this.negative;
- dest.red = this.red;
- };
- BN.prototype.clone = function clone () {
- var r = new BN(null);
- this.copy(r);
- return r;
- };
- BN.prototype._expand = function _expand (size) {
- while (this.length < size) {
- this.words[this.length++] = 0;
- }
- return this;
- };
- // Remove leading `0` from `this`
- BN.prototype.strip = function strip () {
- while (this.length > 1 && this.words[this.length - 1] === 0) {
- this.length--;
- }
- return this._normSign();
- };
- BN.prototype._normSign = function _normSign () {
- // -0 = 0
- if (this.length === 1 && this.words[0] === 0) {
- this.negative = 0;
- }
- return this;
- };
- BN.prototype.inspect = function inspect () {
- return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
- };
- /*
- var zeros = [];
- var groupSizes = [];
- var groupBases = [];
- var s = '';
- var i = -1;
- while (++i < BN.wordSize) {
- zeros[i] = s;
- s += '0';
- }
- groupSizes[0] = 0;
- groupSizes[1] = 0;
- groupBases[0] = 0;
- groupBases[1] = 0;
- var base = 2 - 1;
- while (++base < 36 + 1) {
- var groupSize = 0;
- var groupBase = 1;
- while (groupBase < (1 << BN.wordSize) / base) {
- groupBase *= base;
- groupSize += 1;
- }
- groupSizes[base] = groupSize;
- groupBases[base] = groupBase;
- }
- */
- var zeros = [
- '',
- '0',
- '00',
- '000',
- '0000',
- '00000',
- '000000',
- '0000000',
- '00000000',
- '000000000',
- '0000000000',
- '00000000000',
- '000000000000',
- '0000000000000',
- '00000000000000',
- '000000000000000',
- '0000000000000000',
- '00000000000000000',
- '000000000000000000',
- '0000000000000000000',
- '00000000000000000000',
- '000000000000000000000',
- '0000000000000000000000',
- '00000000000000000000000',
- '000000000000000000000000',
- '0000000000000000000000000'
- ];
- var groupSizes = [
- 0, 0,
- 25, 16, 12, 11, 10, 9, 8,
- 8, 7, 7, 7, 7, 6, 6,
- 6, 6, 6, 6, 6, 5, 5,
- 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5
- ];
- var groupBases = [
- 0, 0,
- 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
- 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
- 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
- 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
- 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
- ];
- BN.prototype.toString = function toString (base, padding) {
- base = base || 10;
- padding = padding | 0 || 1;
- var out;
- if (base === 16 || base === 'hex') {
- out = '';
- var off = 0;
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = this.words[i];
- var word = (((w << off) | carry) & 0xffffff).toString(16);
- carry = (w >>> (24 - off)) & 0xffffff;
- if (carry !== 0 || i !== this.length - 1) {
- out = zeros[6 - word.length] + word + out;
- } else {
- out = word + out;
- }
- off += 2;
- if (off >= 26) {
- off -= 26;
- i--;
- }
- }
- if (carry !== 0) {
- out = carry.toString(16) + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- if (base === (base | 0) && base >= 2 && base <= 36) {
- // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
- var groupSize = groupSizes[base];
- // var groupBase = Math.pow(base, groupSize);
- var groupBase = groupBases[base];
- out = '';
- var c = this.clone();
- c.negative = 0;
- while (!c.isZero()) {
- var r = c.modn(groupBase).toString(base);
- c = c.idivn(groupBase);
- if (!c.isZero()) {
- out = zeros[groupSize - r.length] + r + out;
- } else {
- out = r + out;
- }
- }
- if (this.isZero()) {
- out = '0' + out;
- }
- while (out.length % padding !== 0) {
- out = '0' + out;
- }
- if (this.negative !== 0) {
- out = '-' + out;
- }
- return out;
- }
- assert(false, 'Base should be between 2 and 36');
- };
- BN.prototype.toNumber = function toNumber () {
- var ret = this.words[0];
- if (this.length === 2) {
- ret += this.words[1] * 0x4000000;
- } else if (this.length === 3 && this.words[2] === 0x01) {
- // NOTE: at this stage it is known that the top bit is set
- ret += 0x10000000000000 + (this.words[1] * 0x4000000);
- } else if (this.length > 2) {
- assert(false, 'Number can only safely store up to 53 bits');
- }
- return (this.negative !== 0) ? -ret : ret;
- };
- BN.prototype.toJSON = function toJSON () {
- return this.toString(16);
- };
- BN.prototype.toBuffer = function toBuffer (endian, length) {
- assert(typeof Buffer !== 'undefined');
- return this.toArrayLike(Buffer, endian, length);
- };
- BN.prototype.toArray = function toArray (endian, length) {
- return this.toArrayLike(Array, endian, length);
- };
- BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
- var byteLength = this.byteLength();
- var reqLength = length || Math.max(1, byteLength);
- assert(byteLength <= reqLength, 'byte array longer than desired length');
- assert(reqLength > 0, 'Requested array length <= 0');
- this.strip();
- var littleEndian = endian === 'le';
- var res = new ArrayType(reqLength);
- var b, i;
- var q = this.clone();
- if (!littleEndian) {
- // Assume big-endian
- for (i = 0; i < reqLength - byteLength; i++) {
- res[i] = 0;
- }
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[reqLength - i - 1] = b;
- }
- } else {
- for (i = 0; !q.isZero(); i++) {
- b = q.andln(0xff);
- q.iushrn(8);
- res[i] = b;
- }
- for (; i < reqLength; i++) {
- res[i] = 0;
- }
- }
- return res;
- };
- if (Math.clz32) {
- BN.prototype._countBits = function _countBits (w) {
- return 32 - Math.clz32(w);
- };
- } else {
- BN.prototype._countBits = function _countBits (w) {
- var t = w;
- var r = 0;
- if (t >= 0x1000) {
- r += 13;
- t >>>= 13;
- }
- if (t >= 0x40) {
- r += 7;
- t >>>= 7;
- }
- if (t >= 0x8) {
- r += 4;
- t >>>= 4;
- }
- if (t >= 0x02) {
- r += 2;
- t >>>= 2;
- }
- return r + t;
- };
- }
- BN.prototype._zeroBits = function _zeroBits (w) {
- // Short-cut
- if (w === 0) return 26;
- var t = w;
- var r = 0;
- if ((t & 0x1fff) === 0) {
- r += 13;
- t >>>= 13;
- }
- if ((t & 0x7f) === 0) {
- r += 7;
- t >>>= 7;
- }
- if ((t & 0xf) === 0) {
- r += 4;
- t >>>= 4;
- }
- if ((t & 0x3) === 0) {
- r += 2;
- t >>>= 2;
- }
- if ((t & 0x1) === 0) {
- r++;
- }
- return r;
- };
- // Return number of used bits in a BN
- BN.prototype.bitLength = function bitLength () {
- var w = this.words[this.length - 1];
- var hi = this._countBits(w);
- return (this.length - 1) * 26 + hi;
- };
- function toBitArray (num) {
- var w = new Array(num.bitLength());
- for (var bit = 0; bit < w.length; bit++) {
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
- }
- return w;
- }
- // Number of trailing zero bits
- BN.prototype.zeroBits = function zeroBits () {
- if (this.isZero()) return 0;
- var r = 0;
- for (var i = 0; i < this.length; i++) {
- var b = this._zeroBits(this.words[i]);
- r += b;
- if (b !== 26) break;
- }
- return r;
- };
- BN.prototype.byteLength = function byteLength () {
- return Math.ceil(this.bitLength() / 8);
- };
- BN.prototype.toTwos = function toTwos (width) {
- if (this.negative !== 0) {
- return this.abs().inotn(width).iaddn(1);
- }
- return this.clone();
- };
- BN.prototype.fromTwos = function fromTwos (width) {
- if (this.testn(width - 1)) {
- return this.notn(width).iaddn(1).ineg();
- }
- return this.clone();
- };
- BN.prototype.isNeg = function isNeg () {
- return this.negative !== 0;
- };
- // Return negative clone of `this`
- BN.prototype.neg = function neg () {
- return this.clone().ineg();
- };
- BN.prototype.ineg = function ineg () {
- if (!this.isZero()) {
- this.negative ^= 1;
- }
- return this;
- };
- // Or `num` with `this` in-place
- BN.prototype.iuor = function iuor (num) {
- while (this.length < num.length) {
- this.words[this.length++] = 0;
- }
- for (var i = 0; i < num.length; i++) {
- this.words[i] = this.words[i] | num.words[i];
- }
- return this.strip();
- };
- BN.prototype.ior = function ior (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuor(num);
- };
- // Or `num` with `this`
- BN.prototype.or = function or (num) {
- if (this.length > num.length) return this.clone().ior(num);
- return num.clone().ior(this);
- };
- BN.prototype.uor = function uor (num) {
- if (this.length > num.length) return this.clone().iuor(num);
- return num.clone().iuor(this);
- };
- // And `num` with `this` in-place
- BN.prototype.iuand = function iuand (num) {
- // b = min-length(num, this)
- var b;
- if (this.length > num.length) {
- b = num;
- } else {
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = this.words[i] & num.words[i];
- }
- this.length = b.length;
- return this.strip();
- };
- BN.prototype.iand = function iand (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuand(num);
- };
- // And `num` with `this`
- BN.prototype.and = function and (num) {
- if (this.length > num.length) return this.clone().iand(num);
- return num.clone().iand(this);
- };
- BN.prototype.uand = function uand (num) {
- if (this.length > num.length) return this.clone().iuand(num);
- return num.clone().iuand(this);
- };
- // Xor `num` with `this` in-place
- BN.prototype.iuxor = function iuxor (num) {
- // a.length > b.length
- var a;
- var b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- for (var i = 0; i < b.length; i++) {
- this.words[i] = a.words[i] ^ b.words[i];
- }
- if (this !== a) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = a.length;
- return this.strip();
- };
- BN.prototype.ixor = function ixor (num) {
- assert((this.negative | num.negative) === 0);
- return this.iuxor(num);
- };
- // Xor `num` with `this`
- BN.prototype.xor = function xor (num) {
- if (this.length > num.length) return this.clone().ixor(num);
- return num.clone().ixor(this);
- };
- BN.prototype.uxor = function uxor (num) {
- if (this.length > num.length) return this.clone().iuxor(num);
- return num.clone().iuxor(this);
- };
- // Not ``this`` with ``width`` bitwidth
- BN.prototype.inotn = function inotn (width) {
- assert(typeof width === 'number' && width >= 0);
- var bytesNeeded = Math.ceil(width / 26) | 0;
- var bitsLeft = width % 26;
- // Extend the buffer with leading zeroes
- this._expand(bytesNeeded);
- if (bitsLeft > 0) {
- bytesNeeded--;
- }
- // Handle complete words
- for (var i = 0; i < bytesNeeded; i++) {
- this.words[i] = ~this.words[i] & 0x3ffffff;
- }
- // Handle the residue
- if (bitsLeft > 0) {
- this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
- }
- // And remove leading zeroes
- return this.strip();
- };
- BN.prototype.notn = function notn (width) {
- return this.clone().inotn(width);
- };
- // Set `bit` of `this`
- BN.prototype.setn = function setn (bit, val) {
- assert(typeof bit === 'number' && bit >= 0);
- var off = (bit / 26) | 0;
- var wbit = bit % 26;
- this._expand(off + 1);
- if (val) {
- this.words[off] = this.words[off] | (1 << wbit);
- } else {
- this.words[off] = this.words[off] & ~(1 << wbit);
- }
- return this.strip();
- };
- // Add `num` to `this` in-place
- BN.prototype.iadd = function iadd (num) {
- var r;
- // negative + positive
- if (this.negative !== 0 && num.negative === 0) {
- this.negative = 0;
- r = this.isub(num);
- this.negative ^= 1;
- return this._normSign();
- // positive + negative
- } else if (this.negative === 0 && num.negative !== 0) {
- num.negative = 0;
- r = this.isub(num);
- num.negative = 1;
- return r._normSign();
- }
- // a.length > b.length
- var a, b;
- if (this.length > num.length) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- this.words[i] = r & 0x3ffffff;
- carry = r >>> 26;
- }
- this.length = a.length;
- if (carry !== 0) {
- this.words[this.length] = carry;
- this.length++;
- // Copy the rest of the words
- } else if (a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- return this;
- };
- // Add `num` to `this`
- BN.prototype.add = function add (num) {
- var res;
- if (num.negative !== 0 && this.negative === 0) {
- num.negative = 0;
- res = this.sub(num);
- num.negative ^= 1;
- return res;
- } else if (num.negative === 0 && this.negative !== 0) {
- this.negative = 0;
- res = num.sub(this);
- this.negative = 1;
- return res;
- }
- if (this.length > num.length) return this.clone().iadd(num);
- return num.clone().iadd(this);
- };
- // Subtract `num` from `this` in-place
- BN.prototype.isub = function isub (num) {
- // this - (-num) = this + num
- if (num.negative !== 0) {
- num.negative = 0;
- var r = this.iadd(num);
- num.negative = 1;
- return r._normSign();
- // -this - num = -(this + num)
- } else if (this.negative !== 0) {
- this.negative = 0;
- this.iadd(num);
- this.negative = 1;
- return this._normSign();
- }
- // At this point both numbers are positive
- var cmp = this.cmp(num);
- // Optimization - zeroify
- if (cmp === 0) {
- this.negative = 0;
- this.length = 1;
- this.words[0] = 0;
- return this;
- }
- // a > b
- var a, b;
- if (cmp > 0) {
- a = this;
- b = num;
- } else {
- a = num;
- b = this;
- }
- var carry = 0;
- for (var i = 0; i < b.length; i++) {
- r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- for (; carry !== 0 && i < a.length; i++) {
- r = (a.words[i] | 0) + carry;
- carry = r >> 26;
- this.words[i] = r & 0x3ffffff;
- }
- // Copy rest of the words
- if (carry === 0 && i < a.length && a !== this) {
- for (; i < a.length; i++) {
- this.words[i] = a.words[i];
- }
- }
- this.length = Math.max(this.length, i);
- if (a !== this) {
- this.negative = 1;
- }
- return this.strip();
- };
- // Subtract `num` from `this`
- BN.prototype.sub = function sub (num) {
- return this.clone().isub(num);
- };
- function smallMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- var len = (self.length + num.length) | 0;
- out.length = len;
- len = (len - 1) | 0;
- // Peel one iteration (compiler can't do it, because of code complexity)
- var a = self.words[0] | 0;
- var b = num.words[0] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- var carry = (r / 0x4000000) | 0;
- out.words[0] = lo;
- for (var k = 1; k < len; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = carry >>> 26;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = (k - j) | 0;
- a = self.words[i] | 0;
- b = num.words[j] | 0;
- r = a * b + rword;
- ncarry += (r / 0x4000000) | 0;
- rword = r & 0x3ffffff;
- }
- out.words[k] = rword | 0;
- carry = ncarry | 0;
- }
- if (carry !== 0) {
- out.words[k] = carry | 0;
- } else {
- out.length--;
- }
- return out.strip();
- }
- // TODO(indutny): it may be reasonable to omit it for users who don't need
- // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
- // multiplication (like elliptic secp256k1).
- var comb10MulTo = function comb10MulTo (self, num, out) {
- var a = self.words;
- var b = num.words;
- var o = out.words;
- var c = 0;
- var lo;
- var mid;
- var hi;
- var a0 = a[0] | 0;
- var al0 = a0 & 0x1fff;
- var ah0 = a0 >>> 13;
- var a1 = a[1] | 0;
- var al1 = a1 & 0x1fff;
- var ah1 = a1 >>> 13;
- var a2 = a[2] | 0;
- var al2 = a2 & 0x1fff;
- var ah2 = a2 >>> 13;
- var a3 = a[3] | 0;
- var al3 = a3 & 0x1fff;
- var ah3 = a3 >>> 13;
- var a4 = a[4] | 0;
- var al4 = a4 & 0x1fff;
- var ah4 = a4 >>> 13;
- var a5 = a[5] | 0;
- var al5 = a5 & 0x1fff;
- var ah5 = a5 >>> 13;
- var a6 = a[6] | 0;
- var al6 = a6 & 0x1fff;
- var ah6 = a6 >>> 13;
- var a7 = a[7] | 0;
- var al7 = a7 & 0x1fff;
- var ah7 = a7 >>> 13;
- var a8 = a[8] | 0;
- var al8 = a8 & 0x1fff;
- var ah8 = a8 >>> 13;
- var a9 = a[9] | 0;
- var al9 = a9 & 0x1fff;
- var ah9 = a9 >>> 13;
- var b0 = b[0] | 0;
- var bl0 = b0 & 0x1fff;
- var bh0 = b0 >>> 13;
- var b1 = b[1] | 0;
- var bl1 = b1 & 0x1fff;
- var bh1 = b1 >>> 13;
- var b2 = b[2] | 0;
- var bl2 = b2 & 0x1fff;
- var bh2 = b2 >>> 13;
- var b3 = b[3] | 0;
- var bl3 = b3 & 0x1fff;
- var bh3 = b3 >>> 13;
- var b4 = b[4] | 0;
- var bl4 = b4 & 0x1fff;
- var bh4 = b4 >>> 13;
- var b5 = b[5] | 0;
- var bl5 = b5 & 0x1fff;
- var bh5 = b5 >>> 13;
- var b6 = b[6] | 0;
- var bl6 = b6 & 0x1fff;
- var bh6 = b6 >>> 13;
- var b7 = b[7] | 0;
- var bl7 = b7 & 0x1fff;
- var bh7 = b7 >>> 13;
- var b8 = b[8] | 0;
- var bl8 = b8 & 0x1fff;
- var bh8 = b8 >>> 13;
- var b9 = b[9] | 0;
- var bl9 = b9 & 0x1fff;
- var bh9 = b9 >>> 13;
- out.negative = self.negative ^ num.negative;
- out.length = 19;
- /* k = 0 */
- lo = Math.imul(al0, bl0);
- mid = Math.imul(al0, bh0);
- mid = (mid + Math.imul(ah0, bl0)) | 0;
- hi = Math.imul(ah0, bh0);
- var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
- w0 &= 0x3ffffff;
- /* k = 1 */
- lo = Math.imul(al1, bl0);
- mid = Math.imul(al1, bh0);
- mid = (mid + Math.imul(ah1, bl0)) | 0;
- hi = Math.imul(ah1, bh0);
- lo = (lo + Math.imul(al0, bl1)) | 0;
- mid = (mid + Math.imul(al0, bh1)) | 0;
- mid = (mid + Math.imul(ah0, bl1)) | 0;
- hi = (hi + Math.imul(ah0, bh1)) | 0;
- var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
- w1 &= 0x3ffffff;
- /* k = 2 */
- lo = Math.imul(al2, bl0);
- mid = Math.imul(al2, bh0);
- mid = (mid + Math.imul(ah2, bl0)) | 0;
- hi = Math.imul(ah2, bh0);
- lo = (lo + Math.imul(al1, bl1)) | 0;
- mid = (mid + Math.imul(al1, bh1)) | 0;
- mid = (mid + Math.imul(ah1, bl1)) | 0;
- hi = (hi + Math.imul(ah1, bh1)) | 0;
- lo = (lo + Math.imul(al0, bl2)) | 0;
- mid = (mid + Math.imul(al0, bh2)) | 0;
- mid = (mid + Math.imul(ah0, bl2)) | 0;
- hi = (hi + Math.imul(ah0, bh2)) | 0;
- var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
- w2 &= 0x3ffffff;
- /* k = 3 */
- lo = Math.imul(al3, bl0);
- mid = Math.imul(al3, bh0);
- mid = (mid + Math.imul(ah3, bl0)) | 0;
- hi = Math.imul(ah3, bh0);
- lo = (lo + Math.imul(al2, bl1)) | 0;
- mid = (mid + Math.imul(al2, bh1)) | 0;
- mid = (mid + Math.imul(ah2, bl1)) | 0;
- hi = (hi + Math.imul(ah2, bh1)) | 0;
- lo = (lo + Math.imul(al1, bl2)) | 0;
- mid = (mid + Math.imul(al1, bh2)) | 0;
- mid = (mid + Math.imul(ah1, bl2)) | 0;
- hi = (hi + Math.imul(ah1, bh2)) | 0;
- lo = (lo + Math.imul(al0, bl3)) | 0;
- mid = (mid + Math.imul(al0, bh3)) | 0;
- mid = (mid + Math.imul(ah0, bl3)) | 0;
- hi = (hi + Math.imul(ah0, bh3)) | 0;
- var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
- w3 &= 0x3ffffff;
- /* k = 4 */
- lo = Math.imul(al4, bl0);
- mid = Math.imul(al4, bh0);
- mid = (mid + Math.imul(ah4, bl0)) | 0;
- hi = Math.imul(ah4, bh0);
- lo = (lo + Math.imul(al3, bl1)) | 0;
- mid = (mid + Math.imul(al3, bh1)) | 0;
- mid = (mid + Math.imul(ah3, bl1)) | 0;
- hi = (hi + Math.imul(ah3, bh1)) | 0;
- lo = (lo + Math.imul(al2, bl2)) | 0;
- mid = (mid + Math.imul(al2, bh2)) | 0;
- mid = (mid + Math.imul(ah2, bl2)) | 0;
- hi = (hi + Math.imul(ah2, bh2)) | 0;
- lo = (lo + Math.imul(al1, bl3)) | 0;
- mid = (mid + Math.imul(al1, bh3)) | 0;
- mid = (mid + Math.imul(ah1, bl3)) | 0;
- hi = (hi + Math.imul(ah1, bh3)) | 0;
- lo = (lo + Math.imul(al0, bl4)) | 0;
- mid = (mid + Math.imul(al0, bh4)) | 0;
- mid = (mid + Math.imul(ah0, bl4)) | 0;
- hi = (hi + Math.imul(ah0, bh4)) | 0;
- var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
- w4 &= 0x3ffffff;
- /* k = 5 */
- lo = Math.imul(al5, bl0);
- mid = Math.imul(al5, bh0);
- mid = (mid + Math.imul(ah5, bl0)) | 0;
- hi = Math.imul(ah5, bh0);
- lo = (lo + Math.imul(al4, bl1)) | 0;
- mid = (mid + Math.imul(al4, bh1)) | 0;
- mid = (mid + Math.imul(ah4, bl1)) | 0;
- hi = (hi + Math.imul(ah4, bh1)) | 0;
- lo = (lo + Math.imul(al3, bl2)) | 0;
- mid = (mid + Math.imul(al3, bh2)) | 0;
- mid = (mid + Math.imul(ah3, bl2)) | 0;
- hi = (hi + Math.imul(ah3, bh2)) | 0;
- lo = (lo + Math.imul(al2, bl3)) | 0;
- mid = (mid + Math.imul(al2, bh3)) | 0;
- mid = (mid + Math.imul(ah2, bl3)) | 0;
- hi = (hi + Math.imul(ah2, bh3)) | 0;
- lo = (lo + Math.imul(al1, bl4)) | 0;
- mid = (mid + Math.imul(al1, bh4)) | 0;
- mid = (mid + Math.imul(ah1, bl4)) | 0;
- hi = (hi + Math.imul(ah1, bh4)) | 0;
- lo = (lo + Math.imul(al0, bl5)) | 0;
- mid = (mid + Math.imul(al0, bh5)) | 0;
- mid = (mid + Math.imul(ah0, bl5)) | 0;
- hi = (hi + Math.imul(ah0, bh5)) | 0;
- var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
- w5 &= 0x3ffffff;
- /* k = 6 */
- lo = Math.imul(al6, bl0);
- mid = Math.imul(al6, bh0);
- mid = (mid + Math.imul(ah6, bl0)) | 0;
- hi = Math.imul(ah6, bh0);
- lo = (lo + Math.imul(al5, bl1)) | 0;
- mid = (mid + Math.imul(al5, bh1)) | 0;
- mid = (mid + Math.imul(ah5, bl1)) | 0;
- hi = (hi + Math.imul(ah5, bh1)) | 0;
- lo = (lo + Math.imul(al4, bl2)) | 0;
- mid = (mid + Math.imul(al4, bh2)) | 0;
- mid = (mid + Math.imul(ah4, bl2)) | 0;
- hi = (hi + Math.imul(ah4, bh2)) | 0;
- lo = (lo + Math.imul(al3, bl3)) | 0;
- mid = (mid + Math.imul(al3, bh3)) | 0;
- mid = (mid + Math.imul(ah3, bl3)) | 0;
- hi = (hi + Math.imul(ah3, bh3)) | 0;
- lo = (lo + Math.imul(al2, bl4)) | 0;
- mid = (mid + Math.imul(al2, bh4)) | 0;
- mid = (mid + Math.imul(ah2, bl4)) | 0;
- hi = (hi + Math.imul(ah2, bh4)) | 0;
- lo = (lo + Math.imul(al1, bl5)) | 0;
- mid = (mid + Math.imul(al1, bh5)) | 0;
- mid = (mid + Math.imul(ah1, bl5)) | 0;
- hi = (hi + Math.imul(ah1, bh5)) | 0;
- lo = (lo + Math.imul(al0, bl6)) | 0;
- mid = (mid + Math.imul(al0, bh6)) | 0;
- mid = (mid + Math.imul(ah0, bl6)) | 0;
- hi = (hi + Math.imul(ah0, bh6)) | 0;
- var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
- w6 &= 0x3ffffff;
- /* k = 7 */
- lo = Math.imul(al7, bl0);
- mid = Math.imul(al7, bh0);
- mid = (mid + Math.imul(ah7, bl0)) | 0;
- hi = Math.imul(ah7, bh0);
- lo = (lo + Math.imul(al6, bl1)) | 0;
- mid = (mid + Math.imul(al6, bh1)) | 0;
- mid = (mid + Math.imul(ah6, bl1)) | 0;
- hi = (hi + Math.imul(ah6, bh1)) | 0;
- lo = (lo + Math.imul(al5, bl2)) | 0;
- mid = (mid + Math.imul(al5, bh2)) | 0;
- mid = (mid + Math.imul(ah5, bl2)) | 0;
- hi = (hi + Math.imul(ah5, bh2)) | 0;
- lo = (lo + Math.imul(al4, bl3)) | 0;
- mid = (mid + Math.imul(al4, bh3)) | 0;
- mid = (mid + Math.imul(ah4, bl3)) | 0;
- hi = (hi + Math.imul(ah4, bh3)) | 0;
- lo = (lo + Math.imul(al3, bl4)) | 0;
- mid = (mid + Math.imul(al3, bh4)) | 0;
- mid = (mid + Math.imul(ah3, bl4)) | 0;
- hi = (hi + Math.imul(ah3, bh4)) | 0;
- lo = (lo + Math.imul(al2, bl5)) | 0;
- mid = (mid + Math.imul(al2, bh5)) | 0;
- mid = (mid + Math.imul(ah2, bl5)) | 0;
- hi = (hi + Math.imul(ah2, bh5)) | 0;
- lo = (lo + Math.imul(al1, bl6)) | 0;
- mid = (mid + Math.imul(al1, bh6)) | 0;
- mid = (mid + Math.imul(ah1, bl6)) | 0;
- hi = (hi + Math.imul(ah1, bh6)) | 0;
- lo = (lo + Math.imul(al0, bl7)) | 0;
- mid = (mid + Math.imul(al0, bh7)) | 0;
- mid = (mid + Math.imul(ah0, bl7)) | 0;
- hi = (hi + Math.imul(ah0, bh7)) | 0;
- var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
- w7 &= 0x3ffffff;
- /* k = 8 */
- lo = Math.imul(al8, bl0);
- mid = Math.imul(al8, bh0);
- mid = (mid + Math.imul(ah8, bl0)) | 0;
- hi = Math.imul(ah8, bh0);
- lo = (lo + Math.imul(al7, bl1)) | 0;
- mid = (mid + Math.imul(al7, bh1)) | 0;
- mid = (mid + Math.imul(ah7, bl1)) | 0;
- hi = (hi + Math.imul(ah7, bh1)) | 0;
- lo = (lo + Math.imul(al6, bl2)) | 0;
- mid = (mid + Math.imul(al6, bh2)) | 0;
- mid = (mid + Math.imul(ah6, bl2)) | 0;
- hi = (hi + Math.imul(ah6, bh2)) | 0;
- lo = (lo + Math.imul(al5, bl3)) | 0;
- mid = (mid + Math.imul(al5, bh3)) | 0;
- mid = (mid + Math.imul(ah5, bl3)) | 0;
- hi = (hi + Math.imul(ah5, bh3)) | 0;
- lo = (lo + Math.imul(al4, bl4)) | 0;
- mid = (mid + Math.imul(al4, bh4)) | 0;
- mid = (mid + Math.imul(ah4, bl4)) | 0;
- hi = (hi + Math.imul(ah4, bh4)) | 0;
- lo = (lo + Math.imul(al3, bl5)) | 0;
- mid = (mid + Math.imul(al3, bh5)) | 0;
- mid = (mid + Math.imul(ah3, bl5)) | 0;
- hi = (hi + Math.imul(ah3, bh5)) | 0;
- lo = (lo + Math.imul(al2, bl6)) | 0;
- mid = (mid + Math.imul(al2, bh6)) | 0;
- mid = (mid + Math.imul(ah2, bl6)) | 0;
- hi = (hi + Math.imul(ah2, bh6)) | 0;
- lo = (lo + Math.imul(al1, bl7)) | 0;
- mid = (mid + Math.imul(al1, bh7)) | 0;
- mid = (mid + Math.imul(ah1, bl7)) | 0;
- hi = (hi + Math.imul(ah1, bh7)) | 0;
- lo = (lo + Math.imul(al0, bl8)) | 0;
- mid = (mid + Math.imul(al0, bh8)) | 0;
- mid = (mid + Math.imul(ah0, bl8)) | 0;
- hi = (hi + Math.imul(ah0, bh8)) | 0;
- var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
- w8 &= 0x3ffffff;
- /* k = 9 */
- lo = Math.imul(al9, bl0);
- mid = Math.imul(al9, bh0);
- mid = (mid + Math.imul(ah9, bl0)) | 0;
- hi = Math.imul(ah9, bh0);
- lo = (lo + Math.imul(al8, bl1)) | 0;
- mid = (mid + Math.imul(al8, bh1)) | 0;
- mid = (mid + Math.imul(ah8, bl1)) | 0;
- hi = (hi + Math.imul(ah8, bh1)) | 0;
- lo = (lo + Math.imul(al7, bl2)) | 0;
- mid = (mid + Math.imul(al7, bh2)) | 0;
- mid = (mid + Math.imul(ah7, bl2)) | 0;
- hi = (hi + Math.imul(ah7, bh2)) | 0;
- lo = (lo + Math.imul(al6, bl3)) | 0;
- mid = (mid + Math.imul(al6, bh3)) | 0;
- mid = (mid + Math.imul(ah6, bl3)) | 0;
- hi = (hi + Math.imul(ah6, bh3)) | 0;
- lo = (lo + Math.imul(al5, bl4)) | 0;
- mid = (mid + Math.imul(al5, bh4)) | 0;
- mid = (mid + Math.imul(ah5, bl4)) | 0;
- hi = (hi + Math.imul(ah5, bh4)) | 0;
- lo = (lo + Math.imul(al4, bl5)) | 0;
- mid = (mid + Math.imul(al4, bh5)) | 0;
- mid = (mid + Math.imul(ah4, bl5)) | 0;
- hi = (hi + Math.imul(ah4, bh5)) | 0;
- lo = (lo + Math.imul(al3, bl6)) | 0;
- mid = (mid + Math.imul(al3, bh6)) | 0;
- mid = (mid + Math.imul(ah3, bl6)) | 0;
- hi = (hi + Math.imul(ah3, bh6)) | 0;
- lo = (lo + Math.imul(al2, bl7)) | 0;
- mid = (mid + Math.imul(al2, bh7)) | 0;
- mid = (mid + Math.imul(ah2, bl7)) | 0;
- hi = (hi + Math.imul(ah2, bh7)) | 0;
- lo = (lo + Math.imul(al1, bl8)) | 0;
- mid = (mid + Math.imul(al1, bh8)) | 0;
- mid = (mid + Math.imul(ah1, bl8)) | 0;
- hi = (hi + Math.imul(ah1, bh8)) | 0;
- lo = (lo + Math.imul(al0, bl9)) | 0;
- mid = (mid + Math.imul(al0, bh9)) | 0;
- mid = (mid + Math.imul(ah0, bl9)) | 0;
- hi = (hi + Math.imul(ah0, bh9)) | 0;
- var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
- w9 &= 0x3ffffff;
- /* k = 10 */
- lo = Math.imul(al9, bl1);
- mid = Math.imul(al9, bh1);
- mid = (mid + Math.imul(ah9, bl1)) | 0;
- hi = Math.imul(ah9, bh1);
- lo = (lo + Math.imul(al8, bl2)) | 0;
- mid = (mid + Math.imul(al8, bh2)) | 0;
- mid = (mid + Math.imul(ah8, bl2)) | 0;
- hi = (hi + Math.imul(ah8, bh2)) | 0;
- lo = (lo + Math.imul(al7, bl3)) | 0;
- mid = (mid + Math.imul(al7, bh3)) | 0;
- mid = (mid + Math.imul(ah7, bl3)) | 0;
- hi = (hi + Math.imul(ah7, bh3)) | 0;
- lo = (lo + Math.imul(al6, bl4)) | 0;
- mid = (mid + Math.imul(al6, bh4)) | 0;
- mid = (mid + Math.imul(ah6, bl4)) | 0;
- hi = (hi + Math.imul(ah6, bh4)) | 0;
- lo = (lo + Math.imul(al5, bl5)) | 0;
- mid = (mid + Math.imul(al5, bh5)) | 0;
- mid = (mid + Math.imul(ah5, bl5)) | 0;
- hi = (hi + Math.imul(ah5, bh5)) | 0;
- lo = (lo + Math.imul(al4, bl6)) | 0;
- mid = (mid + Math.imul(al4, bh6)) | 0;
- mid = (mid + Math.imul(ah4, bl6)) | 0;
- hi = (hi + Math.imul(ah4, bh6)) | 0;
- lo = (lo + Math.imul(al3, bl7)) | 0;
- mid = (mid + Math.imul(al3, bh7)) | 0;
- mid = (mid + Math.imul(ah3, bl7)) | 0;
- hi = (hi + Math.imul(ah3, bh7)) | 0;
- lo = (lo + Math.imul(al2, bl8)) | 0;
- mid = (mid + Math.imul(al2, bh8)) | 0;
- mid = (mid + Math.imul(ah2, bl8)) | 0;
- hi = (hi + Math.imul(ah2, bh8)) | 0;
- lo = (lo + Math.imul(al1, bl9)) | 0;
- mid = (mid + Math.imul(al1, bh9)) | 0;
- mid = (mid + Math.imul(ah1, bl9)) | 0;
- hi = (hi + Math.imul(ah1, bh9)) | 0;
- var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
- w10 &= 0x3ffffff;
- /* k = 11 */
- lo = Math.imul(al9, bl2);
- mid = Math.imul(al9, bh2);
- mid = (mid + Math.imul(ah9, bl2)) | 0;
- hi = Math.imul(ah9, bh2);
- lo = (lo + Math.imul(al8, bl3)) | 0;
- mid = (mid + Math.imul(al8, bh3)) | 0;
- mid = (mid + Math.imul(ah8, bl3)) | 0;
- hi = (hi + Math.imul(ah8, bh3)) | 0;
- lo = (lo + Math.imul(al7, bl4)) | 0;
- mid = (mid + Math.imul(al7, bh4)) | 0;
- mid = (mid + Math.imul(ah7, bl4)) | 0;
- hi = (hi + Math.imul(ah7, bh4)) | 0;
- lo = (lo + Math.imul(al6, bl5)) | 0;
- mid = (mid + Math.imul(al6, bh5)) | 0;
- mid = (mid + Math.imul(ah6, bl5)) | 0;
- hi = (hi + Math.imul(ah6, bh5)) | 0;
- lo = (lo + Math.imul(al5, bl6)) | 0;
- mid = (mid + Math.imul(al5, bh6)) | 0;
- mid = (mid + Math.imul(ah5, bl6)) | 0;
- hi = (hi + Math.imul(ah5, bh6)) | 0;
- lo = (lo + Math.imul(al4, bl7)) | 0;
- mid = (mid + Math.imul(al4, bh7)) | 0;
- mid = (mid + Math.imul(ah4, bl7)) | 0;
- hi = (hi + Math.imul(ah4, bh7)) | 0;
- lo = (lo + Math.imul(al3, bl8)) | 0;
- mid = (mid + Math.imul(al3, bh8)) | 0;
- mid = (mid + Math.imul(ah3, bl8)) | 0;
- hi = (hi + Math.imul(ah3, bh8)) | 0;
- lo = (lo + Math.imul(al2, bl9)) | 0;
- mid = (mid + Math.imul(al2, bh9)) | 0;
- mid = (mid + Math.imul(ah2, bl9)) | 0;
- hi = (hi + Math.imul(ah2, bh9)) | 0;
- var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
- w11 &= 0x3ffffff;
- /* k = 12 */
- lo = Math.imul(al9, bl3);
- mid = Math.imul(al9, bh3);
- mid = (mid + Math.imul(ah9, bl3)) | 0;
- hi = Math.imul(ah9, bh3);
- lo = (lo + Math.imul(al8, bl4)) | 0;
- mid = (mid + Math.imul(al8, bh4)) | 0;
- mid = (mid + Math.imul(ah8, bl4)) | 0;
- hi = (hi + Math.imul(ah8, bh4)) | 0;
- lo = (lo + Math.imul(al7, bl5)) | 0;
- mid = (mid + Math.imul(al7, bh5)) | 0;
- mid = (mid + Math.imul(ah7, bl5)) | 0;
- hi = (hi + Math.imul(ah7, bh5)) | 0;
- lo = (lo + Math.imul(al6, bl6)) | 0;
- mid = (mid + Math.imul(al6, bh6)) | 0;
- mid = (mid + Math.imul(ah6, bl6)) | 0;
- hi = (hi + Math.imul(ah6, bh6)) | 0;
- lo = (lo + Math.imul(al5, bl7)) | 0;
- mid = (mid + Math.imul(al5, bh7)) | 0;
- mid = (mid + Math.imul(ah5, bl7)) | 0;
- hi = (hi + Math.imul(ah5, bh7)) | 0;
- lo = (lo + Math.imul(al4, bl8)) | 0;
- mid = (mid + Math.imul(al4, bh8)) | 0;
- mid = (mid + Math.imul(ah4, bl8)) | 0;
- hi = (hi + Math.imul(ah4, bh8)) | 0;
- lo = (lo + Math.imul(al3, bl9)) | 0;
- mid = (mid + Math.imul(al3, bh9)) | 0;
- mid = (mid + Math.imul(ah3, bl9)) | 0;
- hi = (hi + Math.imul(ah3, bh9)) | 0;
- var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
- w12 &= 0x3ffffff;
- /* k = 13 */
- lo = Math.imul(al9, bl4);
- mid = Math.imul(al9, bh4);
- mid = (mid + Math.imul(ah9, bl4)) | 0;
- hi = Math.imul(ah9, bh4);
- lo = (lo + Math.imul(al8, bl5)) | 0;
- mid = (mid + Math.imul(al8, bh5)) | 0;
- mid = (mid + Math.imul(ah8, bl5)) | 0;
- hi = (hi + Math.imul(ah8, bh5)) | 0;
- lo = (lo + Math.imul(al7, bl6)) | 0;
- mid = (mid + Math.imul(al7, bh6)) | 0;
- mid = (mid + Math.imul(ah7, bl6)) | 0;
- hi = (hi + Math.imul(ah7, bh6)) | 0;
- lo = (lo + Math.imul(al6, bl7)) | 0;
- mid = (mid + Math.imul(al6, bh7)) | 0;
- mid = (mid + Math.imul(ah6, bl7)) | 0;
- hi = (hi + Math.imul(ah6, bh7)) | 0;
- lo = (lo + Math.imul(al5, bl8)) | 0;
- mid = (mid + Math.imul(al5, bh8)) | 0;
- mid = (mid + Math.imul(ah5, bl8)) | 0;
- hi = (hi + Math.imul(ah5, bh8)) | 0;
- lo = (lo + Math.imul(al4, bl9)) | 0;
- mid = (mid + Math.imul(al4, bh9)) | 0;
- mid = (mid + Math.imul(ah4, bl9)) | 0;
- hi = (hi + Math.imul(ah4, bh9)) | 0;
- var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
- w13 &= 0x3ffffff;
- /* k = 14 */
- lo = Math.imul(al9, bl5);
- mid = Math.imul(al9, bh5);
- mid = (mid + Math.imul(ah9, bl5)) | 0;
- hi = Math.imul(ah9, bh5);
- lo = (lo + Math.imul(al8, bl6)) | 0;
- mid = (mid + Math.imul(al8, bh6)) | 0;
- mid = (mid + Math.imul(ah8, bl6)) | 0;
- hi = (hi + Math.imul(ah8, bh6)) | 0;
- lo = (lo + Math.imul(al7, bl7)) | 0;
- mid = (mid + Math.imul(al7, bh7)) | 0;
- mid = (mid + Math.imul(ah7, bl7)) | 0;
- hi = (hi + Math.imul(ah7, bh7)) | 0;
- lo = (lo + Math.imul(al6, bl8)) | 0;
- mid = (mid + Math.imul(al6, bh8)) | 0;
- mid = (mid + Math.imul(ah6, bl8)) | 0;
- hi = (hi + Math.imul(ah6, bh8)) | 0;
- lo = (lo + Math.imul(al5, bl9)) | 0;
- mid = (mid + Math.imul(al5, bh9)) | 0;
- mid = (mid + Math.imul(ah5, bl9)) | 0;
- hi = (hi + Math.imul(ah5, bh9)) | 0;
- var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
- w14 &= 0x3ffffff;
- /* k = 15 */
- lo = Math.imul(al9, bl6);
- mid = Math.imul(al9, bh6);
- mid = (mid + Math.imul(ah9, bl6)) | 0;
- hi = Math.imul(ah9, bh6);
- lo = (lo + Math.imul(al8, bl7)) | 0;
- mid = (mid + Math.imul(al8, bh7)) | 0;
- mid = (mid + Math.imul(ah8, bl7)) | 0;
- hi = (hi + Math.imul(ah8, bh7)) | 0;
- lo = (lo + Math.imul(al7, bl8)) | 0;
- mid = (mid + Math.imul(al7, bh8)) | 0;
- mid = (mid + Math.imul(ah7, bl8)) | 0;
- hi = (hi + Math.imul(ah7, bh8)) | 0;
- lo = (lo + Math.imul(al6, bl9)) | 0;
- mid = (mid + Math.imul(al6, bh9)) | 0;
- mid = (mid + Math.imul(ah6, bl9)) | 0;
- hi = (hi + Math.imul(ah6, bh9)) | 0;
- var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
- w15 &= 0x3ffffff;
- /* k = 16 */
- lo = Math.imul(al9, bl7);
- mid = Math.imul(al9, bh7);
- mid = (mid + Math.imul(ah9, bl7)) | 0;
- hi = Math.imul(ah9, bh7);
- lo = (lo + Math.imul(al8, bl8)) | 0;
- mid = (mid + Math.imul(al8, bh8)) | 0;
- mid = (mid + Math.imul(ah8, bl8)) | 0;
- hi = (hi + Math.imul(ah8, bh8)) | 0;
- lo = (lo + Math.imul(al7, bl9)) | 0;
- mid = (mid + Math.imul(al7, bh9)) | 0;
- mid = (mid + Math.imul(ah7, bl9)) | 0;
- hi = (hi + Math.imul(ah7, bh9)) | 0;
- var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
- w16 &= 0x3ffffff;
- /* k = 17 */
- lo = Math.imul(al9, bl8);
- mid = Math.imul(al9, bh8);
- mid = (mid + Math.imul(ah9, bl8)) | 0;
- hi = Math.imul(ah9, bh8);
- lo = (lo + Math.imul(al8, bl9)) | 0;
- mid = (mid + Math.imul(al8, bh9)) | 0;
- mid = (mid + Math.imul(ah8, bl9)) | 0;
- hi = (hi + Math.imul(ah8, bh9)) | 0;
- var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
- w17 &= 0x3ffffff;
- /* k = 18 */
- lo = Math.imul(al9, bl9);
- mid = Math.imul(al9, bh9);
- mid = (mid + Math.imul(ah9, bl9)) | 0;
- hi = Math.imul(ah9, bh9);
- var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
- c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
- w18 &= 0x3ffffff;
- o[0] = w0;
- o[1] = w1;
- o[2] = w2;
- o[3] = w3;
- o[4] = w4;
- o[5] = w5;
- o[6] = w6;
- o[7] = w7;
- o[8] = w8;
- o[9] = w9;
- o[10] = w10;
- o[11] = w11;
- o[12] = w12;
- o[13] = w13;
- o[14] = w14;
- o[15] = w15;
- o[16] = w16;
- o[17] = w17;
- o[18] = w18;
- if (c !== 0) {
- o[19] = c;
- out.length++;
- }
- return out;
- };
- // Polyfill comb
- if (!Math.imul) {
- comb10MulTo = smallMulTo;
- }
- function bigMulTo (self, num, out) {
- out.negative = num.negative ^ self.negative;
- out.length = self.length + num.length;
- var carry = 0;
- var hncarry = 0;
- for (var k = 0; k < out.length - 1; k++) {
- // Sum all words with the same `i + j = k` and accumulate `ncarry`,
- // note that ncarry could be >= 0x3ffffff
- var ncarry = hncarry;
- hncarry = 0;
- var rword = carry & 0x3ffffff;
- var maxJ = Math.min(k, num.length - 1);
- for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
- var i = k - j;
- var a = self.words[i] | 0;
- var b = num.words[j] | 0;
- var r = a * b;
- var lo = r & 0x3ffffff;
- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
- lo = (lo + rword) | 0;
- rword = lo & 0x3ffffff;
- ncarry = (ncarry + (lo >>> 26)) | 0;
- hncarry += ncarry >>> 26;
- ncarry &= 0x3ffffff;
- }
- out.words[k] = rword;
- carry = ncarry;
- ncarry = hncarry;
- }
- if (carry !== 0) {
- out.words[k] = carry;
- } else {
- out.length--;
- }
- return out.strip();
- }
- function jumboMulTo (self, num, out) {
- var fftm = new FFTM();
- return fftm.mulp(self, num, out);
- }
- BN.prototype.mulTo = function mulTo (num, out) {
- var res;
- var len = this.length + num.length;
- if (this.length === 10 && num.length === 10) {
- res = comb10MulTo(this, num, out);
- } else if (len < 63) {
- res = smallMulTo(this, num, out);
- } else if (len < 1024) {
- res = bigMulTo(this, num, out);
- } else {
- res = jumboMulTo(this, num, out);
- }
- return res;
- };
- // Cooley-Tukey algorithm for FFT
- // slightly revisited to rely on looping instead of recursion
- function FFTM (x, y) {
- this.x = x;
- this.y = y;
- }
- FFTM.prototype.makeRBT = function makeRBT (N) {
- var t = new Array(N);
- var l = BN.prototype._countBits(N) - 1;
- for (var i = 0; i < N; i++) {
- t[i] = this.revBin(i, l, N);
- }
- return t;
- };
- // Returns binary-reversed representation of `x`
- FFTM.prototype.revBin = function revBin (x, l, N) {
- if (x === 0 || x === N - 1) return x;
- var rb = 0;
- for (var i = 0; i < l; i++) {
- rb |= (x & 1) << (l - i - 1);
- x >>= 1;
- }
- return rb;
- };
- // Performs "tweedling" phase, therefore 'emulating'
- // behaviour of the recursive algorithm
- FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
- for (var i = 0; i < N; i++) {
- rtws[i] = rws[rbt[i]];
- itws[i] = iws[rbt[i]];
- }
- };
- FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
- this.permute(rbt, rws, iws, rtws, itws, N);
- for (var s = 1; s < N; s <<= 1) {
- var l = s << 1;
- var rtwdf = Math.cos(2 * Math.PI / l);
- var itwdf = Math.sin(2 * Math.PI / l);
- for (var p = 0; p < N; p += l) {
- var rtwdf_ = rtwdf;
- var itwdf_ = itwdf;
- for (var j = 0; j < s; j++) {
- var re = rtws[p + j];
- var ie = itws[p + j];
- var ro = rtws[p + j + s];
- var io = itws[p + j + s];
- var rx = rtwdf_ * ro - itwdf_ * io;
- io = rtwdf_ * io + itwdf_ * ro;
- ro = rx;
- rtws[p + j] = re + ro;
- itws[p + j] = ie + io;
- rtws[p + j + s] = re - ro;
- itws[p + j + s] = ie - io;
- /* jshint maxdepth : false */
- if (j !== l) {
- rx = rtwdf * rtwdf_ - itwdf * itwdf_;
- itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
- rtwdf_ = rx;
- }
- }
- }
- }
- };
- FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
- var N = Math.max(m, n) | 1;
- var odd = N & 1;
- var i = 0;
- for (N = N / 2 | 0; N; N = N >>> 1) {
- i++;
- }
- return 1 << i + 1 + odd;
- };
- FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
- if (N <= 1) return;
- for (var i = 0; i < N / 2; i++) {
- var t = rws[i];
- rws[i] = rws[N - i - 1];
- rws[N - i - 1] = t;
- t = iws[i];
- iws[i] = -iws[N - i - 1];
- iws[N - i - 1] = -t;
- }
- };
- FFTM.prototype.normalize13b = function normalize13b (ws, N) {
- var carry = 0;
- for (var i = 0; i < N / 2; i++) {
- var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
- Math.round(ws[2 * i] / N) +
- carry;
- ws[i] = w & 0x3ffffff;
- if (w < 0x4000000) {
- carry = 0;
- } else {
- carry = w / 0x4000000 | 0;
- }
- }
- return ws;
- };
- FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
- var carry = 0;
- for (var i = 0; i < len; i++) {
- carry = carry + (ws[i] | 0);
- rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
- rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
- }
- // Pad with zeroes
- for (i = 2 * len; i < N; ++i) {
- rws[i] = 0;
- }
- assert(carry === 0);
- assert((carry & ~0x1fff) === 0);
- };
- FFTM.prototype.stub = function stub (N) {
- var ph = new Array(N);
- for (var i = 0; i < N; i++) {
- ph[i] = 0;
- }
- return ph;
- };
- FFTM.prototype.mulp = function mulp (x, y, out) {
- var N = 2 * this.guessLen13b(x.length, y.length);
- var rbt = this.makeRBT(N);
- var _ = this.stub(N);
- var rws = new Array(N);
- var rwst = new Array(N);
- var iwst = new Array(N);
- var nrws = new Array(N);
- var nrwst = new Array(N);
- var niwst = new Array(N);
- var rmws = out.words;
- rmws.length = N;
- this.convert13b(x.words, x.length, rws, N);
- this.convert13b(y.words, y.length, nrws, N);
- this.transform(rws, _, rwst, iwst, N, rbt);
- this.transform(nrws, _, nrwst, niwst, N, rbt);
- for (var i = 0; i < N; i++) {
- var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
- iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
- rwst[i] = rx;
- }
- this.conjugate(rwst, iwst, N);
- this.transform(rwst, iwst, rmws, _, N, rbt);
- this.conjugate(rmws, _, N);
- this.normalize13b(rmws, N);
- out.negative = x.negative ^ y.negative;
- out.length = x.length + y.length;
- return out.strip();
- };
- // Multiply `this` by `num`
- BN.prototype.mul = function mul (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return this.mulTo(num, out);
- };
- // Multiply employing FFT
- BN.prototype.mulf = function mulf (num) {
- var out = new BN(null);
- out.words = new Array(this.length + num.length);
- return jumboMulTo(this, num, out);
- };
- // In-place Multiplication
- BN.prototype.imul = function imul (num) {
- return this.clone().mulTo(num, this);
- };
- BN.prototype.imuln = function imuln (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- // Carry
- var carry = 0;
- for (var i = 0; i < this.length; i++) {
- var w = (this.words[i] | 0) * num;
- var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
- carry >>= 26;
- carry += (w / 0x4000000) | 0;
- // NOTE: lo is 27bit maximum
- carry += lo >>> 26;
- this.words[i] = lo & 0x3ffffff;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.muln = function muln (num) {
- return this.clone().imuln(num);
- };
- // `this` * `this`
- BN.prototype.sqr = function sqr () {
- return this.mul(this);
- };
- // `this` * `this` in-place
- BN.prototype.isqr = function isqr () {
- return this.imul(this.clone());
- };
- // Math.pow(`this`, `num`)
- BN.prototype.pow = function pow (num) {
- var w = toBitArray(num);
- if (w.length === 0) return new BN(1);
- // Skip leading zeroes
- var res = this;
- for (var i = 0; i < w.length; i++, res = res.sqr()) {
- if (w[i] !== 0) break;
- }
- if (++i < w.length) {
- for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
- if (w[i] === 0) continue;
- res = res.mul(q);
- }
- }
- return res;
- };
- // Shift-left in-place
- BN.prototype.iushln = function iushln (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
- var i;
- if (r !== 0) {
- var carry = 0;
- for (i = 0; i < this.length; i++) {
- var newCarry = this.words[i] & carryMask;
- var c = ((this.words[i] | 0) - newCarry) << r;
- this.words[i] = c | carry;
- carry = newCarry >>> (26 - r);
- }
- if (carry) {
- this.words[i] = carry;
- this.length++;
- }
- }
- if (s !== 0) {
- for (i = this.length - 1; i >= 0; i--) {
- this.words[i + s] = this.words[i];
- }
- for (i = 0; i < s; i++) {
- this.words[i] = 0;
- }
- this.length += s;
- }
- return this.strip();
- };
- BN.prototype.ishln = function ishln (bits) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushln(bits);
- };
- // Shift-right in-place
- // NOTE: `hint` is a lowest bit before trailing zeroes
- // NOTE: if `extended` is present - it will be filled with destroyed bits
- BN.prototype.iushrn = function iushrn (bits, hint, extended) {
- assert(typeof bits === 'number' && bits >= 0);
- var h;
- if (hint) {
- h = (hint - (hint % 26)) / 26;
- } else {
- h = 0;
- }
- var r = bits % 26;
- var s = Math.min((bits - r) / 26, this.length);
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- var maskedWords = extended;
- h -= s;
- h = Math.max(0, h);
- // Extended mode, copy masked part
- if (maskedWords) {
- for (var i = 0; i < s; i++) {
- maskedWords.words[i] = this.words[i];
- }
- maskedWords.length = s;
- }
- if (s === 0) {
- // No-op, we should not move anything at all
- } else if (this.length > s) {
- this.length -= s;
- for (i = 0; i < this.length; i++) {
- this.words[i] = this.words[i + s];
- }
- } else {
- this.words[0] = 0;
- this.length = 1;
- }
- var carry = 0;
- for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
- var word = this.words[i] | 0;
- this.words[i] = (carry << (26 - r)) | (word >>> r);
- carry = word & mask;
- }
- // Push carried bits as a mask
- if (maskedWords && carry !== 0) {
- maskedWords.words[maskedWords.length++] = carry;
- }
- if (this.length === 0) {
- this.words[0] = 0;
- this.length = 1;
- }
- return this.strip();
- };
- BN.prototype.ishrn = function ishrn (bits, hint, extended) {
- // TODO(indutny): implement me
- assert(this.negative === 0);
- return this.iushrn(bits, hint, extended);
- };
- // Shift-left
- BN.prototype.shln = function shln (bits) {
- return this.clone().ishln(bits);
- };
- BN.prototype.ushln = function ushln (bits) {
- return this.clone().iushln(bits);
- };
- // Shift-right
- BN.prototype.shrn = function shrn (bits) {
- return this.clone().ishrn(bits);
- };
- BN.prototype.ushrn = function ushrn (bits) {
- return this.clone().iushrn(bits);
- };
- // Test if n bit is set
- BN.prototype.testn = function testn (bit) {
- assert(typeof bit === 'number' && bit >= 0);
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) return false;
- // Check bit and return
- var w = this.words[s];
- return !!(w & q);
- };
- // Return only lowers bits of number (in-place)
- BN.prototype.imaskn = function imaskn (bits) {
- assert(typeof bits === 'number' && bits >= 0);
- var r = bits % 26;
- var s = (bits - r) / 26;
- assert(this.negative === 0, 'imaskn works only with positive numbers');
- if (this.length <= s) {
- return this;
- }
- if (r !== 0) {
- s++;
- }
- this.length = Math.min(s, this.length);
- if (r !== 0) {
- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
- this.words[this.length - 1] &= mask;
- }
- return this.strip();
- };
- // Return only lowers bits of number
- BN.prototype.maskn = function maskn (bits) {
- return this.clone().imaskn(bits);
- };
- // Add plain number `num` to `this`
- BN.prototype.iaddn = function iaddn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.isubn(-num);
- // Possible sign change
- if (this.negative !== 0) {
- if (this.length === 1 && (this.words[0] | 0) < num) {
- this.words[0] = num - (this.words[0] | 0);
- this.negative = 0;
- return this;
- }
- this.negative = 0;
- this.isubn(num);
- this.negative = 1;
- return this;
- }
- // Add without checks
- return this._iaddn(num);
- };
- BN.prototype._iaddn = function _iaddn (num) {
- this.words[0] += num;
- // Carry
- for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
- this.words[i] -= 0x4000000;
- if (i === this.length - 1) {
- this.words[i + 1] = 1;
- } else {
- this.words[i + 1]++;
- }
- }
- this.length = Math.max(this.length, i + 1);
- return this;
- };
- // Subtract plain number `num` from `this`
- BN.prototype.isubn = function isubn (num) {
- assert(typeof num === 'number');
- assert(num < 0x4000000);
- if (num < 0) return this.iaddn(-num);
- if (this.negative !== 0) {
- this.negative = 0;
- this.iaddn(num);
- this.negative = 1;
- return this;
- }
- this.words[0] -= num;
- if (this.length === 1 && this.words[0] < 0) {
- this.words[0] = -this.words[0];
- this.negative = 1;
- } else {
- // Carry
- for (var i = 0; i < this.length && this.words[i] < 0; i++) {
- this.words[i] += 0x4000000;
- this.words[i + 1] -= 1;
- }
- }
- return this.strip();
- };
- BN.prototype.addn = function addn (num) {
- return this.clone().iaddn(num);
- };
- BN.prototype.subn = function subn (num) {
- return this.clone().isubn(num);
- };
- BN.prototype.iabs = function iabs () {
- this.negative = 0;
- return this;
- };
- BN.prototype.abs = function abs () {
- return this.clone().iabs();
- };
- BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
- var len = num.length + shift;
- var i;
- this._expand(len);
- var w;
- var carry = 0;
- for (i = 0; i < num.length; i++) {
- w = (this.words[i + shift] | 0) + carry;
- var right = (num.words[i] | 0) * mul;
- w -= right & 0x3ffffff;
- carry = (w >> 26) - ((right / 0x4000000) | 0);
- this.words[i + shift] = w & 0x3ffffff;
- }
- for (; i < this.length - shift; i++) {
- w = (this.words[i + shift] | 0) + carry;
- carry = w >> 26;
- this.words[i + shift] = w & 0x3ffffff;
- }
- if (carry === 0) return this.strip();
- // Subtraction overflow
- assert(carry === -1);
- carry = 0;
- for (i = 0; i < this.length; i++) {
- w = -(this.words[i] | 0) + carry;
- carry = w >> 26;
- this.words[i] = w & 0x3ffffff;
- }
- this.negative = 1;
- return this.strip();
- };
- BN.prototype._wordDiv = function _wordDiv (num, mode) {
- var shift = this.length - num.length;
- var a = this.clone();
- var b = num;
- // Normalize
- var bhi = b.words[b.length - 1] | 0;
- var bhiBits = this._countBits(bhi);
- shift = 26 - bhiBits;
- if (shift !== 0) {
- b = b.ushln(shift);
- a.iushln(shift);
- bhi = b.words[b.length - 1] | 0;
- }
- // Initialize quotient
- var m = a.length - b.length;
- var q;
- if (mode !== 'mod') {
- q = new BN(null);
- q.length = m + 1;
- q.words = new Array(q.length);
- for (var i = 0; i < q.length; i++) {
- q.words[i] = 0;
- }
- }
- var diff = a.clone()._ishlnsubmul(b, 1, m);
- if (diff.negative === 0) {
- a = diff;
- if (q) {
- q.words[m] = 1;
- }
- }
- for (var j = m - 1; j >= 0; j--) {
- var qj = (a.words[b.length + j] | 0) * 0x4000000 +
- (a.words[b.length + j - 1] | 0);
- // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
- // (0x7ffffff)
- qj = Math.min((qj / bhi) | 0, 0x3ffffff);
- a._ishlnsubmul(b, qj, j);
- while (a.negative !== 0) {
- qj--;
- a.negative = 0;
- a._ishlnsubmul(b, 1, j);
- if (!a.isZero()) {
- a.negative ^= 1;
- }
- }
- if (q) {
- q.words[j] = qj;
- }
- }
- if (q) {
- q.strip();
- }
- a.strip();
- // Denormalize
- if (mode !== 'div' && shift !== 0) {
- a.iushrn(shift);
- }
- return {
- div: q || null,
- mod: a
- };
- };
- // NOTE: 1) `mode` can be set to `mod` to request mod only,
- // to `div` to request div only, or be absent to
- // request both div & mod
- // 2) `positive` is true if unsigned mod is requested
- BN.prototype.divmod = function divmod (num, mode, positive) {
- assert(!num.isZero());
- if (this.isZero()) {
- return {
- div: new BN(0),
- mod: new BN(0)
- };
- }
- var div, mod, res;
- if (this.negative !== 0 && num.negative === 0) {
- res = this.neg().divmod(num, mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.iadd(num);
- }
- }
- return {
- div: div,
- mod: mod
- };
- }
- if (this.negative === 0 && num.negative !== 0) {
- res = this.divmod(num.neg(), mode);
- if (mode !== 'mod') {
- div = res.div.neg();
- }
- return {
- div: div,
- mod: res.mod
- };
- }
- if ((this.negative & num.negative) !== 0) {
- res = this.neg().divmod(num.neg(), mode);
- if (mode !== 'div') {
- mod = res.mod.neg();
- if (positive && mod.negative !== 0) {
- mod.isub(num);
- }
- }
- return {
- div: res.div,
- mod: mod
- };
- }
- // Both numbers are positive at this point
- // Strip both numbers to approximate shift value
- if (num.length > this.length || this.cmp(num) < 0) {
- return {
- div: new BN(0),
- mod: this
- };
- }
- // Very short reduction
- if (num.length === 1) {
- if (mode === 'div') {
- return {
- div: this.divn(num.words[0]),
- mod: null
- };
- }
- if (mode === 'mod') {
- return {
- div: null,
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return {
- div: this.divn(num.words[0]),
- mod: new BN(this.modn(num.words[0]))
- };
- }
- return this._wordDiv(num, mode);
- };
- // Find `this` / `num`
- BN.prototype.div = function div (num) {
- return this.divmod(num, 'div', false).div;
- };
- // Find `this` % `num`
- BN.prototype.mod = function mod (num) {
- return this.divmod(num, 'mod', false).mod;
- };
- BN.prototype.umod = function umod (num) {
- return this.divmod(num, 'mod', true).mod;
- };
- // Find Round(`this` / `num`)
- BN.prototype.divRound = function divRound (num) {
- var dm = this.divmod(num);
- // Fast case - exact division
- if (dm.mod.isZero()) return dm.div;
- var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
- var half = num.ushrn(1);
- var r2 = num.andln(1);
- var cmp = mod.cmp(half);
- // Round down
- if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
- // Round up
- return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
- };
- BN.prototype.modn = function modn (num) {
- assert(num <= 0x3ffffff);
- var p = (1 << 26) % num;
- var acc = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- acc = (p * acc + (this.words[i] | 0)) % num;
- }
- return acc;
- };
- // In-place division by number
- BN.prototype.idivn = function idivn (num) {
- assert(num <= 0x3ffffff);
- var carry = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var w = (this.words[i] | 0) + carry * 0x4000000;
- this.words[i] = (w / num) | 0;
- carry = w % num;
- }
- return this.strip();
- };
- BN.prototype.divn = function divn (num) {
- return this.clone().idivn(num);
- };
- BN.prototype.egcd = function egcd (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var x = this;
- var y = p.clone();
- if (x.negative !== 0) {
- x = x.umod(p);
- } else {
- x = x.clone();
- }
- // A * x + B * y = x
- var A = new BN(1);
- var B = new BN(0);
- // C * x + D * y = y
- var C = new BN(0);
- var D = new BN(1);
- var g = 0;
- while (x.isEven() && y.isEven()) {
- x.iushrn(1);
- y.iushrn(1);
- ++g;
- }
- var yp = y.clone();
- var xp = x.clone();
- while (!x.isZero()) {
- for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- x.iushrn(i);
- while (i-- > 0) {
- if (A.isOdd() || B.isOdd()) {
- A.iadd(yp);
- B.isub(xp);
- }
- A.iushrn(1);
- B.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- y.iushrn(j);
- while (j-- > 0) {
- if (C.isOdd() || D.isOdd()) {
- C.iadd(yp);
- D.isub(xp);
- }
- C.iushrn(1);
- D.iushrn(1);
- }
- }
- if (x.cmp(y) >= 0) {
- x.isub(y);
- A.isub(C);
- B.isub(D);
- } else {
- y.isub(x);
- C.isub(A);
- D.isub(B);
- }
- }
- return {
- a: C,
- b: D,
- gcd: y.iushln(g)
- };
- };
- // This is reduced incarnation of the binary EEA
- // above, designated to invert members of the
- // _prime_ fields F(p) at a maximal speed
- BN.prototype._invmp = function _invmp (p) {
- assert(p.negative === 0);
- assert(!p.isZero());
- var a = this;
- var b = p.clone();
- if (a.negative !== 0) {
- a = a.umod(p);
- } else {
- a = a.clone();
- }
- var x1 = new BN(1);
- var x2 = new BN(0);
- var delta = b.clone();
- while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
- for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
- if (i > 0) {
- a.iushrn(i);
- while (i-- > 0) {
- if (x1.isOdd()) {
- x1.iadd(delta);
- }
- x1.iushrn(1);
- }
- }
- for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
- if (j > 0) {
- b.iushrn(j);
- while (j-- > 0) {
- if (x2.isOdd()) {
- x2.iadd(delta);
- }
- x2.iushrn(1);
- }
- }
- if (a.cmp(b) >= 0) {
- a.isub(b);
- x1.isub(x2);
- } else {
- b.isub(a);
- x2.isub(x1);
- }
- }
- var res;
- if (a.cmpn(1) === 0) {
- res = x1;
- } else {
- res = x2;
- }
- if (res.cmpn(0) < 0) {
- res.iadd(p);
- }
- return res;
- };
- BN.prototype.gcd = function gcd (num) {
- if (this.isZero()) return num.abs();
- if (num.isZero()) return this.abs();
- var a = this.clone();
- var b = num.clone();
- a.negative = 0;
- b.negative = 0;
- // Remove common factor of two
- for (var shift = 0; a.isEven() && b.isEven(); shift++) {
- a.iushrn(1);
- b.iushrn(1);
- }
- do {
- while (a.isEven()) {
- a.iushrn(1);
- }
- while (b.isEven()) {
- b.iushrn(1);
- }
- var r = a.cmp(b);
- if (r < 0) {
- // Swap `a` and `b` to make `a` always bigger than `b`
- var t = a;
- a = b;
- b = t;
- } else if (r === 0 || b.cmpn(1) === 0) {
- break;
- }
- a.isub(b);
- } while (true);
- return b.iushln(shift);
- };
- // Invert number in the field F(num)
- BN.prototype.invm = function invm (num) {
- return this.egcd(num).a.umod(num);
- };
- BN.prototype.isEven = function isEven () {
- return (this.words[0] & 1) === 0;
- };
- BN.prototype.isOdd = function isOdd () {
- return (this.words[0] & 1) === 1;
- };
- // And first word and num
- BN.prototype.andln = function andln (num) {
- return this.words[0] & num;
- };
- // Increment at the bit position in-line
- BN.prototype.bincn = function bincn (bit) {
- assert(typeof bit === 'number');
- var r = bit % 26;
- var s = (bit - r) / 26;
- var q = 1 << r;
- // Fast case: bit is much higher than all existing words
- if (this.length <= s) {
- this._expand(s + 1);
- this.words[s] |= q;
- return this;
- }
- // Add bit and propagate, if needed
- var carry = q;
- for (var i = s; carry !== 0 && i < this.length; i++) {
- var w = this.words[i] | 0;
- w += carry;
- carry = w >>> 26;
- w &= 0x3ffffff;
- this.words[i] = w;
- }
- if (carry !== 0) {
- this.words[i] = carry;
- this.length++;
- }
- return this;
- };
- BN.prototype.isZero = function isZero () {
- return this.length === 1 && this.words[0] === 0;
- };
- BN.prototype.cmpn = function cmpn (num) {
- var negative = num < 0;
- if (this.negative !== 0 && !negative) return -1;
- if (this.negative === 0 && negative) return 1;
- this.strip();
- var res;
- if (this.length > 1) {
- res = 1;
- } else {
- if (negative) {
- num = -num;
- }
- assert(num <= 0x3ffffff, 'Number is too big');
- var w = this.words[0] | 0;
- res = w === num ? 0 : w < num ? -1 : 1;
- }
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Compare two numbers and return:
- // 1 - if `this` > `num`
- // 0 - if `this` == `num`
- // -1 - if `this` < `num`
- BN.prototype.cmp = function cmp (num) {
- if (this.negative !== 0 && num.negative === 0) return -1;
- if (this.negative === 0 && num.negative !== 0) return 1;
- var res = this.ucmp(num);
- if (this.negative !== 0) return -res | 0;
- return res;
- };
- // Unsigned comparison
- BN.prototype.ucmp = function ucmp (num) {
- // At this point both numbers have the same sign
- if (this.length > num.length) return 1;
- if (this.length < num.length) return -1;
- var res = 0;
- for (var i = this.length - 1; i >= 0; i--) {
- var a = this.words[i] | 0;
- var b = num.words[i] | 0;
- if (a === b) continue;
- if (a < b) {
- res = -1;
- } else if (a > b) {
- res = 1;
- }
- break;
- }
- return res;
- };
- BN.prototype.gtn = function gtn (num) {
- return this.cmpn(num) === 1;
- };
- BN.prototype.gt = function gt (num) {
- return this.cmp(num) === 1;
- };
- BN.prototype.gten = function gten (num) {
- return this.cmpn(num) >= 0;
- };
- BN.prototype.gte = function gte (num) {
- return this.cmp(num) >= 0;
- };
- BN.prototype.ltn = function ltn (num) {
- return this.cmpn(num) === -1;
- };
- BN.prototype.lt = function lt (num) {
- return this.cmp(num) === -1;
- };
- BN.prototype.lten = function lten (num) {
- return this.cmpn(num) <= 0;
- };
- BN.prototype.lte = function lte (num) {
- return this.cmp(num) <= 0;
- };
- BN.prototype.eqn = function eqn (num) {
- return this.cmpn(num) === 0;
- };
- BN.prototype.eq = function eq (num) {
- return this.cmp(num) === 0;
- };
- //
- // A reduce context, could be using montgomery or something better, depending
- // on the `m` itself.
- //
- BN.red = function red (num) {
- return new Red(num);
- };
- BN.prototype.toRed = function toRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- assert(this.negative === 0, 'red works only with positives');
- return ctx.convertTo(this)._forceRed(ctx);
- };
- BN.prototype.fromRed = function fromRed () {
- assert(this.red, 'fromRed works only with numbers in reduction context');
- return this.red.convertFrom(this);
- };
- BN.prototype._forceRed = function _forceRed (ctx) {
- this.red = ctx;
- return this;
- };
- BN.prototype.forceRed = function forceRed (ctx) {
- assert(!this.red, 'Already a number in reduction context');
- return this._forceRed(ctx);
- };
- BN.prototype.redAdd = function redAdd (num) {
- assert(this.red, 'redAdd works only with red numbers');
- return this.red.add(this, num);
- };
- BN.prototype.redIAdd = function redIAdd (num) {
- assert(this.red, 'redIAdd works only with red numbers');
- return this.red.iadd(this, num);
- };
- BN.prototype.redSub = function redSub (num) {
- assert(this.red, 'redSub works only with red numbers');
- return this.red.sub(this, num);
- };
- BN.prototype.redISub = function redISub (num) {
- assert(this.red, 'redISub works only with red numbers');
- return this.red.isub(this, num);
- };
- BN.prototype.redShl = function redShl (num) {
- assert(this.red, 'redShl works only with red numbers');
- return this.red.shl(this, num);
- };
- BN.prototype.redMul = function redMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.mul(this, num);
- };
- BN.prototype.redIMul = function redIMul (num) {
- assert(this.red, 'redMul works only with red numbers');
- this.red._verify2(this, num);
- return this.red.imul(this, num);
- };
- BN.prototype.redSqr = function redSqr () {
- assert(this.red, 'redSqr works only with red numbers');
- this.red._verify1(this);
- return this.red.sqr(this);
- };
- BN.prototype.redISqr = function redISqr () {
- assert(this.red, 'redISqr works only with red numbers');
- this.red._verify1(this);
- return this.red.isqr(this);
- };
- // Square root over p
- BN.prototype.redSqrt = function redSqrt () {
- assert(this.red, 'redSqrt works only with red numbers');
- this.red._verify1(this);
- return this.red.sqrt(this);
- };
- BN.prototype.redInvm = function redInvm () {
- assert(this.red, 'redInvm works only with red numbers');
- this.red._verify1(this);
- return this.red.invm(this);
- };
- // Return negative clone of `this` % `red modulo`
- BN.prototype.redNeg = function redNeg () {
- assert(this.red, 'redNeg works only with red numbers');
- this.red._verify1(this);
- return this.red.neg(this);
- };
- BN.prototype.redPow = function redPow (num) {
- assert(this.red && !num.red, 'redPow(normalNum)');
- this.red._verify1(this);
- return this.red.pow(this, num);
- };
- // Prime numbers with efficient reduction
- var primes = {
- k256: null,
- p224: null,
- p192: null,
- p25519: null
- };
- // Pseudo-Mersenne prime
- function MPrime (name, p) {
- // P = 2 ^ N - K
- this.name = name;
- this.p = new BN(p, 16);
- this.n = this.p.bitLength();
- this.k = new BN(1).iushln(this.n).isub(this.p);
- this.tmp = this._tmp();
- }
- MPrime.prototype._tmp = function _tmp () {
- var tmp = new BN(null);
- tmp.words = new Array(Math.ceil(this.n / 13));
- return tmp;
- };
- MPrime.prototype.ireduce = function ireduce (num) {
- // Assumes that `num` is less than `P^2`
- // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
- var r = num;
- var rlen;
- do {
- this.split(r, this.tmp);
- r = this.imulK(r);
- r = r.iadd(this.tmp);
- rlen = r.bitLength();
- } while (rlen > this.n);
- var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
- if (cmp === 0) {
- r.words[0] = 0;
- r.length = 1;
- } else if (cmp > 0) {
- r.isub(this.p);
- } else {
- r.strip();
- }
- return r;
- };
- MPrime.prototype.split = function split (input, out) {
- input.iushrn(this.n, 0, out);
- };
- MPrime.prototype.imulK = function imulK (num) {
- return num.imul(this.k);
- };
- function K256 () {
- MPrime.call(
- this,
- 'k256',
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
- }
- inherits(K256, MPrime);
- K256.prototype.split = function split (input, output) {
- // 256 = 9 * 26 + 22
- var mask = 0x3fffff;
- var outLen = Math.min(input.length, 9);
- for (var i = 0; i < outLen; i++) {
- output.words[i] = input.words[i];
- }
- output.length = outLen;
- if (input.length <= 9) {
- input.words[0] = 0;
- input.length = 1;
- return;
- }
- // Shift by 9 limbs
- var prev = input.words[9];
- output.words[output.length++] = prev & mask;
- for (i = 10; i < input.length; i++) {
- var next = input.words[i] | 0;
- input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
- prev = next;
- }
- prev >>>= 22;
- input.words[i - 10] = prev;
- if (prev === 0 && input.length > 10) {
- input.length -= 10;
- } else {
- input.length -= 9;
- }
- };
- K256.prototype.imulK = function imulK (num) {
- // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
- num.words[num.length] = 0;
- num.words[num.length + 1] = 0;
- num.length += 2;
- // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
- var lo = 0;
- for (var i = 0; i < num.length; i++) {
- var w = num.words[i] | 0;
- lo += w * 0x3d1;
- num.words[i] = lo & 0x3ffffff;
- lo = w * 0x40 + ((lo / 0x4000000) | 0);
- }
- // Fast length reduction
- if (num.words[num.length - 1] === 0) {
- num.length--;
- if (num.words[num.length - 1] === 0) {
- num.length--;
- }
- }
- return num;
- };
- function P224 () {
- MPrime.call(
- this,
- 'p224',
- 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
- }
- inherits(P224, MPrime);
- function P192 () {
- MPrime.call(
- this,
- 'p192',
- 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
- }
- inherits(P192, MPrime);
- function P25519 () {
- // 2 ^ 255 - 19
- MPrime.call(
- this,
- '25519',
- '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
- }
- inherits(P25519, MPrime);
- P25519.prototype.imulK = function imulK (num) {
- // K = 0x13
- var carry = 0;
- for (var i = 0; i < num.length; i++) {
- var hi = (num.words[i] | 0) * 0x13 + carry;
- var lo = hi & 0x3ffffff;
- hi >>>= 26;
- num.words[i] = lo;
- carry = hi;
- }
- if (carry !== 0) {
- num.words[num.length++] = carry;
- }
- return num;
- };
- // Exported mostly for testing purposes, use plain name instead
- BN._prime = function prime (name) {
- // Cached version of prime
- if (primes[name]) return primes[name];
- var prime;
- if (name === 'k256') {
- prime = new K256();
- } else if (name === 'p224') {
- prime = new P224();
- } else if (name === 'p192') {
- prime = new P192();
- } else if (name === 'p25519') {
- prime = new P25519();
- } else {
- throw new Error('Unknown prime ' + name);
- }
- primes[name] = prime;
- return prime;
- };
- //
- // Base reduction engine
- //
- function Red (m) {
- if (typeof m === 'string') {
- var prime = BN._prime(m);
- this.m = prime.p;
- this.prime = prime;
- } else {
- assert(m.gtn(1), 'modulus must be greater than 1');
- this.m = m;
- this.prime = null;
- }
- }
- Red.prototype._verify1 = function _verify1 (a) {
- assert(a.negative === 0, 'red works only with positives');
- assert(a.red, 'red works only with red numbers');
- };
- Red.prototype._verify2 = function _verify2 (a, b) {
- assert((a.negative | b.negative) === 0, 'red works only with positives');
- assert(a.red && a.red === b.red,
- 'red works only with red numbers');
- };
- Red.prototype.imod = function imod (a) {
- if (this.prime) return this.prime.ireduce(a)._forceRed(this);
- return a.umod(this.m)._forceRed(this);
- };
- Red.prototype.neg = function neg (a) {
- if (a.isZero()) {
- return a.clone();
- }
- return this.m.sub(a)._forceRed(this);
- };
- Red.prototype.add = function add (a, b) {
- this._verify2(a, b);
- var res = a.add(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.iadd = function iadd (a, b) {
- this._verify2(a, b);
- var res = a.iadd(b);
- if (res.cmp(this.m) >= 0) {
- res.isub(this.m);
- }
- return res;
- };
- Red.prototype.sub = function sub (a, b) {
- this._verify2(a, b);
- var res = a.sub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Red.prototype.isub = function isub (a, b) {
- this._verify2(a, b);
- var res = a.isub(b);
- if (res.cmpn(0) < 0) {
- res.iadd(this.m);
- }
- return res;
- };
- Red.prototype.shl = function shl (a, num) {
- this._verify1(a);
- return this.imod(a.ushln(num));
- };
- Red.prototype.imul = function imul (a, b) {
- this._verify2(a, b);
- return this.imod(a.imul(b));
- };
- Red.prototype.mul = function mul (a, b) {
- this._verify2(a, b);
- return this.imod(a.mul(b));
- };
- Red.prototype.isqr = function isqr (a) {
- return this.imul(a, a.clone());
- };
- Red.prototype.sqr = function sqr (a) {
- return this.mul(a, a);
- };
- Red.prototype.sqrt = function sqrt (a) {
- if (a.isZero()) return a.clone();
- var mod3 = this.m.andln(3);
- assert(mod3 % 2 === 1);
- // Fast case
- if (mod3 === 3) {
- var pow = this.m.add(new BN(1)).iushrn(2);
- return this.pow(a, pow);
- }
- // Tonelli-Shanks algorithm (Totally unoptimized and slow)
- //
- // Find Q and S, that Q * 2 ^ S = (P - 1)
- var q = this.m.subn(1);
- var s = 0;
- while (!q.isZero() && q.andln(1) === 0) {
- s++;
- q.iushrn(1);
- }
- assert(!q.isZero());
- var one = new BN(1).toRed(this);
- var nOne = one.redNeg();
- // Find quadratic non-residue
- // NOTE: Max is such because of generalized Riemann hypothesis.
- var lpow = this.m.subn(1).iushrn(1);
- var z = this.m.bitLength();
- z = new BN(2 * z * z).toRed(this);
- while (this.pow(z, lpow).cmp(nOne) !== 0) {
- z.redIAdd(nOne);
- }
- var c = this.pow(z, q);
- var r = this.pow(a, q.addn(1).iushrn(1));
- var t = this.pow(a, q);
- var m = s;
- while (t.cmp(one) !== 0) {
- var tmp = t;
- for (var i = 0; tmp.cmp(one) !== 0; i++) {
- tmp = tmp.redSqr();
- }
- assert(i < m);
- var b = this.pow(c, new BN(1).iushln(m - i - 1));
- r = r.redMul(b);
- c = b.redSqr();
- t = t.redMul(c);
- m = i;
- }
- return r;
- };
- Red.prototype.invm = function invm (a) {
- var inv = a._invmp(this.m);
- if (inv.negative !== 0) {
- inv.negative = 0;
- return this.imod(inv).redNeg();
- } else {
- return this.imod(inv);
- }
- };
- Red.prototype.pow = function pow (a, num) {
- if (num.isZero()) return new BN(1);
- if (num.cmpn(1) === 0) return a.clone();
- var windowSize = 4;
- var wnd = new Array(1 << windowSize);
- wnd[0] = new BN(1).toRed(this);
- wnd[1] = a;
- for (var i = 2; i < wnd.length; i++) {
- wnd[i] = this.mul(wnd[i - 1], a);
- }
- var res = wnd[0];
- var current = 0;
- var currentLen = 0;
- var start = num.bitLength() % 26;
- if (start === 0) {
- start = 26;
- }
- for (i = num.length - 1; i >= 0; i--) {
- var word = num.words[i];
- for (var j = start - 1; j >= 0; j--) {
- var bit = (word >> j) & 1;
- if (res !== wnd[0]) {
- res = this.sqr(res);
- }
- if (bit === 0 && current === 0) {
- currentLen = 0;
- continue;
- }
- current <<= 1;
- current |= bit;
- currentLen++;
- if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
- res = this.mul(res, wnd[current]);
- currentLen = 0;
- current = 0;
- }
- start = 26;
- }
- return res;
- };
- Red.prototype.convertTo = function convertTo (num) {
- var r = num.umod(this.m);
- return r === num ? r.clone() : r;
- };
- Red.prototype.convertFrom = function convertFrom (num) {
- var res = num.clone();
- res.red = null;
- return res;
- };
- //
- // Montgomery method engine
- //
- BN.mont = function mont (num) {
- return new Mont(num);
- };
- function Mont (m) {
- Red.call(this, m);
- this.shift = this.m.bitLength();
- if (this.shift % 26 !== 0) {
- this.shift += 26 - (this.shift % 26);
- }
- this.r = new BN(1).iushln(this.shift);
- this.r2 = this.imod(this.r.sqr());
- this.rinv = this.r._invmp(this.m);
- this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
- this.minv = this.minv.umod(this.r);
- this.minv = this.r.sub(this.minv);
- }
- inherits(Mont, Red);
- Mont.prototype.convertTo = function convertTo (num) {
- return this.imod(num.ushln(this.shift));
- };
- Mont.prototype.convertFrom = function convertFrom (num) {
- var r = this.imod(num.mul(this.rinv));
- r.red = null;
- return r;
- };
- Mont.prototype.imul = function imul (a, b) {
- if (a.isZero() || b.isZero()) {
- a.words[0] = 0;
- a.length = 1;
- return a;
- }
- var t = a.imul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.mul = function mul (a, b) {
- if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
- var t = a.mul(b);
- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
- var u = t.isub(c).iushrn(this.shift);
- var res = u;
- if (u.cmp(this.m) >= 0) {
- res = u.isub(this.m);
- } else if (u.cmpn(0) < 0) {
- res = u.iadd(this.m);
- }
- return res._forceRed(this);
- };
- Mont.prototype.invm = function invm (a) {
- // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
- var res = this.imod(a._invmp(this.m).mul(this.r2));
- return res._forceRed(this);
- };
- })(typeof module === 'undefined' || module, this);
- },{}],5:[function(require,module,exports){
- var r;
- module.exports = function rand(len) {
- if (!r)
- r = new Rand(null);
- return r.generate(len);
- };
- function Rand(rand) {
- this.rand = rand;
- }
- module.exports.Rand = Rand;
- Rand.prototype.generate = function generate(len) {
- return this._rand(len);
- };
- // Emulate crypto API using randy
- Rand.prototype._rand = function _rand(n) {
- if (this.rand.getBytes)
- return this.rand.getBytes(n);
- var res = new Uint8Array(n);
- for (var i = 0; i < res.length; i++)
- res[i] = this.rand.getByte();
- return res;
- };
- if (typeof self === 'object') {
- if (self.crypto && self.crypto.getRandomValues) {
- // Modern browsers
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- self.crypto.getRandomValues(arr);
- return arr;
- };
- } else if (self.msCrypto && self.msCrypto.getRandomValues) {
- // IE
- Rand.prototype._rand = function _rand(n) {
- var arr = new Uint8Array(n);
- self.msCrypto.getRandomValues(arr);
- return arr;
- };
- // Safari's WebWorkers do not have `crypto`
- } else if (typeof window === 'object') {
- // Old junk
- Rand.prototype._rand = function() {
- throw new Error('Not implemented yet');
- };
- }
- } else {
- // Node.js or Web worker with no crypto support
- try {
- var crypto = require('crypto');
- if (typeof crypto.randomBytes !== 'function')
- throw new Error('Not supported');
- Rand.prototype._rand = function _rand(n) {
- return crypto.randomBytes(n);
- };
- } catch (e) {
- }
- }
- },{"crypto":63}],6:[function(require,module,exports){
- (function (Buffer){
- var Transform = require('stream').Transform
- var inherits = require('inherits')
- var StringDecoder = require('string_decoder').StringDecoder
- module.exports = CipherBase
- inherits(CipherBase, Transform)
- function CipherBase (hashMode) {
- Transform.call(this)
- this.hashMode = typeof hashMode === 'string'
- if (this.hashMode) {
- this[hashMode] = this._finalOrDigest
- } else {
- this.final = this._finalOrDigest
- }
- this._decoder = null
- this._encoding = null
- }
- CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
- if (typeof data === 'string') {
- data = new Buffer(data, inputEnc)
- }
- var outData = this._update(data)
- if (this.hashMode) {
- return this
- }
- if (outputEnc) {
- outData = this._toString(outData, outputEnc)
- }
- return outData
- }
- CipherBase.prototype.setAutoPadding = function () {}
- CipherBase.prototype.getAuthTag = function () {
- throw new Error('trying to get auth tag in unsupported state')
- }
- CipherBase.prototype.setAuthTag = function () {
- throw new Error('trying to set auth tag in unsupported state')
- }
- CipherBase.prototype.setAAD = function () {
- throw new Error('trying to set aad in unsupported state')
- }
- CipherBase.prototype._transform = function (data, _, next) {
- var err
- try {
- if (this.hashMode) {
- this._update(data)
- } else {
- this.push(this._update(data))
- }
- } catch (e) {
- err = e
- } finally {
- next(err)
- }
- }
- CipherBase.prototype._flush = function (done) {
- var err
- try {
- this.push(this._final())
- } catch (e) {
- err = e
- } finally {
- done(err)
- }
- }
- CipherBase.prototype._finalOrDigest = function (outputEnc) {
- var outData = this._final() || new Buffer('')
- if (outputEnc) {
- outData = this._toString(outData, outputEnc, true)
- }
- return outData
- }
- CipherBase.prototype._toString = function (value, enc, fin) {
- if (!this._decoder) {
- this._decoder = new StringDecoder(enc)
- this._encoding = enc
- }
- if (this._encoding !== enc) {
- throw new Error('can\'t switch encodings')
- }
- var out = this._decoder.write(value)
- if (fin) {
- out += this._decoder.end()
- }
- return out
- }
- }).call(this,require("buffer").Buffer)
- },{"buffer":65,"inherits":34,"stream":85,"string_decoder":86}],7:[function(require,module,exports){
- (function (Buffer){
- 'use strict';
- var inherits = require('inherits')
- var md5 = require('./md5')
- var rmd160 = require('ripemd160')
- var sha = require('sha.js')
- var Base = require('cipher-base')
- function HashNoConstructor(hash) {
- Base.call(this, 'digest')
- this._hash = hash
- this.buffers = []
- }
- inherits(HashNoConstructor, Base)
- HashNoConstructor.prototype._update = function (data) {
- this.buffers.push(data)
- }
- HashNoConstructor.prototype._final = function () {
- var buf = Buffer.concat(this.buffers)
- var r = this._hash(buf)
- this.buffers = null
- return r
- }
- function Hash(hash) {
- Base.call(this, 'digest')
- this._hash = hash
- }
- inherits(Hash, Base)
- Hash.prototype._update = function (data) {
- this._hash.update(data)
- }
- Hash.prototype._final = function () {
- return this._hash.digest()
- }
- module.exports = function createHash (alg) {
- alg = alg.toLowerCase()
- if ('md5' === alg) return new HashNoConstructor(md5)
- if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160)
- return new Hash(sha(alg))
- }
- }).call(this,require("buffer").Buffer)
- },{"./md5":9,"buffer":65,"cipher-base":6,"inherits":34,"ripemd160":44,"sha.js":53}],8:[function(require,module,exports){
- (function (Buffer){
- 'use strict';
- var intSize = 4;
- var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
- var chrsz = 8;
- function toArray(buf, bigEndian) {
- if ((buf.length % intSize) !== 0) {
- var len = buf.length + (intSize - (buf.length % intSize));
- buf = Buffer.concat([buf, zeroBuffer], len);
- }
- var arr = [];
- var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
- for (var i = 0; i < buf.length; i += intSize) {
- arr.push(fn.call(buf, i));
- }
- return arr;
- }
- function toBuffer(arr, size, bigEndian) {
- var buf = new Buffer(size);
- var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
- for (var i = 0; i < arr.length; i++) {
- fn.call(buf, arr[i], i * 4, true);
- }
- return buf;
- }
- function hash(buf, fn, hashSize, bigEndian) {
- if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
- var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
- return toBuffer(arr, hashSize, bigEndian);
- }
- exports.hash = hash;
- }).call(this,require("buffer").Buffer)
- },{"buffer":65}],9:[function(require,module,exports){
- 'use strict';
- /*
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
- * Digest Algorithm, as defined in RFC 1321.
- * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for more info.
- */
- var helpers = require('./helpers');
- /*
- * Calculate the MD5 of an array of little-endian words, and a bit length
- */
- function core_md5(x, len)
- {
- /* append padding */
- x[len >> 5] |= 0x80 << ((len) % 32);
- x[(((len + 64) >>> 9) << 4) + 14] = len;
- var a = 1732584193;
- var b = -271733879;
- var c = -1732584194;
- var d = 271733878;
- for(var i = 0; i < x.length; i += 16)
- {
- var olda = a;
- var oldb = b;
- var oldc = c;
- var oldd = d;
- a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
- d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
- c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
- b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
- a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
- d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
- c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
- b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
- a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
- d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
- c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
- b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
- a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
- d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
- c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
- b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
- a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
- d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
- c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
- b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
- a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
- d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
- c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
- b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
- a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
- d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
- c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
- b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
- a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
- d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
- c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
- b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
- a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
- d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
- c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
- b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
- a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
- d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
- c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
- b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
- a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
- d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
- c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
- b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
- a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
- d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
- c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
- b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
- a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
- d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
- c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
- b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
- a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
- d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
- c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
- b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
- a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
- d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
- c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
- b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
- a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
- d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
- c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
- b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
- a = safe_add(a, olda);
- b = safe_add(b, oldb);
- c = safe_add(c, oldc);
- d = safe_add(d, oldd);
- }
- return Array(a, b, c, d);
- }
- /*
- * These functions implement the four basic operations the algorithm uses.
- */
- function md5_cmn(q, a, b, x, s, t)
- {
- return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
- }
- function md5_ff(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
- }
- function md5_gg(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
- }
- function md5_hh(a, b, c, d, x, s, t)
- {
- return md5_cmn(b ^ c ^ d, a, b, x, s, t);
- }
- function md5_ii(a, b, c, d, x, s, t)
- {
- return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
- }
- /*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
- function safe_add(x, y)
- {
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
- }
- /*
- * Bitwise rotate a 32-bit number to the left.
- */
- function bit_rol(num, cnt)
- {
- return (num << cnt) | (num >>> (32 - cnt));
- }
- module.exports = function md5(buf) {
- return helpers.hash(buf, core_md5, 16);
- };
- },{"./helpers":8}],10:[function(require,module,exports){
- 'use strict';
- var elliptic = exports;
- elliptic.version = require('../package.json').version;
- elliptic.utils = require('./elliptic/utils');
- elliptic.rand = require('brorand');
- elliptic.curve = require('./elliptic/curve');
- elliptic.curves = require('./elliptic/curves');
- // Protocols
- elliptic.ec = require('./elliptic/ec');
- elliptic.eddsa = require('./elliptic/eddsa');
- },{"../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){
- 'use strict';
- var BN = require('bn.js');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var getNAF = utils.getNAF;
- var getJSF = utils.getJSF;
- var assert = utils.assert;
- function BaseCurve(type, conf) {
- this.type = type;
- this.p = new BN(conf.p, 16);
- // Use Montgomery, when there is no fast reduction for the prime
- this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
- // Useful for many curves
- this.zero = new BN(0).toRed(this.red);
- this.one = new BN(1).toRed(this.red);
- this.two = new BN(2).toRed(this.red);
- // Curve configuration, optional
- this.n = conf.n && new BN(conf.n, 16);
- this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
- // Temporary arrays
- this._wnafT1 = new Array(4);
- this._wnafT2 = new Array(4);
- this._wnafT3 = new Array(4);
- this._wnafT4 = new Array(4);
- // Generalized Greg Maxwell's trick
- var adjustCount = this.n && this.p.div(this.n);
- if (!adjustCount || adjustCount.cmpn(100) > 0) {
- this.redN = null;
- } else {
- this._maxwellTrick = true;
- this.redN = this.n.toRed(this.red);
- }
- }
- module.exports = BaseCurve;
- BaseCurve.prototype.point = function point() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype.validate = function validate() {
- throw new Error('Not implemented');
- };
- BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
- assert(p.precomputed);
- var doubles = p._getDoubles();
- var naf = getNAF(k, 1);
- var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
- I /= 3;
- // Translate into more windowed form
- var repr = [];
- for (var j = 0; j < naf.length; j += doubles.step) {
- var nafW = 0;
- for (var k = j + doubles.step - 1; k >= j; k--)
- nafW = (nafW << 1) + naf[k];
- repr.push(nafW);
- }
- var a = this.jpoint(null, null, null);
- var b = this.jpoint(null, null, null);
- for (var i = I; i > 0; i--) {
- for (var j = 0; j < repr.length; j++) {
- var nafW = repr[j];
- if (nafW === i)
- b = b.mixedAdd(doubles.points[j]);
- else if (nafW === -i)
- b = b.mixedAdd(doubles.points[j].neg());
- }
- a = a.add(b);
- }
- return a.toP();
- };
- BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
- var w = 4;
- // Precompute window
- var nafPoints = p._getNAFPoints(w);
- w = nafPoints.wnd;
- var wnd = nafPoints.points;
- // Get NAF form
- var naf = getNAF(k, w);
- // Add `this`*(N+1) for every w-NAF index
- var acc = this.jpoint(null, null, null);
- for (var i = naf.length - 1; i >= 0; i--) {
- // Count zeroes
- for (var k = 0; i >= 0 && naf[i] === 0; i--)
- k++;
- if (i >= 0)
- k++;
- acc = acc.dblp(k);
- if (i < 0)
- break;
- var z = naf[i];
- assert(z !== 0);
- if (p.type === 'affine') {
- // J +- P
- if (z > 0)
- acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
- else
- acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
- } else {
- // J +- J
- if (z > 0)
- acc = acc.add(wnd[(z - 1) >> 1]);
- else
- acc = acc.add(wnd[(-z - 1) >> 1].neg());
- }
- }
- return p.type === 'affine' ? acc.toP() : acc;
- };
- BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
- points,
- coeffs,
- len,
- jacobianResult) {
- var wndWidth = this._wnafT1;
- var wnd = this._wnafT2;
- var naf = this._wnafT3;
- // Fill all arrays
- var max = 0;
- for (var i = 0; i < len; i++) {
- var p = points[i];
- var nafPoints = p._getNAFPoints(defW);
- wndWidth[i] = nafPoints.wnd;
- wnd[i] = nafPoints.points;
- }
- // Comb small window NAFs
- for (var i = len - 1; i >= 1; i -= 2) {
- var a = i - 1;
- var b = i;
- if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
- naf[a] = getNAF(coeffs[a], wndWidth[a]);
- naf[b] = getNAF(coeffs[b], wndWidth[b]);
- max = Math.max(naf[a].length, max);
- max = Math.max(naf[b].length, max);
- continue;
- }
- var comb = [
- points[a], /* 1 */
- null, /* 3 */
- null, /* 5 */
- points[b] /* 7 */
- ];
- // Try to avoid Projective points, if possible
- if (points[a].y.cmp(points[b].y) === 0) {
- comb[1] = points[a].add(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].add(points[b].neg());
- } else {
- comb[1] = points[a].toJ().mixedAdd(points[b]);
- comb[2] = points[a].toJ().mixedAdd(points[b].neg());
- }
- var index = [
- -3, /* -1 -1 */
- -1, /* -1 0 */
- -5, /* -1 1 */
- -7, /* 0 -1 */
- 0, /* 0 0 */
- 7, /* 0 1 */
- 5, /* 1 -1 */
- 1, /* 1 0 */
- 3 /* 1 1 */
- ];
- var jsf = getJSF(coeffs[a], coeffs[b]);
- max = Math.max(jsf[0].length, max);
- naf[a] = new Array(max);
- naf[b] = new Array(max);
- for (var j = 0; j < max; j++) {
- var ja = jsf[0][j] | 0;
- var jb = jsf[1][j] | 0;
- naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
- naf[b][j] = 0;
- wnd[a] = comb;
- }
- }
- var acc = this.jpoint(null, null, null);
- var tmp = this._wnafT4;
- for (var i = max; i >= 0; i--) {
- var k = 0;
- while (i >= 0) {
- var zero = true;
- for (var j = 0; j < len; j++) {
- tmp[j] = naf[j][i] | 0;
- if (tmp[j] !== 0)
- zero = false;
- }
- if (!zero)
- break;
- k++;
- i--;
- }
- if (i >= 0)
- k++;
- acc = acc.dblp(k);
- if (i < 0)
- break;
- for (var j = 0; j < len; j++) {
- var z = tmp[j];
- var p;
- if (z === 0)
- continue;
- else if (z > 0)
- p = wnd[j][(z - 1) >> 1];
- else if (z < 0)
- p = wnd[j][(-z - 1) >> 1].neg();
- if (p.type === 'affine')
- acc = acc.mixedAdd(p);
- else
- acc = acc.add(p);
- }
- }
- // Zeroify references
- for (var i = 0; i < len; i++)
- wnd[i] = null;
- if (jacobianResult)
- return acc;
- else
- return acc.toP();
- };
- function BasePoint(curve, type) {
- this.curve = curve;
- this.type = type;
- this.precomputed = null;
- }
- BaseCurve.BasePoint = BasePoint;
- BasePoint.prototype.eq = function eq(/*other*/) {
- throw new Error('Not implemented');
- };
- BasePoint.prototype.validate = function validate() {
- return this.curve.validate(this);
- };
- BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- bytes = utils.toArray(bytes, enc);
- var len = this.p.byteLength();
- // uncompressed, hybrid-odd, hybrid-even
- if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
- bytes.length - 1 === 2 * len) {
- if (bytes[0] === 0x06)
- assert(bytes[bytes.length - 1] % 2 === 0);
- else if (bytes[0] === 0x07)
- assert(bytes[bytes.length - 1] % 2 === 1);
- var res = this.point(bytes.slice(1, 1 + len),
- bytes.slice(1 + len, 1 + 2 * len));
- return res;
- } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
- bytes.length - 1 === len) {
- return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
- }
- throw new Error('Unknown point format');
- };
- BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
- return this.encode(enc, true);
- };
- BasePoint.prototype._encode = function _encode(compact) {
- var len = this.curve.p.byteLength();
- var x = this.getX().toArray('be', len);
- if (compact)
- return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
- return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
- };
- BasePoint.prototype.encode = function encode(enc, compact) {
- return utils.encode(this._encode(compact), enc);
- };
- BasePoint.prototype.precompute = function precompute(power) {
- if (this.precomputed)
- return this;
- var precomputed = {
- doubles: null,
- naf: null,
- beta: null
- };
- precomputed.naf = this._getNAFPoints(8);
- precomputed.doubles = this._getDoubles(4, power);
- precomputed.beta = this._getBeta();
- this.precomputed = precomputed;
- return this;
- };
- BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
- if (!this.precomputed)
- return false;
- var doubles = this.precomputed.doubles;
- if (!doubles)
- return false;
- return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
- };
- BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
- if (this.precomputed && this.precomputed.doubles)
- return this.precomputed.doubles;
- var doubles = [ this ];
- var acc = this;
- for (var i = 0; i < power; i += step) {
- for (var j = 0; j < step; j++)
- acc = acc.dbl();
- doubles.push(acc);
- }
- return {
- step: step,
- points: doubles
- };
- };
- BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
- if (this.precomputed && this.precomputed.naf)
- return this.precomputed.naf;
- var res = [ this ];
- var max = (1 << wnd) - 1;
- var dbl = max === 1 ? null : this.dbl();
- for (var i = 1; i < max; i++)
- res[i] = res[i - 1].add(dbl);
- return {
- wnd: wnd,
- points: res
- };
- };
- BasePoint.prototype._getBeta = function _getBeta() {
- return null;
- };
- BasePoint.prototype.dblp = function dblp(k) {
- var r = this;
- for (var i = 0; i < k; i++)
- r = r.dbl();
- return r;
- };
- },{"../../elliptic":10,"bn.js":4}],12:[function(require,module,exports){
- 'use strict';
- var curve = require('../curve');
- var elliptic = require('../../elliptic');
- var BN = require('bn.js');
- var inherits = require('inherits');
- var Base = curve.base;
- var assert = elliptic.utils.assert;
- function EdwardsCurve(conf) {
- // NOTE: Important as we are creating point in Base.call()
- this.twisted = (conf.a | 0) !== 1;
- this.mOneA = this.twisted && (conf.a | 0) === -1;
- this.extended = this.mOneA;
- Base.call(this, 'edwards', conf);
- this.a = new BN(conf.a, 16).umod(this.red.m);
- this.a = this.a.toRed(this.red);
- this.c = new BN(conf.c, 16).toRed(this.red);
- this.c2 = this.c.redSqr();
- this.d = new BN(conf.d, 16).toRed(this.red);
- this.dd = this.d.redAdd(this.d);
- assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
- this.oneC = (conf.c | 0) === 1;
- }
- inherits(EdwardsCurve, Base);
- module.exports = EdwardsCurve;
- EdwardsCurve.prototype._mulA = function _mulA(num) {
- if (this.mOneA)
- return num.redNeg();
- else
- return this.a.redMul(num);
- };
- EdwardsCurve.prototype._mulC = function _mulC(num) {
- if (this.oneC)
- return num;
- else
- return this.c.redMul(num);
- };
- // Just for compatibility with Short curve
- EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
- return this.point(x, y, z, t);
- };
- EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var x2 = x.redSqr();
- var rhs = this.c2.redSub(this.a.redMul(x2));
- var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
- var y2 = rhs.redMul(lhs.redInvm());
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
- y = new BN(y, 16);
- if (!y.red)
- y = y.toRed(this.red);
- // x^2 = (y^2 - 1) / (d y^2 + 1)
- var y2 = y.redSqr();
- var lhs = y2.redSub(this.one);
- var rhs = y2.redMul(this.d).redAdd(this.one);
- var x2 = lhs.redMul(rhs.redInvm());
- if (x2.cmp(this.zero) === 0) {
- if (odd)
- throw new Error('invalid point');
- else
- return this.point(this.zero, y);
- }
- var x = x2.redSqrt();
- if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- if (x.isOdd() !== odd)
- x = x.redNeg();
- return this.point(x, y);
- };
- EdwardsCurve.prototype.validate = function validate(point) {
- if (point.isInfinity())
- return true;
- // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
- point.normalize();
- var x2 = point.x.redSqr();
- var y2 = point.y.redSqr();
- var lhs = x2.redMul(this.a).redAdd(y2);
- var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
- return lhs.cmp(rhs) === 0;
- };
- function Point(curve, x, y, z, t) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && y === null && z === null) {
- this.x = this.curve.zero;
- this.y = this.curve.one;
- this.z = this.curve.one;
- this.t = this.curve.zero;
- this.zOne = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = z ? new BN(z, 16) : this.curve.one;
- this.t = t && new BN(t, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- if (this.t && !this.t.red)
- this.t = this.t.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- // Use extended coordinates
- if (this.curve.extended && !this.t) {
- this.t = this.x.redMul(this.y);
- if (!this.zOne)
- this.t = this.t.redMul(this.z.redInvm());
- }
- }
- }
- inherits(Point, Base.BasePoint);
- EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- EdwardsCurve.prototype.point = function point(x, y, z, t) {
- return new Point(this, x, y, z, t);
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1], obj[2]);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.x.cmpn(0) === 0 &&
- this.y.cmp(this.z) === 0;
- };
- Point.prototype._extDbl = function _extDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #doubling-dbl-2008-hwcd
- // 4M + 4S
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = 2 * Z1^2
- var c = this.z.redSqr();
- c = c.redIAdd(c);
- // D = a * A
- var d = this.curve._mulA(a);
- // E = (X1 + Y1)^2 - A - B
- var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
- // G = D + B
- var g = d.redAdd(b);
- // F = G - C
- var f = g.redSub(c);
- // H = D - B
- var h = d.redSub(b);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projDbl = function _projDbl() {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #doubling-dbl-2008-bbjlp
- // #doubling-dbl-2007-bl
- // and others
- // Generally 3M + 4S or 2M + 4S
- // B = (X1 + Y1)^2
- var b = this.x.redAdd(this.y).redSqr();
- // C = X1^2
- var c = this.x.redSqr();
- // D = Y1^2
- var d = this.y.redSqr();
- var nx;
- var ny;
- var nz;
- if (this.curve.twisted) {
- // E = a * C
- var e = this.curve._mulA(c);
- // F = E + D
- var f = e.redAdd(d);
- if (this.zOne) {
- // X3 = (B - C - D) * (F - 2)
- nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F^2 - 2 * F
- nz = f.redSqr().redSub(f).redSub(f);
- } else {
- // H = Z1^2
- var h = this.z.redSqr();
- // J = F - 2 * H
- var j = f.redSub(h).redISub(h);
- // X3 = (B-C-D)*J
- nx = b.redSub(c).redISub(d).redMul(j);
- // Y3 = F * (E - D)
- ny = f.redMul(e.redSub(d));
- // Z3 = F * J
- nz = f.redMul(j);
- }
- } else {
- // E = C + D
- var e = c.redAdd(d);
- // H = (c * Z1)^2
- var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
- // J = E - 2 * H
- var j = e.redSub(h).redSub(h);
- // X3 = c * (B - E) * J
- nx = this.curve._mulC(b.redISub(e)).redMul(j);
- // Y3 = c * E * (C - D)
- ny = this.curve._mulC(e).redMul(c.redISub(d));
- // Z3 = E * J
- nz = e.redMul(j);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- // Double in extended coordinates
- if (this.curve.extended)
- return this._extDbl();
- else
- return this._projDbl();
- };
- Point.prototype._extAdd = function _extAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
- // #addition-add-2008-hwcd-3
- // 8M
- // A = (Y1 - X1) * (Y2 - X2)
- var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
- // B = (Y1 + X1) * (Y2 + X2)
- var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
- // C = T1 * k * T2
- var c = this.t.redMul(this.curve.dd).redMul(p.t);
- // D = Z1 * 2 * Z2
- var d = this.z.redMul(p.z.redAdd(p.z));
- // E = B - A
- var e = b.redSub(a);
- // F = D - C
- var f = d.redSub(c);
- // G = D + C
- var g = d.redAdd(c);
- // H = B + A
- var h = b.redAdd(a);
- // X3 = E * F
- var nx = e.redMul(f);
- // Y3 = G * H
- var ny = g.redMul(h);
- // T3 = E * H
- var nt = e.redMul(h);
- // Z3 = F * G
- var nz = f.redMul(g);
- return this.curve.point(nx, ny, nz, nt);
- };
- Point.prototype._projAdd = function _projAdd(p) {
- // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
- // #addition-add-2008-bbjlp
- // #addition-add-2007-bl
- // 10M + 1S
- // A = Z1 * Z2
- var a = this.z.redMul(p.z);
- // B = A^2
- var b = a.redSqr();
- // C = X1 * X2
- var c = this.x.redMul(p.x);
- // D = Y1 * Y2
- var d = this.y.redMul(p.y);
- // E = d * C * D
- var e = this.curve.d.redMul(c).redMul(d);
- // F = B - E
- var f = b.redSub(e);
- // G = B + E
- var g = b.redAdd(e);
- // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
- var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
- var nx = a.redMul(f).redMul(tmp);
- var ny;
- var nz;
- if (this.curve.twisted) {
- // Y3 = A * G * (D - a * C)
- ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
- // Z3 = F * G
- nz = f.redMul(g);
- } else {
- // Y3 = A * G * (D - C)
- ny = a.redMul(g).redMul(d.redSub(c));
- // Z3 = c * F * G
- nz = this.curve._mulC(f).redMul(g);
- }
- return this.curve.point(nx, ny, nz);
- };
- Point.prototype.add = function add(p) {
- if (this.isInfinity())
- return p;
- if (p.isInfinity())
- return this;
- if (this.curve.extended)
- return this._extAdd(p);
- else
- return this._projAdd(p);
- };
- Point.prototype.mul = function mul(k) {
- if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
- return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
- };
- Point.prototype.normalize = function normalize() {
- if (this.zOne)
- return this;
- // Normalize coordinates
- var zi = this.z.redInvm();
- this.x = this.x.redMul(zi);
- this.y = this.y.redMul(zi);
- if (this.t)
- this.t = this.t.redMul(zi);
- this.z = this.curve.one;
- this.zOne = true;
- return this;
- };
- Point.prototype.neg = function neg() {
- return this.curve.point(this.x.redNeg(),
- this.y,
- this.z,
- this.t && this.t.redNeg());
- };
- Point.prototype.getX = function getX() {
- this.normalize();
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- this.normalize();
- return this.y.fromRed();
- };
- Point.prototype.eq = function eq(other) {
- return this === other ||
- this.getX().cmp(other.getX()) === 0 &&
- this.getY().cmp(other.getY()) === 0;
- };
- Point.prototype.eqXToP = function eqXToP(x) {
- var rx = x.toRed(this.curve.red).redMul(this.z);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(this.z);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- return false;
- };
- // Compatibility with BaseCurve
- Point.prototype.toP = Point.prototype.normalize;
- Point.prototype.mixedAdd = Point.prototype.add;
- },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],13:[function(require,module,exports){
- 'use strict';
- var curve = exports;
- curve.base = require('./base');
- curve.short = require('./short');
- curve.mont = require('./mont');
- curve.edwards = require('./edwards');
- },{"./base":11,"./edwards":12,"./mont":14,"./short":15}],14:[function(require,module,exports){
- 'use strict';
- var curve = require('../curve');
- var BN = require('bn.js');
- var inherits = require('inherits');
- var Base = curve.base;
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- function MontCurve(conf) {
- Base.call(this, 'mont', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.i4 = new BN(4).toRed(this.red).redInvm();
- this.two = new BN(2).toRed(this.red);
- this.a24 = this.i4.redMul(this.a.redAdd(this.two));
- }
- inherits(MontCurve, Base);
- module.exports = MontCurve;
- MontCurve.prototype.validate = function validate(point) {
- var x = point.normalize().x;
- var x2 = x.redSqr();
- var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
- var y = rhs.redSqrt();
- return y.redSqr().cmp(rhs) === 0;
- };
- function Point(curve, x, z) {
- Base.BasePoint.call(this, curve, 'projective');
- if (x === null && z === null) {
- this.x = this.curve.one;
- this.z = this.curve.zero;
- } else {
- this.x = new BN(x, 16);
- this.z = new BN(z, 16);
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- }
- }
- inherits(Point, Base.BasePoint);
- MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
- return this.point(utils.toArray(bytes, enc), 1);
- };
- MontCurve.prototype.point = function point(x, z) {
- return new Point(this, x, z);
- };
- MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
- return Point.fromJSON(this, obj);
- };
- Point.prototype.precompute = function precompute() {
- // No-op
- };
- Point.prototype._encode = function _encode() {
- return this.getX().toArray('be', this.curve.p.byteLength());
- };
- Point.fromJSON = function fromJSON(curve, obj) {
- return new Point(curve, obj[0], obj[1] || curve.one);
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' z: ' + this.z.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- Point.prototype.dbl = function dbl() {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
- // 2M + 2S + 4A
- // A = X1 + Z1
- var a = this.x.redAdd(this.z);
- // AA = A^2
- var aa = a.redSqr();
- // B = X1 - Z1
- var b = this.x.redSub(this.z);
- // BB = B^2
- var bb = b.redSqr();
- // C = AA - BB
- var c = aa.redSub(bb);
- // X3 = AA * BB
- var nx = aa.redMul(bb);
- // Z3 = C * (BB + A24 * C)
- var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
- return this.curve.point(nx, nz);
- };
- Point.prototype.add = function add() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.diffAdd = function diffAdd(p, diff) {
- // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
- // 4M + 2S + 6A
- // A = X2 + Z2
- var a = this.x.redAdd(this.z);
- // B = X2 - Z2
- var b = this.x.redSub(this.z);
- // C = X3 + Z3
- var c = p.x.redAdd(p.z);
- // D = X3 - Z3
- var d = p.x.redSub(p.z);
- // DA = D * A
- var da = d.redMul(a);
- // CB = C * B
- var cb = c.redMul(b);
- // X5 = Z1 * (DA + CB)^2
- var nx = diff.z.redMul(da.redAdd(cb).redSqr());
- // Z5 = X1 * (DA - CB)^2
- var nz = diff.x.redMul(da.redISub(cb).redSqr());
- return this.curve.point(nx, nz);
- };
- Point.prototype.mul = function mul(k) {
- var t = k.clone();
- var a = this; // (N / 2) * Q + Q
- var b = this.curve.point(null, null); // (N / 2) * Q
- var c = this; // Q
- for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
- bits.push(t.andln(1));
- for (var i = bits.length - 1; i >= 0; i--) {
- if (bits[i] === 0) {
- // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
- a = a.diffAdd(b, c);
- // N * Q = 2 * ((N / 2) * Q + Q))
- b = b.dbl();
- } else {
- // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
- b = a.diffAdd(b, c);
- // N * Q + Q = 2 * ((N / 2) * Q + Q)
- a = a.dbl();
- }
- }
- return b;
- };
- Point.prototype.mulAdd = function mulAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.jumlAdd = function jumlAdd() {
- throw new Error('Not supported on Montgomery curve');
- };
- Point.prototype.eq = function eq(other) {
- return this.getX().cmp(other.getX()) === 0;
- };
- Point.prototype.normalize = function normalize() {
- this.x = this.x.redMul(this.z.redInvm());
- this.z = this.curve.one;
- return this;
- };
- Point.prototype.getX = function getX() {
- // Normalize coordinates
- this.normalize();
- return this.x.fromRed();
- };
- },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],15:[function(require,module,exports){
- 'use strict';
- var curve = require('../curve');
- var elliptic = require('../../elliptic');
- var BN = require('bn.js');
- var inherits = require('inherits');
- var Base = curve.base;
- var assert = elliptic.utils.assert;
- function ShortCurve(conf) {
- Base.call(this, 'short', conf);
- this.a = new BN(conf.a, 16).toRed(this.red);
- this.b = new BN(conf.b, 16).toRed(this.red);
- this.tinv = this.two.redInvm();
- this.zeroA = this.a.fromRed().cmpn(0) === 0;
- this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
- // If the curve is endomorphic, precalculate beta and lambda
- this.endo = this._getEndomorphism(conf);
- this._endoWnafT1 = new Array(4);
- this._endoWnafT2 = new Array(4);
- }
- inherits(ShortCurve, Base);
- module.exports = ShortCurve;
- ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
- // No efficient endomorphism
- if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
- return;
- // Compute beta and lambda, that lambda * P = (beta * Px; Py)
- var beta;
- var lambda;
- if (conf.beta) {
- beta = new BN(conf.beta, 16).toRed(this.red);
- } else {
- var betas = this._getEndoRoots(this.p);
- // Choose the smallest beta
- beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
- beta = beta.toRed(this.red);
- }
- if (conf.lambda) {
- lambda = new BN(conf.lambda, 16);
- } else {
- // Choose the lambda that is matching selected beta
- var lambdas = this._getEndoRoots(this.n);
- if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
- lambda = lambdas[0];
- } else {
- lambda = lambdas[1];
- assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
- }
- }
- // Get basis vectors, used for balanced length-two representation
- var basis;
- if (conf.basis) {
- basis = conf.basis.map(function(vec) {
- return {
- a: new BN(vec.a, 16),
- b: new BN(vec.b, 16)
- };
- });
- } else {
- basis = this._getEndoBasis(lambda);
- }
- return {
- beta: beta,
- lambda: lambda,
- basis: basis
- };
- };
- ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
- // Find roots of for x^2 + x + 1 in F
- // Root = (-1 +- Sqrt(-3)) / 2
- //
- var red = num === this.p ? this.red : BN.mont(num);
- var tinv = new BN(2).toRed(red).redInvm();
- var ntinv = tinv.redNeg();
- var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
- var l1 = ntinv.redAdd(s).fromRed();
- var l2 = ntinv.redSub(s).fromRed();
- return [ l1, l2 ];
- };
- ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
- // aprxSqrt >= sqrt(this.n)
- var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
- // 3.74
- // Run EGCD, until r(L + 1) < aprxSqrt
- var u = lambda;
- var v = this.n.clone();
- var x1 = new BN(1);
- var y1 = new BN(0);
- var x2 = new BN(0);
- var y2 = new BN(1);
- // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
- var a0;
- var b0;
- // First vector
- var a1;
- var b1;
- // Second vector
- var a2;
- var b2;
- var prevR;
- var i = 0;
- var r;
- var x;
- while (u.cmpn(0) !== 0) {
- var q = v.div(u);
- r = v.sub(q.mul(u));
- x = x2.sub(q.mul(x1));
- var y = y2.sub(q.mul(y1));
- if (!a1 && r.cmp(aprxSqrt) < 0) {
- a0 = prevR.neg();
- b0 = x1;
- a1 = r.neg();
- b1 = x;
- } else if (a1 && ++i === 2) {
- break;
- }
- prevR = r;
- v = u;
- u = r;
- x2 = x1;
- x1 = x;
- y2 = y1;
- y1 = y;
- }
- a2 = r.neg();
- b2 = x;
- var len1 = a1.sqr().add(b1.sqr());
- var len2 = a2.sqr().add(b2.sqr());
- if (len2.cmp(len1) >= 0) {
- a2 = a0;
- b2 = b0;
- }
- // Normalize signs
- if (a1.negative) {
- a1 = a1.neg();
- b1 = b1.neg();
- }
- if (a2.negative) {
- a2 = a2.neg();
- b2 = b2.neg();
- }
- return [
- { a: a1, b: b1 },
- { a: a2, b: b2 }
- ];
- };
- ShortCurve.prototype._endoSplit = function _endoSplit(k) {
- var basis = this.endo.basis;
- var v1 = basis[0];
- var v2 = basis[1];
- var c1 = v2.b.mul(k).divRound(this.n);
- var c2 = v1.b.neg().mul(k).divRound(this.n);
- var p1 = c1.mul(v1.a);
- var p2 = c2.mul(v2.a);
- var q1 = c1.mul(v1.b);
- var q2 = c2.mul(v2.b);
- // Calculate answer
- var k1 = k.sub(p1).sub(p2);
- var k2 = q1.add(q2).neg();
- return { k1: k1, k2: k2 };
- };
- ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
- x = new BN(x, 16);
- if (!x.red)
- x = x.toRed(this.red);
- var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
- var y = y2.redSqrt();
- if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
- throw new Error('invalid point');
- // XXX Is there any way to tell if the number is odd without converting it
- // to non-red form?
- var isOdd = y.fromRed().isOdd();
- if (odd && !isOdd || !odd && isOdd)
- y = y.redNeg();
- return this.point(x, y);
- };
- ShortCurve.prototype.validate = function validate(point) {
- if (point.inf)
- return true;
- var x = point.x;
- var y = point.y;
- var ax = this.a.redMul(x);
- var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
- return y.redSqr().redISub(rhs).cmpn(0) === 0;
- };
- ShortCurve.prototype._endoWnafMulAdd =
- function _endoWnafMulAdd(points, coeffs, jacobianResult) {
- var npoints = this._endoWnafT1;
- var ncoeffs = this._endoWnafT2;
- for (var i = 0; i < points.length; i++) {
- var split = this._endoSplit(coeffs[i]);
- var p = points[i];
- var beta = p._getBeta();
- if (split.k1.negative) {
- split.k1.ineg();
- p = p.neg(true);
- }
- if (split.k2.negative) {
- split.k2.ineg();
- beta = beta.neg(true);
- }
- npoints[i * 2] = p;
- npoints[i * 2 + 1] = beta;
- ncoeffs[i * 2] = split.k1;
- ncoeffs[i * 2 + 1] = split.k2;
- }
- var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
- // Clean-up references to points and coefficients
- for (var j = 0; j < i * 2; j++) {
- npoints[j] = null;
- ncoeffs[j] = null;
- }
- return res;
- };
- function Point(curve, x, y, isRed) {
- Base.BasePoint.call(this, curve, 'affine');
- if (x === null && y === null) {
- this.x = null;
- this.y = null;
- this.inf = true;
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- // Force redgomery representation when loading from JSON
- if (isRed) {
- this.x.forceRed(this.curve.red);
- this.y.forceRed(this.curve.red);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- this.inf = false;
- }
- }
- inherits(Point, Base.BasePoint);
- ShortCurve.prototype.point = function point(x, y, isRed) {
- return new Point(this, x, y, isRed);
- };
- ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
- return Point.fromJSON(this, obj, red);
- };
- Point.prototype._getBeta = function _getBeta() {
- if (!this.curve.endo)
- return;
- var pre = this.precomputed;
- if (pre && pre.beta)
- return pre.beta;
- var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
- if (pre) {
- var curve = this.curve;
- var endoMul = function(p) {
- return curve.point(p.x.redMul(curve.endo.beta), p.y);
- };
- pre.beta = beta;
- beta.precomputed = {
- beta: null,
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(endoMul)
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(endoMul)
- }
- };
- }
- return beta;
- };
- Point.prototype.toJSON = function toJSON() {
- if (!this.precomputed)
- return [ this.x, this.y ];
- return [ this.x, this.y, this.precomputed && {
- doubles: this.precomputed.doubles && {
- step: this.precomputed.doubles.step,
- points: this.precomputed.doubles.points.slice(1)
- },
- naf: this.precomputed.naf && {
- wnd: this.precomputed.naf.wnd,
- points: this.precomputed.naf.points.slice(1)
- }
- } ];
- };
- Point.fromJSON = function fromJSON(curve, obj, red) {
- if (typeof obj === 'string')
- obj = JSON.parse(obj);
- var res = curve.point(obj[0], obj[1], red);
- if (!obj[2])
- return res;
- function obj2point(obj) {
- return curve.point(obj[0], obj[1], red);
- }
- var pre = obj[2];
- res.precomputed = {
- beta: null,
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: [ res ].concat(pre.doubles.points.map(obj2point))
- },
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: [ res ].concat(pre.naf.points.map(obj2point))
- }
- };
- return res;
- };
- Point.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC Point Infinity>';
- return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
- ' y: ' + this.y.fromRed().toString(16, 2) + '>';
- };
- Point.prototype.isInfinity = function isInfinity() {
- return this.inf;
- };
- Point.prototype.add = function add(p) {
- // O + P = P
- if (this.inf)
- return p;
- // P + O = P
- if (p.inf)
- return this;
- // P + P = 2P
- if (this.eq(p))
- return this.dbl();
- // P + (-P) = O
- if (this.neg().eq(p))
- return this.curve.point(null, null);
- // P + Q = O
- if (this.x.cmp(p.x) === 0)
- return this.curve.point(null, null);
- var c = this.y.redSub(p.y);
- if (c.cmpn(0) !== 0)
- c = c.redMul(this.x.redSub(p.x).redInvm());
- var nx = c.redSqr().redISub(this.x).redISub(p.x);
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.dbl = function dbl() {
- if (this.inf)
- return this;
- // 2P = O
- var ys1 = this.y.redAdd(this.y);
- if (ys1.cmpn(0) === 0)
- return this.curve.point(null, null);
- var a = this.curve.a;
- var x2 = this.x.redSqr();
- var dyinv = ys1.redInvm();
- var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
- var nx = c.redSqr().redISub(this.x.redAdd(this.x));
- var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
- return this.curve.point(nx, ny);
- };
- Point.prototype.getX = function getX() {
- return this.x.fromRed();
- };
- Point.prototype.getY = function getY() {
- return this.y.fromRed();
- };
- Point.prototype.mul = function mul(k) {
- k = new BN(k, 16);
- if (this._hasDoubles(k))
- return this.curve._fixedNafMul(this, k);
- else if (this.curve.endo)
- return this.curve._endoWnafMulAdd([ this ], [ k ]);
- else
- return this.curve._wnafMul(this, k);
- };
- Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2);
- };
- Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
- var points = [ this, p2 ];
- var coeffs = [ k1, k2 ];
- if (this.curve.endo)
- return this.curve._endoWnafMulAdd(points, coeffs, true);
- else
- return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
- };
- Point.prototype.eq = function eq(p) {
- return this === p ||
- this.inf === p.inf &&
- (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
- };
- Point.prototype.neg = function neg(_precompute) {
- if (this.inf)
- return this;
- var res = this.curve.point(this.x, this.y.redNeg());
- if (_precompute && this.precomputed) {
- var pre = this.precomputed;
- var negate = function(p) {
- return p.neg();
- };
- res.precomputed = {
- naf: pre.naf && {
- wnd: pre.naf.wnd,
- points: pre.naf.points.map(negate)
- },
- doubles: pre.doubles && {
- step: pre.doubles.step,
- points: pre.doubles.points.map(negate)
- }
- };
- }
- return res;
- };
- Point.prototype.toJ = function toJ() {
- if (this.inf)
- return this.curve.jpoint(null, null, null);
- var res = this.curve.jpoint(this.x, this.y, this.curve.one);
- return res;
- };
- function JPoint(curve, x, y, z) {
- Base.BasePoint.call(this, curve, 'jacobian');
- if (x === null && y === null && z === null) {
- this.x = this.curve.one;
- this.y = this.curve.one;
- this.z = new BN(0);
- } else {
- this.x = new BN(x, 16);
- this.y = new BN(y, 16);
- this.z = new BN(z, 16);
- }
- if (!this.x.red)
- this.x = this.x.toRed(this.curve.red);
- if (!this.y.red)
- this.y = this.y.toRed(this.curve.red);
- if (!this.z.red)
- this.z = this.z.toRed(this.curve.red);
- this.zOne = this.z === this.curve.one;
- }
- inherits(JPoint, Base.BasePoint);
- ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
- return new JPoint(this, x, y, z);
- };
- JPoint.prototype.toP = function toP() {
- if (this.isInfinity())
- return this.curve.point(null, null);
- var zinv = this.z.redInvm();
- var zinv2 = zinv.redSqr();
- var ax = this.x.redMul(zinv2);
- var ay = this.y.redMul(zinv2).redMul(zinv);
- return this.curve.point(ax, ay);
- };
- JPoint.prototype.neg = function neg() {
- return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
- };
- JPoint.prototype.add = function add(p) {
- // O + P = P
- if (this.isInfinity())
- return p;
- // P + O = P
- if (p.isInfinity())
- return this;
- // 12M + 4S + 7A
- var pz2 = p.z.redSqr();
- var z2 = this.z.redSqr();
- var u1 = this.x.redMul(pz2);
- var u2 = p.x.redMul(z2);
- var s1 = this.y.redMul(pz2.redMul(p.z));
- var s2 = p.y.redMul(z2.redMul(this.z));
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(p.z).redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mixedAdd = function mixedAdd(p) {
- // O + P = P
- if (this.isInfinity())
- return p.toJ();
- // P + O = P
- if (p.isInfinity())
- return this;
- // 8M + 3S + 7A
- var z2 = this.z.redSqr();
- var u1 = this.x;
- var u2 = p.x.redMul(z2);
- var s1 = this.y;
- var s2 = p.y.redMul(z2).redMul(this.z);
- var h = u1.redSub(u2);
- var r = s1.redSub(s2);
- if (h.cmpn(0) === 0) {
- if (r.cmpn(0) !== 0)
- return this.curve.jpoint(null, null, null);
- else
- return this.dbl();
- }
- var h2 = h.redSqr();
- var h3 = h2.redMul(h);
- var v = u1.redMul(h2);
- var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
- var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
- var nz = this.z.redMul(h);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.dblp = function dblp(pow) {
- if (pow === 0)
- return this;
- if (this.isInfinity())
- return this;
- if (!pow)
- return this.dbl();
- if (this.curve.zeroA || this.curve.threeA) {
- var r = this;
- for (var i = 0; i < pow; i++)
- r = r.dbl();
- return r;
- }
- // 1M + 2S + 1A + N * (4S + 5M + 8A)
- // N = 1 => 6M + 6S + 9A
- var a = this.curve.a;
- var tinv = this.curve.tinv;
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- // Reuse results
- var jyd = jy.redAdd(jy);
- for (var i = 0; i < pow; i++) {
- var jx2 = jx.redSqr();
- var jyd2 = jyd.redSqr();
- var jyd4 = jyd2.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var t1 = jx.redMul(jyd2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var dny = c.redMul(t2);
- dny = dny.redIAdd(dny).redISub(jyd4);
- var nz = jyd.redMul(jz);
- if (i + 1 < pow)
- jz4 = jz4.redMul(jyd4);
- jx = nx;
- jz = nz;
- jyd = dny;
- }
- return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
- };
- JPoint.prototype.dbl = function dbl() {
- if (this.isInfinity())
- return this;
- if (this.curve.zeroA)
- return this._zeroDbl();
- else if (this.curve.threeA)
- return this._threeDbl();
- else
- return this._dbl();
- };
- JPoint.prototype._zeroDbl = function _zeroDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 14A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // T = M ^ 2 - 2*S
- var t = m.redSqr().redISub(s).redISub(s);
- // 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2*Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
- // #doubling-dbl-2009-l
- // 2M + 5S + 13A
- // A = X1^2
- var a = this.x.redSqr();
- // B = Y1^2
- var b = this.y.redSqr();
- // C = B^2
- var c = b.redSqr();
- // D = 2 * ((X1 + B)^2 - A - C)
- var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
- d = d.redIAdd(d);
- // E = 3 * A
- var e = a.redAdd(a).redIAdd(a);
- // F = E^2
- var f = e.redSqr();
- // 8 * C
- var c8 = c.redIAdd(c);
- c8 = c8.redIAdd(c8);
- c8 = c8.redIAdd(c8);
- // X3 = F - 2 * D
- nx = f.redISub(d).redISub(d);
- // Y3 = E * (D - X3) - 8 * C
- ny = e.redMul(d.redISub(nx)).redISub(c8);
- // Z3 = 2 * Y1 * Z1
- nz = this.y.redMul(this.z);
- nz = nz.redIAdd(nz);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._threeDbl = function _threeDbl() {
- var nx;
- var ny;
- var nz;
- // Z = 1
- if (this.zOne) {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
- // #doubling-mdbl-2007-bl
- // 1M + 5S + 15A
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // S = 2 * ((X1 + YY)^2 - XX - YYYY)
- var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- s = s.redIAdd(s);
- // M = 3 * XX + a
- var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
- // T = M^2 - 2 * S
- var t = m.redSqr().redISub(s).redISub(s);
- // X3 = T
- nx = t;
- // Y3 = M * (S - T) - 8 * YYYY
- var yyyy8 = yyyy.redIAdd(yyyy);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- yyyy8 = yyyy8.redIAdd(yyyy8);
- ny = m.redMul(s.redISub(t)).redISub(yyyy8);
- // Z3 = 2 * Y1
- nz = this.y.redAdd(this.y);
- } else {
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
- // 3M + 5S
- // delta = Z1^2
- var delta = this.z.redSqr();
- // gamma = Y1^2
- var gamma = this.y.redSqr();
- // beta = X1 * gamma
- var beta = this.x.redMul(gamma);
- // alpha = 3 * (X1 - delta) * (X1 + delta)
- var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
- alpha = alpha.redAdd(alpha).redIAdd(alpha);
- // X3 = alpha^2 - 8 * beta
- var beta4 = beta.redIAdd(beta);
- beta4 = beta4.redIAdd(beta4);
- var beta8 = beta4.redAdd(beta4);
- nx = alpha.redSqr().redISub(beta8);
- // Z3 = (Y1 + Z1)^2 - gamma - delta
- nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
- // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
- var ggamma8 = gamma.redSqr();
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ggamma8 = ggamma8.redIAdd(ggamma8);
- ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
- }
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype._dbl = function _dbl() {
- var a = this.curve.a;
- // 4M + 6S + 10A
- var jx = this.x;
- var jy = this.y;
- var jz = this.z;
- var jz4 = jz.redSqr().redSqr();
- var jx2 = jx.redSqr();
- var jy2 = jy.redSqr();
- var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
- var jxd4 = jx.redAdd(jx);
- jxd4 = jxd4.redIAdd(jxd4);
- var t1 = jxd4.redMul(jy2);
- var nx = c.redSqr().redISub(t1.redAdd(t1));
- var t2 = t1.redISub(nx);
- var jyd8 = jy2.redSqr();
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- jyd8 = jyd8.redIAdd(jyd8);
- var ny = c.redMul(t2).redISub(jyd8);
- var nz = jy.redAdd(jy).redMul(jz);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.trpl = function trpl() {
- if (!this.curve.zeroA)
- return this.dbl().add(this);
- // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
- // 5M + 10S + ...
- // XX = X1^2
- var xx = this.x.redSqr();
- // YY = Y1^2
- var yy = this.y.redSqr();
- // ZZ = Z1^2
- var zz = this.z.redSqr();
- // YYYY = YY^2
- var yyyy = yy.redSqr();
- // M = 3 * XX + a * ZZ2; a = 0
- var m = xx.redAdd(xx).redIAdd(xx);
- // MM = M^2
- var mm = m.redSqr();
- // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
- var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
- e = e.redIAdd(e);
- e = e.redAdd(e).redIAdd(e);
- e = e.redISub(mm);
- // EE = E^2
- var ee = e.redSqr();
- // T = 16*YYYY
- var t = yyyy.redIAdd(yyyy);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- t = t.redIAdd(t);
- // U = (M + E)^2 - MM - EE - T
- var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
- // X3 = 4 * (X1 * EE - 4 * YY * U)
- var yyu4 = yy.redMul(u);
- yyu4 = yyu4.redIAdd(yyu4);
- yyu4 = yyu4.redIAdd(yyu4);
- var nx = this.x.redMul(ee).redISub(yyu4);
- nx = nx.redIAdd(nx);
- nx = nx.redIAdd(nx);
- // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
- var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- ny = ny.redIAdd(ny);
- // Z3 = (Z1 + E)^2 - ZZ - EE
- var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
- return this.curve.jpoint(nx, ny, nz);
- };
- JPoint.prototype.mul = function mul(k, kbase) {
- k = new BN(k, kbase);
- return this.curve._wnafMul(this, k);
- };
- JPoint.prototype.eq = function eq(p) {
- if (p.type === 'affine')
- return this.eq(p.toJ());
- if (this === p)
- return true;
- // x1 * z2^2 == x2 * z1^2
- var z2 = this.z.redSqr();
- var pz2 = p.z.redSqr();
- if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
- return false;
- // y1 * z2^3 == y2 * z1^3
- var z3 = z2.redMul(this.z);
- var pz3 = pz2.redMul(p.z);
- return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
- };
- JPoint.prototype.eqXToP = function eqXToP(x) {
- var zs = this.z.redSqr();
- var rx = x.toRed(this.curve.red).redMul(zs);
- if (this.x.cmp(rx) === 0)
- return true;
- var xc = x.clone();
- var t = this.curve.redN.redMul(zs);
- for (;;) {
- xc.iadd(this.curve.n);
- if (xc.cmp(this.curve.p) >= 0)
- return false;
- rx.redIAdd(t);
- if (this.x.cmp(rx) === 0)
- return true;
- }
- return false;
- };
- JPoint.prototype.inspect = function inspect() {
- if (this.isInfinity())
- return '<EC JPoint Infinity>';
- return '<EC JPoint x: ' + this.x.toString(16, 2) +
- ' y: ' + this.y.toString(16, 2) +
- ' z: ' + this.z.toString(16, 2) + '>';
- };
- JPoint.prototype.isInfinity = function isInfinity() {
- // XXX This code assumes that zero is always zero in red
- return this.z.cmpn(0) === 0;
- };
- },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],16:[function(require,module,exports){
- 'use strict';
- var curves = exports;
- var hash = require('hash.js');
- var elliptic = require('../elliptic');
- var assert = elliptic.utils.assert;
- function PresetCurve(options) {
- if (options.type === 'short')
- this.curve = new elliptic.curve.short(options);
- else if (options.type === 'edwards')
- this.curve = new elliptic.curve.edwards(options);
- else
- this.curve = new elliptic.curve.mont(options);
- this.g = this.curve.g;
- this.n = this.curve.n;
- this.hash = options.hash;
- assert(this.g.validate(), 'Invalid curve');
- assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
- }
- curves.PresetCurve = PresetCurve;
- function defineCurve(name, options) {
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- get: function() {
- var curve = new PresetCurve(options);
- Object.defineProperty(curves, name, {
- configurable: true,
- enumerable: true,
- value: curve
- });
- return curve;
- }
- });
- }
- defineCurve('p192', {
- type: 'short',
- prime: 'p192',
- p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
- b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
- n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
- hash: hash.sha256,
- gRed: false,
- g: [
- '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
- '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
- ]
- });
- defineCurve('p224', {
- type: 'short',
- prime: 'p224',
- p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
- a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
- b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
- n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
- hash: hash.sha256,
- gRed: false,
- g: [
- 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
- 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
- ]
- });
- defineCurve('p256', {
- type: 'short',
- prime: null,
- p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
- a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
- b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
- n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
- hash: hash.sha256,
- gRed: false,
- g: [
- '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
- '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
- ]
- });
- defineCurve('p384', {
- type: 'short',
- prime: null,
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 ffffffff',
- a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'fffffffe ffffffff 00000000 00000000 fffffffc',
- b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
- '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
- n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
- 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
- hash: hash.sha384,
- gRed: false,
- g: [
- 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
- '5502f25d bf55296c 3a545e38 72760ab7',
- '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
- '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
- ]
- });
- defineCurve('p521', {
- type: 'short',
- prime: null,
- p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff',
- a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff ffffffff ffffffff fffffffc',
- b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
- '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
- '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
- n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
- 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
- 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
- hash: hash.sha512,
- gRed: false,
- g: [
- '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
- '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
- 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
- '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
- '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
- '3fad0761 353c7086 a272c240 88be9476 9fd16650'
- ]
- });
- defineCurve('curve25519', {
- type: 'mont',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '76d06',
- b: '1',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '9'
- ]
- });
- defineCurve('ed25519', {
- type: 'edwards',
- prime: 'p25519',
- p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
- a: '-1',
- c: '1',
- // -121665 * (121666^(-1)) (mod P)
- d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
- n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
- hash: hash.sha256,
- gRed: false,
- g: [
- '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
- // 4/5
- '6666666666666666666666666666666666666666666666666666666666666658'
- ]
- });
- var pre;
- try {
- pre = require('./precomputed/secp256k1');
- } catch (e) {
- pre = undefined;
- }
- defineCurve('secp256k1', {
- type: 'short',
- prime: 'k256',
- p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
- a: '0',
- b: '7',
- n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
- h: '1',
- hash: hash.sha256,
- // Precomputed endomorphism
- beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
- lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
- basis: [
- {
- a: '3086d221a7d46bcde86c90e49284eb15',
- b: '-e4437ed6010e88286f547fa90abfe4c3'
- },
- {
- a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
- b: '3086d221a7d46bcde86c90e49284eb15'
- }
- ],
- gRed: false,
- g: [
- '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
- '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
- pre
- ]
- });
- },{"../elliptic":10,"./precomputed/secp256k1":23,"hash.js":27}],17:[function(require,module,exports){
- 'use strict';
- var BN = require('bn.js');
- var HmacDRBG = require('hmac-drbg');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- var KeyPair = require('./key');
- var Signature = require('./signature');
- function EC(options) {
- if (!(this instanceof EC))
- return new EC(options);
- // Shortcut `elliptic.ec(curve-name)`
- if (typeof options === 'string') {
- assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
- options = elliptic.curves[options];
- }
- // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
- if (options instanceof elliptic.curves.PresetCurve)
- options = { curve: options };
- this.curve = options.curve.curve;
- this.n = this.curve.n;
- this.nh = this.n.ushrn(1);
- this.g = this.curve.g;
- // Point on curve
- this.g = options.curve.g;
- this.g.precompute(options.curve.n.bitLength() + 1);
- // Hash for function for DRBG
- this.hash = options.hash || options.curve.hash;
- }
- module.exports = EC;
- EC.prototype.keyPair = function keyPair(options) {
- return new KeyPair(this, options);
- };
- EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
- return KeyPair.fromPrivate(this, priv, enc);
- };
- EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
- return KeyPair.fromPublic(this, pub, enc);
- };
- EC.prototype.genKeyPair = function genKeyPair(options) {
- if (!options)
- options = {};
- // Instantiate Hmac_DRBG
- var drbg = new HmacDRBG({
- hash: this.hash,
- pers: options.pers,
- persEnc: options.persEnc || 'utf8',
- entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
- entropyEnc: options.entropy && options.entropyEnc || 'utf8',
- nonce: this.n.toArray()
- });
- var bytes = this.n.byteLength();
- var ns2 = this.n.sub(new BN(2));
- do {
- var priv = new BN(drbg.generate(bytes));
- if (priv.cmp(ns2) > 0)
- continue;
- priv.iaddn(1);
- return this.keyFromPrivate(priv);
- } while (true);
- };
- EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
- var delta = msg.byteLength() * 8 - this.n.bitLength();
- if (delta > 0)
- msg = msg.ushrn(delta);
- if (!truncOnly && msg.cmp(this.n) >= 0)
- return msg.sub(this.n);
- else
- return msg;
- };
- EC.prototype.sign = function sign(msg, key, enc, options) {
- if (typeof enc === 'object') {
- options = enc;
- enc = null;
- }
- if (!options)
- options = {};
- key = this.keyFromPrivate(key, enc);
- msg = this._truncateToN(new BN(msg, 16));
- // Zero-extend key to provide enough entropy
- var bytes = this.n.byteLength();
- var bkey = key.getPrivate().toArray('be', bytes);
- // Zero-extend nonce to have the same byte size as N
- var nonce = msg.toArray('be', bytes);
- // Instantiate Hmac_DRBG
- var drbg = new HmacDRBG({
- hash: this.hash,
- entropy: bkey,
- nonce: nonce,
- pers: options.pers,
- persEnc: options.persEnc || 'utf8'
- });
- // Number of bytes to generate
- var ns1 = this.n.sub(new BN(1));
- for (var iter = 0; true; iter++) {
- var k = options.k ?
- options.k(iter) :
- new BN(drbg.generate(this.n.byteLength()));
- k = this._truncateToN(k, true);
- if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
- continue;
- var kp = this.g.mul(k);
- if (kp.isInfinity())
- continue;
- var kpX = kp.getX();
- var r = kpX.umod(this.n);
- if (r.cmpn(0) === 0)
- continue;
- var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
- s = s.umod(this.n);
- if (s.cmpn(0) === 0)
- continue;
- var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
- (kpX.cmp(r) !== 0 ? 2 : 0);
- // Use complement of `s`, if it is > `n / 2`
- if (options.canonical && s.cmp(this.nh) > 0) {
- s = this.n.sub(s);
- recoveryParam ^= 1;
- }
- return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
- }
- };
- EC.prototype.verify = function verify(msg, signature, key, enc) {
- msg = this._truncateToN(new BN(msg, 16));
- key = this.keyFromPublic(key, enc);
- signature = new Signature(signature, 'hex');
- // Perform primitive values validation
- var r = signature.r;
- var s = signature.s;
- if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
- return false;
- if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
- return false;
- // Validate signature
- var sinv = s.invm(this.n);
- var u1 = sinv.mul(msg).umod(this.n);
- var u2 = sinv.mul(r).umod(this.n);
- if (!this.curve._maxwellTrick) {
- var p = this.g.mulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- return p.getX().umod(this.n).cmp(r) === 0;
- }
- // NOTE: Greg Maxwell's trick, inspired by:
- // https://git.io/vad3K
- var p = this.g.jmulAdd(u1, key.getPublic(), u2);
- if (p.isInfinity())
- return false;
- // Compare `p.x` of Jacobian point with `r`,
- // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
- // inverse of `p.z^2`
- return p.eqXToP(r);
- };
- EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
- assert((3 & j) === j, 'The recovery param is more than two bits');
- signature = new Signature(signature, enc);
- var n = this.n;
- var e = new BN(msg);
- var r = signature.r;
- var s = signature.s;
- // A set LSB signifies that the y-coordinate is odd
- var isYOdd = j & 1;
- var isSecondKey = j >> 1;
- if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
- throw new Error('Unable to find sencond key candinate');
- // 1.1. Let x = r + jn.
- if (isSecondKey)
- r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
- else
- r = this.curve.pointFromX(r, isYOdd);
- var rInv = signature.r.invm(n);
- var s1 = n.sub(e).mul(rInv).umod(n);
- var s2 = s.mul(rInv).umod(n);
- // 1.6.1 Compute Q = r^-1 (sR - eG)
- // Q = r^-1 (sR + -eG)
- return this.g.mulAdd(s1, r, s2);
- };
- EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
- signature = new Signature(signature, enc);
- if (signature.recoveryParam !== null)
- return signature.recoveryParam;
- for (var i = 0; i < 4; i++) {
- var Qprime;
- try {
- Qprime = this.recoverPubKey(e, signature, i);
- } catch (e) {
- continue;
- }
- if (Qprime.eq(Q))
- return i;
- }
- throw new Error('Unable to find valid recovery factor');
- };
- },{"../../elliptic":10,"./key":18,"./signature":19,"bn.js":4,"hmac-drbg":33}],18:[function(require,module,exports){
- 'use strict';
- var BN = require('bn.js');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- function KeyPair(ec, options) {
- this.ec = ec;
- this.priv = null;
- this.pub = null;
- // KeyPair(ec, { priv: ..., pub: ... })
- if (options.priv)
- this._importPrivate(options.priv, options.privEnc);
- if (options.pub)
- this._importPublic(options.pub, options.pubEnc);
- }
- module.exports = KeyPair;
- KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(ec, {
- pub: pub,
- pubEnc: enc
- });
- };
- KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
- if (priv instanceof KeyPair)
- return priv;
- return new KeyPair(ec, {
- priv: priv,
- privEnc: enc
- });
- };
- KeyPair.prototype.validate = function validate() {
- var pub = this.getPublic();
- if (pub.isInfinity())
- return { result: false, reason: 'Invalid public key' };
- if (!pub.validate())
- return { result: false, reason: 'Public key is not a point' };
- if (!pub.mul(this.ec.curve.n).isInfinity())
- return { result: false, reason: 'Public key * N != O' };
- return { result: true, reason: null };
- };
- KeyPair.prototype.getPublic = function getPublic(compact, enc) {
- // compact is optional argument
- if (typeof compact === 'string') {
- enc = compact;
- compact = null;
- }
- if (!this.pub)
- this.pub = this.ec.g.mul(this.priv);
- if (!enc)
- return this.pub;
- return this.pub.encode(enc, compact);
- };
- KeyPair.prototype.getPrivate = function getPrivate(enc) {
- if (enc === 'hex')
- return this.priv.toString(16, 2);
- else
- return this.priv;
- };
- KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
- this.priv = new BN(key, enc || 16);
- // Ensure that the priv won't be bigger than n, otherwise we may fail
- // in fixed multiplication method
- this.priv = this.priv.umod(this.ec.curve.n);
- };
- KeyPair.prototype._importPublic = function _importPublic(key, enc) {
- if (key.x || key.y) {
- // Montgomery points only have an `x` coordinate.
- // Weierstrass/Edwards points on the other hand have both `x` and
- // `y` coordinates.
- if (this.ec.curve.type === 'mont') {
- assert(key.x, 'Need x coordinate');
- } else if (this.ec.curve.type === 'short' ||
- this.ec.curve.type === 'edwards') {
- assert(key.x && key.y, 'Need both x and y coordinate');
- }
- this.pub = this.ec.curve.point(key.x, key.y);
- return;
- }
- this.pub = this.ec.curve.decodePoint(key, enc);
- };
- // ECDH
- KeyPair.prototype.derive = function derive(pub) {
- return pub.mul(this.priv).getX();
- };
- // ECDSA
- KeyPair.prototype.sign = function sign(msg, enc, options) {
- return this.ec.sign(msg, this, enc, options);
- };
- KeyPair.prototype.verify = function verify(msg, signature) {
- return this.ec.verify(msg, signature, this);
- };
- KeyPair.prototype.inspect = function inspect() {
- return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
- ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
- };
- },{"../../elliptic":10,"bn.js":4}],19:[function(require,module,exports){
- 'use strict';
- var BN = require('bn.js');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- function Signature(options, enc) {
- if (options instanceof Signature)
- return options;
- if (this._importDER(options, enc))
- return;
- assert(options.r && options.s, 'Signature without r or s');
- this.r = new BN(options.r, 16);
- this.s = new BN(options.s, 16);
- if (options.recoveryParam === undefined)
- this.recoveryParam = null;
- else
- this.recoveryParam = options.recoveryParam;
- }
- module.exports = Signature;
- function Position() {
- this.place = 0;
- }
- function getLength(buf, p) {
- var initial = buf[p.place++];
- if (!(initial & 0x80)) {
- return initial;
- }
- var octetLen = initial & 0xf;
- var val = 0;
- for (var i = 0, off = p.place; i < octetLen; i++, off++) {
- val <<= 8;
- val |= buf[off];
- }
- p.place = off;
- return val;
- }
- function rmPadding(buf) {
- var i = 0;
- var len = buf.length - 1;
- while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
- i++;
- }
- if (i === 0) {
- return buf;
- }
- return buf.slice(i);
- }
- Signature.prototype._importDER = function _importDER(data, enc) {
- data = utils.toArray(data, enc);
- var p = new Position();
- if (data[p.place++] !== 0x30) {
- return false;
- }
- var len = getLength(data, p);
- if ((len + p.place) !== data.length) {
- return false;
- }
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var rlen = getLength(data, p);
- var r = data.slice(p.place, rlen + p.place);
- p.place += rlen;
- if (data[p.place++] !== 0x02) {
- return false;
- }
- var slen = getLength(data, p);
- if (data.length !== slen + p.place) {
- return false;
- }
- var s = data.slice(p.place, slen + p.place);
- if (r[0] === 0 && (r[1] & 0x80)) {
- r = r.slice(1);
- }
- if (s[0] === 0 && (s[1] & 0x80)) {
- s = s.slice(1);
- }
- this.r = new BN(r);
- this.s = new BN(s);
- this.recoveryParam = null;
- return true;
- };
- function constructLength(arr, len) {
- if (len < 0x80) {
- arr.push(len);
- return;
- }
- var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
- arr.push(octets | 0x80);
- while (--octets) {
- arr.push((len >>> (octets << 3)) & 0xff);
- }
- arr.push(len);
- }
- Signature.prototype.toDER = function toDER(enc) {
- var r = this.r.toArray();
- var s = this.s.toArray();
- // Pad values
- if (r[0] & 0x80)
- r = [ 0 ].concat(r);
- // Pad values
- if (s[0] & 0x80)
- s = [ 0 ].concat(s);
- r = rmPadding(r);
- s = rmPadding(s);
- while (!s[0] && !(s[1] & 0x80)) {
- s = s.slice(1);
- }
- var arr = [ 0x02 ];
- constructLength(arr, r.length);
- arr = arr.concat(r);
- arr.push(0x02);
- constructLength(arr, s.length);
- var backHalf = arr.concat(s);
- var res = [ 0x30 ];
- constructLength(res, backHalf.length);
- res = res.concat(backHalf);
- return utils.encode(res, enc);
- };
- },{"../../elliptic":10,"bn.js":4}],20:[function(require,module,exports){
- 'use strict';
- var hash = require('hash.js');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var KeyPair = require('./key');
- var Signature = require('./signature');
- function EDDSA(curve) {
- assert(curve === 'ed25519', 'only tested with ed25519 so far');
- if (!(this instanceof EDDSA))
- return new EDDSA(curve);
- var curve = elliptic.curves[curve].curve;
- this.curve = curve;
- this.g = curve.g;
- this.g.precompute(curve.n.bitLength() + 1);
- this.pointClass = curve.point().constructor;
- this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
- this.hash = hash.sha512;
- }
- module.exports = EDDSA;
- /**
- * @param {Array|String} message - message bytes
- * @param {Array|String|KeyPair} secret - secret bytes or a keypair
- * @returns {Signature} - signature
- */
- EDDSA.prototype.sign = function sign(message, secret) {
- message = parseBytes(message);
- var key = this.keyFromSecret(secret);
- var r = this.hashInt(key.messagePrefix(), message);
- var R = this.g.mul(r);
- var Rencoded = this.encodePoint(R);
- var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
- .mul(key.priv());
- var S = r.add(s_).umod(this.curve.n);
- return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
- };
- /**
- * @param {Array} message - message bytes
- * @param {Array|String|Signature} sig - sig bytes
- * @param {Array|String|Point|KeyPair} pub - public key
- * @returns {Boolean} - true if public key matches sig of message
- */
- EDDSA.prototype.verify = function verify(message, sig, pub) {
- message = parseBytes(message);
- sig = this.makeSignature(sig);
- var key = this.keyFromPublic(pub);
- var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
- var SG = this.g.mul(sig.S());
- var RplusAh = sig.R().add(key.pub().mul(h));
- return RplusAh.eq(SG);
- };
- EDDSA.prototype.hashInt = function hashInt() {
- var hash = this.hash();
- for (var i = 0; i < arguments.length; i++)
- hash.update(arguments[i]);
- return utils.intFromLE(hash.digest()).umod(this.curve.n);
- };
- EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
- return KeyPair.fromPublic(this, pub);
- };
- EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
- return KeyPair.fromSecret(this, secret);
- };
- EDDSA.prototype.makeSignature = function makeSignature(sig) {
- if (sig instanceof Signature)
- return sig;
- return new Signature(this, sig);
- };
- /**
- * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
- *
- * EDDSA defines methods for encoding and decoding points and integers. These are
- * helper convenience methods, that pass along to utility functions implied
- * parameters.
- *
- */
- EDDSA.prototype.encodePoint = function encodePoint(point) {
- var enc = point.getY().toArray('le', this.encodingLength);
- enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
- return enc;
- };
- EDDSA.prototype.decodePoint = function decodePoint(bytes) {
- bytes = utils.parseBytes(bytes);
- var lastIx = bytes.length - 1;
- var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
- var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
- var y = utils.intFromLE(normed);
- return this.curve.pointFromY(y, xIsOdd);
- };
- EDDSA.prototype.encodeInt = function encodeInt(num) {
- return num.toArray('le', this.encodingLength);
- };
- EDDSA.prototype.decodeInt = function decodeInt(bytes) {
- return utils.intFromLE(bytes);
- };
- EDDSA.prototype.isPoint = function isPoint(val) {
- return val instanceof this.pointClass;
- };
- },{"../../elliptic":10,"./key":21,"./signature":22,"hash.js":27}],21:[function(require,module,exports){
- 'use strict';
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- var parseBytes = utils.parseBytes;
- var cachedProperty = utils.cachedProperty;
- /**
- * @param {EDDSA} eddsa - instance
- * @param {Object} params - public/private key parameters
- *
- * @param {Array<Byte>} [params.secret] - secret seed bytes
- * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
- * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
- *
- */
- function KeyPair(eddsa, params) {
- this.eddsa = eddsa;
- this._secret = parseBytes(params.secret);
- if (eddsa.isPoint(params.pub))
- this._pub = params.pub;
- else
- this._pubBytes = parseBytes(params.pub);
- }
- KeyPair.fromPublic = function fromPublic(eddsa, pub) {
- if (pub instanceof KeyPair)
- return pub;
- return new KeyPair(eddsa, { pub: pub });
- };
- KeyPair.fromSecret = function fromSecret(eddsa, secret) {
- if (secret instanceof KeyPair)
- return secret;
- return new KeyPair(eddsa, { secret: secret });
- };
- KeyPair.prototype.secret = function secret() {
- return this._secret;
- };
- cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
- return this.eddsa.encodePoint(this.pub());
- });
- cachedProperty(KeyPair, 'pub', function pub() {
- if (this._pubBytes)
- return this.eddsa.decodePoint(this._pubBytes);
- return this.eddsa.g.mul(this.priv());
- });
- cachedProperty(KeyPair, 'privBytes', function privBytes() {
- var eddsa = this.eddsa;
- var hash = this.hash();
- var lastIx = eddsa.encodingLength - 1;
- var a = hash.slice(0, eddsa.encodingLength);
- a[0] &= 248;
- a[lastIx] &= 127;
- a[lastIx] |= 64;
- return a;
- });
- cachedProperty(KeyPair, 'priv', function priv() {
- return this.eddsa.decodeInt(this.privBytes());
- });
- cachedProperty(KeyPair, 'hash', function hash() {
- return this.eddsa.hash().update(this.secret()).digest();
- });
- cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
- return this.hash().slice(this.eddsa.encodingLength);
- });
- KeyPair.prototype.sign = function sign(message) {
- assert(this._secret, 'KeyPair can only verify');
- return this.eddsa.sign(message, this);
- };
- KeyPair.prototype.verify = function verify(message, sig) {
- return this.eddsa.verify(message, sig, this);
- };
- KeyPair.prototype.getSecret = function getSecret(enc) {
- assert(this._secret, 'KeyPair is public only');
- return utils.encode(this.secret(), enc);
- };
- KeyPair.prototype.getPublic = function getPublic(enc) {
- return utils.encode(this.pubBytes(), enc);
- };
- module.exports = KeyPair;
- },{"../../elliptic":10}],22:[function(require,module,exports){
- 'use strict';
- var BN = require('bn.js');
- var elliptic = require('../../elliptic');
- var utils = elliptic.utils;
- var assert = utils.assert;
- var cachedProperty = utils.cachedProperty;
- var parseBytes = utils.parseBytes;
- /**
- * @param {EDDSA} eddsa - eddsa instance
- * @param {Array<Bytes>|Object} sig -
- * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
- * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
- * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
- * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
- */
- function Signature(eddsa, sig) {
- this.eddsa = eddsa;
- if (typeof sig !== 'object')
- sig = parseBytes(sig);
- if (Array.isArray(sig)) {
- sig = {
- R: sig.slice(0, eddsa.encodingLength),
- S: sig.slice(eddsa.encodingLength)
- };
- }
- assert(sig.R && sig.S, 'Signature without R or S');
- if (eddsa.isPoint(sig.R))
- this._R = sig.R;
- if (sig.S instanceof BN)
- this._S = sig.S;
- this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
- this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
- }
- cachedProperty(Signature, 'S', function S() {
- return this.eddsa.decodeInt(this.Sencoded());
- });
- cachedProperty(Signature, 'R', function R() {
- return this.eddsa.decodePoint(this.Rencoded());
- });
- cachedProperty(Signature, 'Rencoded', function Rencoded() {
- return this.eddsa.encodePoint(this.R());
- });
- cachedProperty(Signature, 'Sencoded', function Sencoded() {
- return this.eddsa.encodeInt(this.S());
- });
- Signature.prototype.toBytes = function toBytes() {
- return this.Rencoded().concat(this.Sencoded());
- };
- Signature.prototype.toHex = function toHex() {
- return utils.encode(this.toBytes(), 'hex').toUpperCase();
- };
- module.exports = Signature;
- },{"../../elliptic":10,"bn.js":4}],23:[function(require,module,exports){
- module.exports = {
- doubles: {
- step: 4,
- points: [
- [
- 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
- 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
- ],
- [
- '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
- '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
- ],
- [
- '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
- 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
- ],
- [
- '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
- '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
- ],
- [
- '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
- '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
- ],
- [
- '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
- '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
- ],
- [
- 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
- '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
- ],
- [
- '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
- 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
- ],
- [
- 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
- '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
- ],
- [
- 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
- 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
- ],
- [
- 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
- '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
- ],
- [
- '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
- '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
- ],
- [
- '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
- '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
- ],
- [
- '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
- '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
- ],
- [
- '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
- '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
- ],
- [
- '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
- '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
- ],
- [
- '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
- '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
- ],
- [
- '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
- '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
- ],
- [
- '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
- 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
- ],
- [
- 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
- '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
- ],
- [
- 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
- '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
- ],
- [
- '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
- '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
- ],
- [
- '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
- '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
- ],
- [
- 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
- '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
- ],
- [
- '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
- 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
- ],
- [
- 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
- '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
- ],
- [
- 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
- 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
- ],
- [
- 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
- '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
- ],
- [
- 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
- 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
- ],
- [
- 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
- '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
- ],
- [
- '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
- 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
- ],
- [
- '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
- '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
- ],
- [
- 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
- '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
- ],
- [
- '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
- 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
- ],
- [
- 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
- '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
- ],
- [
- 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
- '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
- ],
- [
- 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
- 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
- ],
- [
- '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
- '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
- ],
- [
- '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
- '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
- ],
- [
- '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
- 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
- ],
- [
- '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
- '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
- ],
- [
- 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
- '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
- ],
- [
- '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
- '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
- ],
- [
- '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
- 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
- ],
- [
- '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
- '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
- ],
- [
- 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
- '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
- ],
- [
- '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
- 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
- ],
- [
- 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
- 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
- ],
- [
- 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
- '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
- ],
- [
- '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
- 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
- ],
- [
- '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
- 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
- ],
- [
- 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
- '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
- ],
- [
- 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
- '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
- ],
- [
- 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
- '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
- ],
- [
- '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
- 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
- ],
- [
- '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
- '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
- ],
- [
- 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
- 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
- ],
- [
- '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
- 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
- ],
- [
- '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
- '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
- ],
- [
- '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
- '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
- ],
- [
- 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
- 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
- ],
- [
- '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
- '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
- ],
- [
- '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
- '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
- ],
- [
- 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
- '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
- ],
- [
- 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
- 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
- ]
- ]
- },
- naf: {
- wnd: 7,
- points: [
- [
- 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
- '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
- ],
- [
- '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
- 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
- ],
- [
- '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
- '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
- ],
- [
- 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
- 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
- ],
- [
- '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
- 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
- ],
- [
- 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
- 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
- ],
- [
- 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
- '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
- ],
- [
- 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
- '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
- ],
- [
- '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
- '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
- ],
- [
- '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
- '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
- ],
- [
- '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
- '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
- ],
- [
- '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
- '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
- ],
- [
- 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
- 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
- ],
- [
- 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
- '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
- ],
- [
- '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
- 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
- ],
- [
- '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
- 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
- ],
- [
- '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
- '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
- ],
- [
- '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
- '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
- ],
- [
- '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
- '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
- ],
- [
- '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
- 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
- ],
- [
- 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
- 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
- ],
- [
- '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
- '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
- ],
- [
- '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
- '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
- ],
- [
- 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
- 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
- ],
- [
- '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
- '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
- ],
- [
- 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
- 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
- ],
- [
- 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
- 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
- ],
- [
- '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
- '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
- ],
- [
- '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
- '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
- ],
- [
- '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
- '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
- ],
- [
- 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
- '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
- ],
- [
- '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
- '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
- ],
- [
- 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
- '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
- ],
- [
- '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
- 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
- ],
- [
- '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
- 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
- ],
- [
- 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
- 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
- ],
- [
- '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
- '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
- ],
- [
- '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
- 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
- ],
- [
- 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
- 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
- ],
- [
- '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
- '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
- ],
- [
- '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
- 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
- ],
- [
- '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
- '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
- ],
- [
- '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
- 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
- ],
- [
- 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
- '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
- ],
- [
- '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
- '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
- ],
- [
- '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
- 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
- ],
- [
- '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
- 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
- ],
- [
- 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
- 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
- ],
- [
- 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
- 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
- ],
- [
- '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
- '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
- ],
- [
- '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
- '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
- ],
- [
- 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
- '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
- ],
- [
- 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
- 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
- ],
- [
- '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
- '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
- ],
- [
- '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
- '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
- ],
- [
- 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
- '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
- ],
- [
- '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
- '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
- ],
- [
- 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
- 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
- ],
- [
- '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
- 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
- ],
- [
- '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
- '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
- ],
- [
- 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
- '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
- ],
- [
- 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
- '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
- ],
- [
- '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
- '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
- ],
- [
- '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
- '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
- ],
- [
- '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
- 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
- ],
- [
- '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
- 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
- ],
- [
- '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
- '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
- ],
- [
- '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
- '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
- ],
- [
- '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
- '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
- ],
- [
- '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
- 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
- ],
- [
- 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
- 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
- ],
- [
- '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
- 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
- ],
- [
- 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
- '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
- ],
- [
- 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
- '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
- ],
- [
- 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
- '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
- ],
- [
- 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
- '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
- ],
- [
- '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
- 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
- ],
- [
- '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
- '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
- ],
- [
- '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
- 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
- ],
- [
- 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
- 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
- ],
- [
- 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
- '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
- ],
- [
- 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
- 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
- ],
- [
- 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
- '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
- ],
- [
- '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
- '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
- ],
- [
- 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
- '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
- ],
- [
- 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
- '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
- ],
- [
- '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
- '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
- ],
- [
- '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
- 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
- ],
- [
- 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
- '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
- ],
- [
- 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
- '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
- ],
- [
- 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
- '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
- ],
- [
- '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
- '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
- ],
- [
- 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
- 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
- ],
- [
- '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
- 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
- ],
- [
- 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
- 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
- ],
- [
- 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
- '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
- ],
- [
- '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
- 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
- ],
- [
- 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
- '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
- ],
- [
- 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
- '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
- ],
- [
- 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
- '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
- ],
- [
- '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
- 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
- ],
- [
- '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
- 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
- ],
- [
- 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
- '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
- ],
- [
- '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
- 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
- ],
- [
- '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
- '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
- ],
- [
- '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
- 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
- ],
- [
- 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
- 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
- ],
- [
- '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
- 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
- ],
- [
- '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
- '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
- ],
- [
- '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
- 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
- ],
- [
- '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
- '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
- ],
- [
- 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
- 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
- ],
- [
- '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
- '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
- ],
- [
- 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
- '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
- ],
- [
- '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
- '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
- ],
- [
- 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
- 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
- ],
- [
- 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
- '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
- ],
- [
- 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
- 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
- ],
- [
- '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
- 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
- ],
- [
- '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
- '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
- ],
- [
- '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
- 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
- ],
- [
- '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
- '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
- ],
- [
- '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
- '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
- ],
- [
- '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
- 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
- ],
- [
- '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
- '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
- ],
- [
- '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
- '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
- ],
- [
- '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
- '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
- ]
- ]
- }
- };
- },{}],24:[function(require,module,exports){
- 'use strict';
- var utils = exports;
- var BN = require('bn.js');
- var minAssert = require('minimalistic-assert');
- var minUtils = require('minimalistic-crypto-utils');
- utils.assert = minAssert;
- utils.toArray = minUtils.toArray;
- utils.zero2 = minUtils.zero2;
- utils.toHex = minUtils.toHex;
- utils.encode = minUtils.encode;
- // Represent num in a w-NAF form
- function getNAF(num, w) {
- var naf = [];
- var ws = 1 << (w + 1);
- var k = num.clone();
- while (k.cmpn(1) >= 0) {
- var z;
- if (k.isOdd()) {
- var mod = k.andln(ws - 1);
- if (mod > (ws >> 1) - 1)
- z = (ws >> 1) - mod;
- else
- z = mod;
- k.isubn(z);
- } else {
- z = 0;
- }
- naf.push(z);
- // Optimization, shift by word if possible
- var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
- for (var i = 1; i < shift; i++)
- naf.push(0);
- k.iushrn(shift);
- }
- return naf;
- }
- utils.getNAF = getNAF;
- // Represent k1, k2 in a Joint Sparse Form
- function getJSF(k1, k2) {
- var jsf = [
- [],
- []
- ];
- k1 = k1.clone();
- k2 = k2.clone();
- var d1 = 0;
- var d2 = 0;
- while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
- // First phase
- var m14 = (k1.andln(3) + d1) & 3;
- var m24 = (k2.andln(3) + d2) & 3;
- if (m14 === 3)
- m14 = -1;
- if (m24 === 3)
- m24 = -1;
- var u1;
- if ((m14 & 1) === 0) {
- u1 = 0;
- } else {
- var m8 = (k1.andln(7) + d1) & 7;
- if ((m8 === 3 || m8 === 5) && m24 === 2)
- u1 = -m14;
- else
- u1 = m14;
- }
- jsf[0].push(u1);
- var u2;
- if ((m24 & 1) === 0) {
- u2 = 0;
- } else {
- var m8 = (k2.andln(7) + d2) & 7;
- if ((m8 === 3 || m8 === 5) && m14 === 2)
- u2 = -m24;
- else
- u2 = m24;
- }
- jsf[1].push(u2);
- // Second phase
- if (2 * d1 === u1 + 1)
- d1 = 1 - d1;
- if (2 * d2 === u2 + 1)
- d2 = 1 - d2;
- k1.iushrn(1);
- k2.iushrn(1);
- }
- return jsf;
- }
- utils.getJSF = getJSF;
- function cachedProperty(obj, name, computer) {
- var key = '_' + name;
- obj.prototype[name] = function cachedProperty() {
- return this[key] !== undefined ? this[key] :
- this[key] = computer.call(this);
- };
- }
- utils.cachedProperty = cachedProperty;
- function parseBytes(bytes) {
- return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
- bytes;
- }
- utils.parseBytes = parseBytes;
- function intFromLE(bytes) {
- return new BN(bytes, 'hex', 'le');
- }
- utils.intFromLE = intFromLE;
- },{"bn.js":4,"minimalistic-assert":42,"minimalistic-crypto-utils":43}],25:[function(require,module,exports){
- module.exports={
- "_args": [
- [
- {
- "raw": "elliptic@^6.2.3",
- "scope": null,
- "escapedName": "elliptic",
- "name": "elliptic",
- "rawSpec": "^6.2.3",
- "spec": ">=6.2.3 <7.0.0",
- "type": "range"
- },
- "/home/ethvm/Desktop/Embark/eth-utils/ethereumjs-util/node_modules/secp256k1"
- ]
- ],
- "_from": "elliptic@>=6.2.3 <7.0.0",
- "_id": "[email protected]",
- "_inCache": true,
- "_location": "/elliptic",
- "_nodeVersion": "7.0.0",
- "_npmOperationalInternal": {
- "host": "packages-18-east.internal.npmjs.com",
- "tmp": "tmp/elliptic-6.4.0.tgz_1487798866428_0.30510620190761983"
- },
- "_npmUser": {
- "name": "indutny",
- "email": "[email protected]"
- },
- "_npmVersion": "3.10.8",
- "_phantomChildren": {},
- "_requested": {
- "raw": "elliptic@^6.2.3",
- "scope": null,
- "escapedName": "elliptic",
- "name": "elliptic",
- "rawSpec": "^6.2.3",
- "spec": ">=6.2.3 <7.0.0",
- "type": "range"
- },
- "_requiredBy": [
- "/browserify-sign",
- "/create-ecdh",
- "/secp256k1"
- ],
- "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
- "_shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df",
- "_shrinkwrap": null,
- "_spec": "elliptic@^6.2.3",
- "_where": "/home/ethvm/Desktop/Embark/eth-utils/ethereumjs-util/node_modules/secp256k1",
- "author": {
- "name": "Fedor Indutny",
- "email": "[email protected]"
- },
- "bugs": {
- "url": "https://github.com/indutny/elliptic/issues"
- },
- "dependencies": {
- "bn.js": "^4.4.0",
- "brorand": "^1.0.1",
- "hash.js": "^1.0.0",
- "hmac-drbg": "^1.0.0",
- "inherits": "^2.0.1",
- "minimalistic-assert": "^1.0.0",
- "minimalistic-crypto-utils": "^1.0.0"
- },
- "description": "EC cryptography",
- "devDependencies": {
- "brfs": "^1.4.3",
- "coveralls": "^2.11.3",
- "grunt": "^0.4.5",
- "grunt-browserify": "^5.0.0",
- "grunt-cli": "^1.2.0",
- "grunt-contrib-connect": "^1.0.0",
- "grunt-contrib-copy": "^1.0.0",
- "grunt-contrib-uglify": "^1.0.1",
- "grunt-mocha-istanbul": "^3.0.1",
- "grunt-saucelabs": "^8.6.2",
- "istanbul": "^0.4.2",
- "jscs": "^2.9.0",
- "jshint": "^2.6.0",
- "mocha": "^2.1.0"
- },
- "directories": {},
- "dist": {
- "shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df",
- "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz"
- },
- "files": [
- "lib"
- ],
- "gitHead": "6b0d2b76caae91471649c8e21f0b1d3ba0f96090",
- "homepage": "https://github.com/indutny/elliptic",
- "keywords": [
- "EC",
- "Elliptic",
- "curve",
- "Cryptography"
- ],
- "license": "MIT",
- "main": "lib/elliptic.js",
- "maintainers": [
- {
- "name": "indutny",
- "email": "[email protected]"
- }
- ],
- "name": "elliptic",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git+ssh://[email protected]/indutny/elliptic.git"
- },
- "scripts": {
- "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
- "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
- "lint": "npm run jscs && npm run jshint",
- "test": "npm run lint && npm run unit",
- "unit": "istanbul test _mocha --reporter=spec test/index.js",
- "version": "grunt dist && git add dist/"
- },
- "version": "6.4.0"
- }
- },{}],26:[function(require,module,exports){
- (function (Buffer){
- 'use strict';
- var isHexPrefixed = require('is-hex-prefixed');
- var stripHexPrefix = require('strip-hex-prefix');
- /**
- * Pads a `String` to have an even length
- * @param {String} value
- * @return {String} output
- */
- function padToEven(value) {
- var a = value; // eslint-disable-line
- if (typeof a !== 'string') {
- throw new Error('[ethjs-util] while padding to even, value must be string, is currently ' + typeof a + ', while padToEven.');
- }
- if (a.length % 2) {
- a = '0' + a;
- }
- return a;
- }
- /**
- * Converts a `Number` into a hex `String`
- * @param {Number} i
- * @return {String}
- */
- function intToHex(i) {
- var hex = i.toString(16); // eslint-disable-line
- return '0x' + padToEven(hex);
- }
- /**
- * Converts an `Number` to a `Buffer`
- * @param {Number} i
- * @return {Buffer}
- */
- function intToBuffer(i) {
- var hex = intToHex(i);
- return new Buffer(hex.slice(2), 'hex');
- }
- /**
- * Get the binary size of a string
- * @param {String} str
- * @return {Number}
- */
- function getBinarySize(str) {
- if (typeof str !== 'string') {
- throw new Error('[ethjs-util] while getting binary size, method getBinarySize requires input \'str\' to be type String, got \'' + typeof str + '\'.');
- }
- return Buffer.byteLength(str, 'utf8');
- }
- /**
- * Returns TRUE if the first specified array contains all elements
- * from the second one. FALSE otherwise.
- *
- * @param {array} superset
- * @param {array} subset
- *
- * @returns {boolean}
- */
- function arrayContainsArray(superset, subset, some) {
- if (Array.isArray(superset) !== true) {
- throw new Error('[ethjs-util] method arrayContainsArray requires input \'superset\' to be an array got type \'' + typeof superset + '\'');
- }
- if (Array.isArray(subset) !== true) {
- throw new Error('[ethjs-util] method arrayContainsArray requires input \'subset\' to be an array got type \'' + typeof subset + '\'');
- }
- return subset[Boolean(some) && 'some' || 'every'](function (value) {
- return superset.indexOf(value) >= 0;
- });
- }
- /**
- * Should be called to get utf8 from it's hex representation
- *
- * @method toUtf8
- * @param {String} string in hex
- * @returns {String} ascii string representation of hex value
- */
- function toUtf8(hex) {
- var bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex');
- return bufferValue.toString('utf8');
- }
- /**
- * Should be called to get ascii from it's hex representation
- *
- * @method toAscii
- * @param {String} string in hex
- * @returns {String} ascii string representation of hex value
- */
- function toAscii(hex) {
- var str = ''; // eslint-disable-line
- var i = 0,
- l = hex.length; // eslint-disable-line
- if (hex.substring(0, 2) === '0x') {
- i = 2;
- }
- for (; i < l; i += 2) {
- var code = parseInt(hex.substr(i, 2), 16);
- str += String.fromCharCode(code);
- }
- return str;
- }
- /**
- * Should be called to get hex representation (prefixed by 0x) of utf8 string
- *
- * @method fromUtf8
- * @param {String} string
- * @param {Number} optional padding
- * @returns {String} hex representation of input string
- */
- function fromUtf8(stringValue) {
- var str = new Buffer(stringValue, 'utf8');
- return '0x' + padToEven(str.toString('hex')).replace(/^0+|0+$/g, '');
- }
- /**
- * Should be called to get hex representation (prefixed by 0x) of ascii string
- *
- * @method fromAscii
- * @param {String} string
- * @param {Number} optional padding
- * @returns {String} hex representation of input string
- */
- function fromAscii(stringValue) {
- var hex = ''; // eslint-disable-line
- for (var i = 0; i < stringValue.length; i++) {
- // eslint-disable-line
- var code = stringValue.charCodeAt(i);
- var n = code.toString(16);
- hex += n.length < 2 ? '0' + n : n;
- }
- return '0x' + hex;
- }
- /**
- * getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
- *
- * @method getKeys get specific key from inner object array of objects
- * @param {String} params
- * @param {String} key
- * @param {Boolean} allowEmpty
- * @returns {Array} output just a simple array of output keys
- */
- function getKeys(params, key, allowEmpty) {
- if (!Array.isArray(params)) {
- throw new Error('[ethjs-util] method getKeys expecting type Array as \'params\' input, got \'' + typeof params + '\'');
- }
- if (typeof key !== 'string') {
- throw new Error('[ethjs-util] method getKeys expecting type String for input \'key\' got \'' + typeof key + '\'.');
- }
- var result = []; // eslint-disable-line
- for (var i = 0; i < params.length; i++) {
- // eslint-disable-line
- var value = params[i][key]; // eslint-disable-line
- if (allowEmpty && !value) {
- value = '';
- } else if (typeof value !== 'string') {
- throw new Error('invalid abi');
- }
- result.push(value);
- }
- return result;
- }
- /**
- * Is the string a hex string.
- *
- * @method check if string is hex string of specific length
- * @param {String} value
- * @param {Number} length
- * @returns {Boolean} output the string is a hex string
- */
- function isHexString(value, length) {
- if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
- return false;
- }
- if (length && value.length !== 2 + 2 * length) {
- return false;
- }
- return true;
- }
- module.exports = {
- arrayContainsArray: arrayContainsArray,
- intToBuffer: intToBuffer,
- getBinarySize: getBinarySize,
- isHexPrefixed: isHexPrefixed,
- stripHexPrefix: stripHexPrefix,
- padToEven: padToEven,
- intToHex: intToHex,
- fromAscii: fromAscii,
- fromUtf8: fromUtf8,
- toAscii: toAscii,
- toUtf8: toUtf8,
- getKeys: getKeys,
- isHexString: isHexString
- };
- }).call(this,require("buffer").Buffer)
- },{"buffer":65,"is-hex-prefixed":35,"strip-hex-prefix":60}],27:[function(require,module,exports){
- var hash = exports;
- hash.utils = require('./hash/utils');
- hash.common = require('./hash/common');
- hash.sha = require('./hash/sha');
- hash.ripemd = require('./hash/ripemd');
- hash.hmac = require('./hash/hmac');
- // Proxy hash functions to the main object
- hash.sha1 = hash.sha.sha1;
- hash.sha256 = hash.sha.sha256;
- hash.sha224 = hash.sha.sha224;
- hash.sha384 = hash.sha.sha384;
- hash.sha512 = hash.sha.sha512;
- hash.ripemd160 = hash.ripemd.ripemd160;
- },{"./hash/common":28,"./hash/hmac":29,"./hash/ripemd":30,"./hash/sha":31,"./hash/utils":32}],28:[function(require,module,exports){
- var hash = require('../hash');
- var utils = hash.utils;
- var assert = utils.assert;
- function BlockHash() {
- this.pending = null;
- this.pendingTotal = 0;
- this.blockSize = this.constructor.blockSize;
- this.outSize = this.constructor.outSize;
- this.hmacStrength = this.constructor.hmacStrength;
- this.padLength = this.constructor.padLength / 8;
- this.endian = 'big';
- this._delta8 = this.blockSize / 8;
- this._delta32 = this.blockSize / 32;
- }
- exports.BlockHash = BlockHash;
- BlockHash.prototype.update = function update(msg, enc) {
- // Convert message to array, pad it, and join into 32bit blocks
- msg = utils.toArray(msg, enc);
- if (!this.pending)
- this.pending = msg;
- else
- this.pending = this.pending.concat(msg);
- this.pendingTotal += msg.length;
- // Enough data, try updating
- if (this.pending.length >= this._delta8) {
- msg = this.pending;
- // Process pending data in blocks
- var r = msg.length % this._delta8;
- this.pending = msg.slice(msg.length - r, msg.length);
- if (this.pending.length === 0)
- this.pending = null;
- msg = utils.join32(msg, 0, msg.length - r, this.endian);
- for (var i = 0; i < msg.length; i += this._delta32)
- this._update(msg, i, i + this._delta32);
- }
- return this;
- };
- BlockHash.prototype.digest = function digest(enc) {
- this.update(this._pad());
- assert(this.pending === null);
- return this._digest(enc);
- };
- BlockHash.prototype._pad = function pad() {
- var len = this.pendingTotal;
- var bytes = this._delta8;
- var k = bytes - ((len + this.padLength) % bytes);
- var res = new Array(k + this.padLength);
- res[0] = 0x80;
- for (var i = 1; i < k; i++)
- res[i] = 0;
- // Append length
- len <<= 3;
- if (this.endian === 'big') {
- for (var t = 8; t < this.padLength; t++)
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = len & 0xff;
- } else {
- res[i++] = len & 0xff;
- res[i++] = (len >>> 8) & 0xff;
- res[i++] = (len >>> 16) & 0xff;
- res[i++] = (len >>> 24) & 0xff;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- res[i++] = 0;
- for (var t = 8; t < this.padLength; t++)
- res[i++] = 0;
- }
- return res;
- };
- },{"../hash":27}],29:[function(require,module,exports){
- var hmac = exports;
- var hash = require('../hash');
- var utils = hash.utils;
- var assert = utils.assert;
- function Hmac(hash, key, enc) {
- if (!(this instanceof Hmac))
- return new Hmac(hash, key, enc);
- this.Hash = hash;
- this.blockSize = hash.blockSize / 8;
- this.outSize = hash.outSize / 8;
- this.inner = null;
- this.outer = null;
- this._init(utils.toArray(key, enc));
- }
- module.exports = Hmac;
- Hmac.prototype._init = function init(key) {
- // Shorten key, if needed
- if (key.length > this.blockSize)
- key = new this.Hash().update(key).digest();
- assert(key.length <= this.blockSize);
- // Add padding to key
- for (var i = key.length; i < this.blockSize; i++)
- key.push(0);
- for (var i = 0; i < key.length; i++)
- key[i] ^= 0x36;
- this.inner = new this.Hash().update(key);
- // 0x36 ^ 0x5c = 0x6a
- for (var i = 0; i < key.length; i++)
- key[i] ^= 0x6a;
- this.outer = new this.Hash().update(key);
- };
- Hmac.prototype.update = function update(msg, enc) {
- this.inner.update(msg, enc);
- return this;
- };
- Hmac.prototype.digest = function digest(enc) {
- this.outer.update(this.inner.digest());
- return this.outer.digest(enc);
- };
- },{"../hash":27}],30:[function(require,module,exports){
- var hash = require('../hash');
- var utils = hash.utils;
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_3 = utils.sum32_3;
- var sum32_4 = utils.sum32_4;
- var BlockHash = hash.common.BlockHash;
- function RIPEMD160() {
- if (!(this instanceof RIPEMD160))
- return new RIPEMD160();
- BlockHash.call(this);
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
- this.endian = 'little';
- }
- utils.inherits(RIPEMD160, BlockHash);
- exports.ripemd160 = RIPEMD160;
- RIPEMD160.blockSize = 512;
- RIPEMD160.outSize = 160;
- RIPEMD160.hmacStrength = 192;
- RIPEMD160.padLength = 64;
- RIPEMD160.prototype._update = function update(msg, start) {
- var A = this.h[0];
- var B = this.h[1];
- var C = this.h[2];
- var D = this.h[3];
- var E = this.h[4];
- var Ah = A;
- var Bh = B;
- var Ch = C;
- var Dh = D;
- var Eh = E;
- for (var j = 0; j < 80; j++) {
- var T = sum32(
- rotl32(
- sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
- s[j]),
- E);
- A = E;
- E = D;
- D = rotl32(C, 10);
- C = B;
- B = T;
- T = sum32(
- rotl32(
- sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
- sh[j]),
- Eh);
- Ah = Eh;
- Eh = Dh;
- Dh = rotl32(Ch, 10);
- Ch = Bh;
- Bh = T;
- }
- T = sum32_3(this.h[1], C, Dh);
- this.h[1] = sum32_3(this.h[2], D, Eh);
- this.h[2] = sum32_3(this.h[3], E, Ah);
- this.h[3] = sum32_3(this.h[4], A, Bh);
- this.h[4] = sum32_3(this.h[0], B, Ch);
- this.h[0] = T;
- };
- RIPEMD160.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'little');
- else
- return utils.split32(this.h, 'little');
- };
- function f(j, x, y, z) {
- if (j <= 15)
- return x ^ y ^ z;
- else if (j <= 31)
- return (x & y) | ((~x) & z);
- else if (j <= 47)
- return (x | (~y)) ^ z;
- else if (j <= 63)
- return (x & z) | (y & (~z));
- else
- return x ^ (y | (~z));
- }
- function K(j) {
- if (j <= 15)
- return 0x00000000;
- else if (j <= 31)
- return 0x5a827999;
- else if (j <= 47)
- return 0x6ed9eba1;
- else if (j <= 63)
- return 0x8f1bbcdc;
- else
- return 0xa953fd4e;
- }
- function Kh(j) {
- if (j <= 15)
- return 0x50a28be6;
- else if (j <= 31)
- return 0x5c4dd124;
- else if (j <= 47)
- return 0x6d703ef3;
- else if (j <= 63)
- return 0x7a6d76e9;
- else
- return 0x00000000;
- }
- var r = [
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
- ];
- var rh = [
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
- ];
- var s = [
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
- ];
- var sh = [
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
- ];
- },{"../hash":27}],31:[function(require,module,exports){
- var hash = require('../hash');
- var utils = hash.utils;
- var assert = utils.assert;
- var rotr32 = utils.rotr32;
- var rotl32 = utils.rotl32;
- var sum32 = utils.sum32;
- var sum32_4 = utils.sum32_4;
- var sum32_5 = utils.sum32_5;
- var rotr64_hi = utils.rotr64_hi;
- var rotr64_lo = utils.rotr64_lo;
- var shr64_hi = utils.shr64_hi;
- var shr64_lo = utils.shr64_lo;
- var sum64 = utils.sum64;
- var sum64_hi = utils.sum64_hi;
- var sum64_lo = utils.sum64_lo;
- var sum64_4_hi = utils.sum64_4_hi;
- var sum64_4_lo = utils.sum64_4_lo;
- var sum64_5_hi = utils.sum64_5_hi;
- var sum64_5_lo = utils.sum64_5_lo;
- var BlockHash = hash.common.BlockHash;
- var sha256_K = [
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
- ];
- var sha512_K = [
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
- ];
- var sha1_K = [
- 0x5A827999, 0x6ED9EBA1,
- 0x8F1BBCDC, 0xCA62C1D6
- ];
- function SHA256() {
- if (!(this instanceof SHA256))
- return new SHA256();
- BlockHash.call(this);
- this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
- this.k = sha256_K;
- this.W = new Array(64);
- }
- utils.inherits(SHA256, BlockHash);
- exports.sha256 = SHA256;
- SHA256.blockSize = 512;
- SHA256.outSize = 256;
- SHA256.hmacStrength = 192;
- SHA256.padLength = 64;
- SHA256.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i++)
- W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- var f = this.h[5];
- var g = this.h[6];
- var h = this.h[7];
- assert(this.k.length === W.length);
- for (var i = 0; i < W.length; i++) {
- var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
- var T2 = sum32(s0_256(a), maj32(a, b, c));
- h = g;
- g = f;
- f = e;
- e = sum32(d, T1);
- d = c;
- c = b;
- b = a;
- a = sum32(T1, T2);
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- this.h[5] = sum32(this.h[5], f);
- this.h[6] = sum32(this.h[6], g);
- this.h[7] = sum32(this.h[7], h);
- };
- SHA256.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function SHA224() {
- if (!(this instanceof SHA224))
- return new SHA224();
- SHA256.call(this);
- this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
- 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
- }
- utils.inherits(SHA224, SHA256);
- exports.sha224 = SHA224;
- SHA224.blockSize = 512;
- SHA224.outSize = 224;
- SHA224.hmacStrength = 192;
- SHA224.padLength = 64;
- SHA224.prototype._digest = function digest(enc) {
- // Just truncate output
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 7), 'big');
- else
- return utils.split32(this.h.slice(0, 7), 'big');
- };
- function SHA512() {
- if (!(this instanceof SHA512))
- return new SHA512();
- BlockHash.call(this);
- this.h = [ 0x6a09e667, 0xf3bcc908,
- 0xbb67ae85, 0x84caa73b,
- 0x3c6ef372, 0xfe94f82b,
- 0xa54ff53a, 0x5f1d36f1,
- 0x510e527f, 0xade682d1,
- 0x9b05688c, 0x2b3e6c1f,
- 0x1f83d9ab, 0xfb41bd6b,
- 0x5be0cd19, 0x137e2179 ];
- this.k = sha512_K;
- this.W = new Array(160);
- }
- utils.inherits(SHA512, BlockHash);
- exports.sha512 = SHA512;
- SHA512.blockSize = 1024;
- SHA512.outSize = 512;
- SHA512.hmacStrength = 192;
- SHA512.padLength = 128;
- SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
- var W = this.W;
- // 32 x 32bit words
- for (var i = 0; i < 32; i++)
- W[i] = msg[start + i];
- for (; i < W.length; i += 2) {
- var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
- var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
- var c1_hi = W[i - 14]; // i - 7
- var c1_lo = W[i - 13];
- var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
- var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
- var c3_hi = W[i - 32]; // i - 16
- var c3_lo = W[i - 31];
- W[i] = sum64_4_hi(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo);
- }
- };
- SHA512.prototype._update = function _update(msg, start) {
- this._prepareBlock(msg, start);
- var W = this.W;
- var ah = this.h[0];
- var al = this.h[1];
- var bh = this.h[2];
- var bl = this.h[3];
- var ch = this.h[4];
- var cl = this.h[5];
- var dh = this.h[6];
- var dl = this.h[7];
- var eh = this.h[8];
- var el = this.h[9];
- var fh = this.h[10];
- var fl = this.h[11];
- var gh = this.h[12];
- var gl = this.h[13];
- var hh = this.h[14];
- var hl = this.h[15];
- assert(this.k.length === W.length);
- for (var i = 0; i < W.length; i += 2) {
- var c0_hi = hh;
- var c0_lo = hl;
- var c1_hi = s1_512_hi(eh, el);
- var c1_lo = s1_512_lo(eh, el);
- var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
- var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
- var c3_hi = this.k[i];
- var c3_lo = this.k[i + 1];
- var c4_hi = W[i];
- var c4_lo = W[i + 1];
- var T1_hi = sum64_5_hi(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- var T1_lo = sum64_5_lo(c0_hi, c0_lo,
- c1_hi, c1_lo,
- c2_hi, c2_lo,
- c3_hi, c3_lo,
- c4_hi, c4_lo);
- var c0_hi = s0_512_hi(ah, al);
- var c0_lo = s0_512_lo(ah, al);
- var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
- var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
- var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
- var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
- hh = gh;
- hl = gl;
- gh = fh;
- gl = fl;
- fh = eh;
- fl = el;
- eh = sum64_hi(dh, dl, T1_hi, T1_lo);
- el = sum64_lo(dl, dl, T1_hi, T1_lo);
- dh = ch;
- dl = cl;
- ch = bh;
- cl = bl;
- bh = ah;
- bl = al;
- ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
- al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
- }
- sum64(this.h, 0, ah, al);
- sum64(this.h, 2, bh, bl);
- sum64(this.h, 4, ch, cl);
- sum64(this.h, 6, dh, dl);
- sum64(this.h, 8, eh, el);
- sum64(this.h, 10, fh, fl);
- sum64(this.h, 12, gh, gl);
- sum64(this.h, 14, hh, hl);
- };
- SHA512.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function SHA384() {
- if (!(this instanceof SHA384))
- return new SHA384();
- SHA512.call(this);
- this.h = [ 0xcbbb9d5d, 0xc1059ed8,
- 0x629a292a, 0x367cd507,
- 0x9159015a, 0x3070dd17,
- 0x152fecd8, 0xf70e5939,
- 0x67332667, 0xffc00b31,
- 0x8eb44a87, 0x68581511,
- 0xdb0c2e0d, 0x64f98fa7,
- 0x47b5481d, 0xbefa4fa4 ];
- }
- utils.inherits(SHA384, SHA512);
- exports.sha384 = SHA384;
- SHA384.blockSize = 1024;
- SHA384.outSize = 384;
- SHA384.hmacStrength = 192;
- SHA384.padLength = 128;
- SHA384.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h.slice(0, 12), 'big');
- else
- return utils.split32(this.h.slice(0, 12), 'big');
- };
- function SHA1() {
- if (!(this instanceof SHA1))
- return new SHA1();
- BlockHash.call(this);
- this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
- 0x10325476, 0xc3d2e1f0 ];
- this.W = new Array(80);
- }
- utils.inherits(SHA1, BlockHash);
- exports.sha1 = SHA1;
- SHA1.blockSize = 512;
- SHA1.outSize = 160;
- SHA1.hmacStrength = 80;
- SHA1.padLength = 64;
- SHA1.prototype._update = function _update(msg, start) {
- var W = this.W;
- for (var i = 0; i < 16; i++)
- W[i] = msg[start + i];
- for(; i < W.length; i++)
- W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
- var a = this.h[0];
- var b = this.h[1];
- var c = this.h[2];
- var d = this.h[3];
- var e = this.h[4];
- for (var i = 0; i < W.length; i++) {
- var s = ~~(i / 20);
- var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
- e = d;
- d = c;
- c = rotl32(b, 30);
- b = a;
- a = t;
- }
- this.h[0] = sum32(this.h[0], a);
- this.h[1] = sum32(this.h[1], b);
- this.h[2] = sum32(this.h[2], c);
- this.h[3] = sum32(this.h[3], d);
- this.h[4] = sum32(this.h[4], e);
- };
- SHA1.prototype._digest = function digest(enc) {
- if (enc === 'hex')
- return utils.toHex32(this.h, 'big');
- else
- return utils.split32(this.h, 'big');
- };
- function ch32(x, y, z) {
- return (x & y) ^ ((~x) & z);
- }
- function maj32(x, y, z) {
- return (x & y) ^ (x & z) ^ (y & z);
- }
- function p32(x, y, z) {
- return x ^ y ^ z;
- }
- function s0_256(x) {
- return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
- }
- function s1_256(x) {
- return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
- }
- function g0_256(x) {
- return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
- }
- function g1_256(x) {
- return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
- }
- function ft_1(s, x, y, z) {
- if (s === 0)
- return ch32(x, y, z);
- if (s === 1 || s === 3)
- return p32(x, y, z);
- if (s === 2)
- return maj32(x, y, z);
- }
- function ch64_hi(xh, xl, yh, yl, zh, zl) {
- var r = (xh & yh) ^ ((~xh) & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function ch64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ ((~xl) & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_hi(xh, xl, yh, yl, zh, zl) {
- var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function maj64_lo(xh, xl, yh, yl, zh, zl) {
- var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 28);
- var c1_hi = rotr64_hi(xl, xh, 2); // 34
- var c2_hi = rotr64_hi(xl, xh, 7); // 39
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 28);
- var c1_lo = rotr64_lo(xl, xh, 2); // 34
- var c2_lo = rotr64_lo(xl, xh, 7); // 39
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 14);
- var c1_hi = rotr64_hi(xh, xl, 18);
- var c2_hi = rotr64_hi(xl, xh, 9); // 41
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function s1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 14);
- var c1_lo = rotr64_lo(xh, xl, 18);
- var c2_lo = rotr64_lo(xl, xh, 9); // 41
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 1);
- var c1_hi = rotr64_hi(xh, xl, 8);
- var c2_hi = shr64_hi(xh, xl, 7);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g0_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 1);
- var c1_lo = rotr64_lo(xh, xl, 8);
- var c2_lo = shr64_lo(xh, xl, 7);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_hi(xh, xl) {
- var c0_hi = rotr64_hi(xh, xl, 19);
- var c1_hi = rotr64_hi(xl, xh, 29); // 61
- var c2_hi = shr64_hi(xh, xl, 6);
- var r = c0_hi ^ c1_hi ^ c2_hi;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- function g1_512_lo(xh, xl) {
- var c0_lo = rotr64_lo(xh, xl, 19);
- var c1_lo = rotr64_lo(xl, xh, 29); // 61
- var c2_lo = shr64_lo(xh, xl, 6);
- var r = c0_lo ^ c1_lo ^ c2_lo;
- if (r < 0)
- r += 0x100000000;
- return r;
- }
- },{"../hash":27}],32:[function(require,module,exports){
- var utils = exports;
- var inherits = require('inherits');
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg === 'string') {
- if (!enc) {
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- var hi = c >> 8;
- var lo = c & 0xff;
- if (hi)
- res.push(hi, lo);
- else
- res.push(lo);
- }
- } else if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (var i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- }
- } else {
- for (var i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- }
- return res;
- }
- utils.toArray = toArray;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- utils.toHex = toHex;
- function htonl(w) {
- var res = (w >>> 24) |
- ((w >>> 8) & 0xff00) |
- ((w << 8) & 0xff0000) |
- ((w & 0xff) << 24);
- return res >>> 0;
- }
- utils.htonl = htonl;
- function toHex32(msg, endian) {
- var res = '';
- for (var i = 0; i < msg.length; i++) {
- var w = msg[i];
- if (endian === 'little')
- w = htonl(w);
- res += zero8(w.toString(16));
- }
- return res;
- }
- utils.toHex32 = toHex32;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- utils.zero2 = zero2;
- function zero8(word) {
- if (word.length === 7)
- return '0' + word;
- else if (word.length === 6)
- return '00' + word;
- else if (word.length === 5)
- return '000' + word;
- else if (word.length === 4)
- return '0000' + word;
- else if (word.length === 3)
- return '00000' + word;
- else if (word.length === 2)
- return '000000' + word;
- else if (word.length === 1)
- return '0000000' + word;
- else
- return word;
- }
- utils.zero8 = zero8;
- function join32(msg, start, end, endian) {
- var len = end - start;
- assert(len % 4 === 0);
- var res = new Array(len / 4);
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
- var w;
- if (endian === 'big')
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
- else
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
- res[i] = w >>> 0;
- }
- return res;
- }
- utils.join32 = join32;
- function split32(msg, endian) {
- var res = new Array(msg.length * 4);
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
- var m = msg[i];
- if (endian === 'big') {
- res[k] = m >>> 24;
- res[k + 1] = (m >>> 16) & 0xff;
- res[k + 2] = (m >>> 8) & 0xff;
- res[k + 3] = m & 0xff;
- } else {
- res[k + 3] = m >>> 24;
- res[k + 2] = (m >>> 16) & 0xff;
- res[k + 1] = (m >>> 8) & 0xff;
- res[k] = m & 0xff;
- }
- }
- return res;
- }
- utils.split32 = split32;
- function rotr32(w, b) {
- return (w >>> b) | (w << (32 - b));
- }
- utils.rotr32 = rotr32;
- function rotl32(w, b) {
- return (w << b) | (w >>> (32 - b));
- }
- utils.rotl32 = rotl32;
- function sum32(a, b) {
- return (a + b) >>> 0;
- }
- utils.sum32 = sum32;
- function sum32_3(a, b, c) {
- return (a + b + c) >>> 0;
- }
- utils.sum32_3 = sum32_3;
- function sum32_4(a, b, c, d) {
- return (a + b + c + d) >>> 0;
- }
- utils.sum32_4 = sum32_4;
- function sum32_5(a, b, c, d, e) {
- return (a + b + c + d + e) >>> 0;
- }
- utils.sum32_5 = sum32_5;
- function assert(cond, msg) {
- if (!cond)
- throw new Error(msg || 'Assertion failed');
- }
- utils.assert = assert;
- utils.inherits = inherits;
- function sum64(buf, pos, ah, al) {
- var bh = buf[pos];
- var bl = buf[pos + 1];
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- buf[pos] = hi >>> 0;
- buf[pos + 1] = lo;
- }
- exports.sum64 = sum64;
- function sum64_hi(ah, al, bh, bl) {
- var lo = (al + bl) >>> 0;
- var hi = (lo < al ? 1 : 0) + ah + bh;
- return hi >>> 0;
- };
- exports.sum64_hi = sum64_hi;
- function sum64_lo(ah, al, bh, bl) {
- var lo = al + bl;
- return lo >>> 0;
- };
- exports.sum64_lo = sum64_lo;
- function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- var hi = ah + bh + ch + dh + carry;
- return hi >>> 0;
- };
- exports.sum64_4_hi = sum64_4_hi;
- function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
- var lo = al + bl + cl + dl;
- return lo >>> 0;
- };
- exports.sum64_4_lo = sum64_4_lo;
- function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var carry = 0;
- var lo = al;
- lo = (lo + bl) >>> 0;
- carry += lo < al ? 1 : 0;
- lo = (lo + cl) >>> 0;
- carry += lo < cl ? 1 : 0;
- lo = (lo + dl) >>> 0;
- carry += lo < dl ? 1 : 0;
- lo = (lo + el) >>> 0;
- carry += lo < el ? 1 : 0;
- var hi = ah + bh + ch + dh + eh + carry;
- return hi >>> 0;
- };
- exports.sum64_5_hi = sum64_5_hi;
- function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
- var lo = al + bl + cl + dl + el;
- return lo >>> 0;
- };
- exports.sum64_5_lo = sum64_5_lo;
- function rotr64_hi(ah, al, num) {
- var r = (al << (32 - num)) | (ah >>> num);
- return r >>> 0;
- };
- exports.rotr64_hi = rotr64_hi;
- function rotr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- };
- exports.rotr64_lo = rotr64_lo;
- function shr64_hi(ah, al, num) {
- return ah >>> num;
- };
- exports.shr64_hi = shr64_hi;
- function shr64_lo(ah, al, num) {
- var r = (ah << (32 - num)) | (al >>> num);
- return r >>> 0;
- };
- exports.shr64_lo = shr64_lo;
- },{"inherits":34}],33:[function(require,module,exports){
- 'use strict';
- var hash = require('hash.js');
- var utils = require('minimalistic-crypto-utils');
- var assert = require('minimalistic-assert');
- function HmacDRBG(options) {
- if (!(this instanceof HmacDRBG))
- return new HmacDRBG(options);
- this.hash = options.hash;
- this.predResist = !!options.predResist;
- this.outLen = this.hash.outSize;
- this.minEntropy = options.minEntropy || this.hash.hmacStrength;
- this.reseed = null;
- this.reseedInterval = null;
- this.K = null;
- this.V = null;
- var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
- var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
- var pers = utils.toArray(options.pers, options.persEnc || 'hex');
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._init(entropy, nonce, pers);
- }
- module.exports = HmacDRBG;
- HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
- var seed = entropy.concat(nonce).concat(pers);
- this.K = new Array(this.outLen / 8);
- this.V = new Array(this.outLen / 8);
- for (var i = 0; i < this.V.length; i++) {
- this.K[i] = 0x00;
- this.V[i] = 0x01;
- }
- this._update(seed);
- this.reseed = 1;
- this.reseedInterval = 0x1000000000000; // 2^48
- };
- HmacDRBG.prototype._hmac = function hmac() {
- return new hash.hmac(this.hash, this.K);
- };
- HmacDRBG.prototype._update = function update(seed) {
- var kmac = this._hmac()
- .update(this.V)
- .update([ 0x00 ]);
- if (seed)
- kmac = kmac.update(seed);
- this.K = kmac.digest();
- this.V = this._hmac().update(this.V).digest();
- if (!seed)
- return;
- this.K = this._hmac()
- .update(this.V)
- .update([ 0x01 ])
- .update(seed)
- .digest();
- this.V = this._hmac().update(this.V).digest();
- };
- HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
- // Optional entropy enc
- if (typeof entropyEnc !== 'string') {
- addEnc = add;
- add = entropyEnc;
- entropyEnc = null;
- }
- entropy = utils.toArray(entropy, entropyEnc);
- add = utils.toArray(add, addEnc);
- assert(entropy.length >= (this.minEntropy / 8),
- 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
- this._update(entropy.concat(add || []));
- this.reseed = 1;
- };
- HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
- if (this.reseed > this.reseedInterval)
- throw new Error('Reseed is required');
- // Optional encoding
- if (typeof enc !== 'string') {
- addEnc = add;
- add = enc;
- enc = null;
- }
- // Optional additional data
- if (add) {
- add = utils.toArray(add, addEnc || 'hex');
- this._update(add);
- }
- var temp = [];
- while (temp.length < len) {
- this.V = this._hmac().update(this.V).digest();
- temp = temp.concat(this.V);
- }
- var res = temp.slice(0, len);
- this._update(add);
- this.reseed++;
- return utils.encode(res, enc);
- };
- },{"hash.js":27,"minimalistic-assert":42,"minimalistic-crypto-utils":43}],34:[function(require,module,exports){
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- },{}],35:[function(require,module,exports){
- /**
- * Returns a `Boolean` on whether or not the a `String` starts with '0x'
- * @param {String} str the string input value
- * @return {Boolean} a boolean if it is or is not hex prefixed
- * @throws if the str input is not a string
- */
- module.exports = function isHexPrefixed(str) {
- if (typeof str !== 'string') {
- throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
- }
- return str.slice(0, 2) === '0x';
- }
- },{}],36:[function(require,module,exports){
- 'use strict'
- module.exports = require('./lib/api')(require('./lib/keccak'))
- },{"./lib/api":37,"./lib/keccak":41}],37:[function(require,module,exports){
- 'use strict'
- var createKeccak = require('./keccak')
- var createShake = require('./shake')
- module.exports = function (KeccakState) {
- var Keccak = createKeccak(KeccakState)
- var Shake = createShake(KeccakState)
- return function (algorithm, options) {
- var hash = typeof algorithm === 'string' ? algorithm.toLowerCase() : algorithm
- switch (hash) {
- case 'keccak224': return new Keccak(1152, 448, null, 224, options)
- case 'keccak256': return new Keccak(1088, 512, null, 256, options)
- case 'keccak384': return new Keccak(832, 768, null, 384, options)
- case 'keccak512': return new Keccak(576, 1024, null, 512, options)
- case 'sha3-224': return new Keccak(1152, 448, 0x06, 224, options)
- case 'sha3-256': return new Keccak(1088, 512, 0x06, 256, options)
- case 'sha3-384': return new Keccak(832, 768, 0x06, 384, options)
- case 'sha3-512': return new Keccak(576, 1024, 0x06, 512, options)
- case 'shake128': return new Shake(1344, 256, 0x1f, options)
- case 'shake256': return new Shake(1088, 512, 0x1f, options)
- default: throw new Error('Invald algorithm: ' + algorithm)
- }
- }
- }
- },{"./keccak":38,"./shake":39}],38:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var Transform = require('stream').Transform
- var inherits = require('inherits')
- module.exports = function (KeccakState) {
- function Keccak (rate, capacity, delimitedSuffix, hashBitLength, options) {
- Transform.call(this, options)
- this._rate = rate
- this._capacity = capacity
- this._delimitedSuffix = delimitedSuffix
- this._hashBitLength = hashBitLength
- this._options = options
- this._state = new KeccakState()
- this._state.initialize(rate, capacity)
- this._finalized = false
- }
- inherits(Keccak, Transform)
- Keccak.prototype._transform = function (chunk, encoding, callback) {
- var error = null
- try {
- this.update(chunk, encoding)
- } catch (err) {
- error = err
- }
- callback(error)
- }
- Keccak.prototype._flush = function (callback) {
- var error = null
- try {
- this.push(this.digest())
- } catch (err) {
- error = err
- }
- callback(error)
- }
- Keccak.prototype.update = function (data, encoding) {
- if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
- if (this._finalized) throw new Error('Digest already called')
- if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
- this._state.absorb(data)
- return this
- }
- Keccak.prototype.digest = function (encoding) {
- if (this._finalized) throw new Error('Digest already called')
- this._finalized = true
- if (this._delimitedSuffix) this._state.absorbLastFewBits(this._delimitedSuffix)
- var digest = this._state.squeeze(this._hashBitLength / 8)
- if (encoding !== undefined) digest = digest.toString(encoding)
- this._resetState()
- return digest
- }
- // remove result from memory
- Keccak.prototype._resetState = function () {
- this._state.initialize(this._rate, this._capacity)
- return this
- }
- // because sometimes we need hash right now and little later
- Keccak.prototype._clone = function () {
- var clone = new Keccak(this._rate, this._capacity, this._delimitedSuffix, this._hashBitLength, this._options)
- this._state.copy(clone._state)
- clone._finalized = this._finalized
- return clone
- }
- return Keccak
- }
- }).call(this,require("buffer").Buffer)
- },{"buffer":65,"inherits":34,"stream":85}],39:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var Transform = require('stream').Transform
- var inherits = require('inherits')
- module.exports = function (KeccakState) {
- function Shake (rate, capacity, delimitedSuffix, options) {
- Transform.call(this, options)
- this._rate = rate
- this._capacity = capacity
- this._delimitedSuffix = delimitedSuffix
- this._options = options
- this._state = new KeccakState()
- this._state.initialize(rate, capacity)
- this._finalized = false
- }
- inherits(Shake, Transform)
- Shake.prototype._transform = function (chunk, encoding, callback) {
- var error = null
- try {
- this.update(chunk, encoding)
- } catch (err) {
- error = err
- }
- callback(error)
- }
- Shake.prototype._flush = function () {}
- Shake.prototype._read = function (size) {
- this.push(this.squeeze(size))
- }
- Shake.prototype.update = function (data, encoding) {
- if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
- if (this._finalized) throw new Error('Squeeze already called')
- if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
- this._state.absorb(data)
- return this
- }
- Shake.prototype.squeeze = function (dataByteLength, encoding) {
- if (!this._finalized) {
- this._finalized = true
- this._state.absorbLastFewBits(this._delimitedSuffix)
- }
- var data = this._state.squeeze(dataByteLength)
- if (encoding !== undefined) data = data.toString(encoding)
- return data
- }
- Shake.prototype._resetState = function () {
- this._state.initialize(this._rate, this._capacity)
- return this
- }
- Shake.prototype._clone = function () {
- var clone = new Shake(this._rate, this._capacity, this._delimitedSuffix, this._options)
- this._state.copy(clone._state)
- clone._finalized = this._finalized
- return clone
- }
- return Shake
- }
- }).call(this,require("buffer").Buffer)
- },{"buffer":65,"inherits":34,"stream":85}],40:[function(require,module,exports){
- 'use strict'
- 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]
- exports.p1600 = function (s) {
- for (var round = 0; round < 24; ++round) {
- // theta
- var lo0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]
- var hi0 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]
- var lo1 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]
- var hi1 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]
- var lo2 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]
- var hi2 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]
- var lo3 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]
- var hi3 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]
- var lo4 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]
- var hi4 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]
- var lo = lo4 ^ (lo1 << 1 | hi1 >>> 31)
- var hi = hi4 ^ (hi1 << 1 | lo1 >>> 31)
- var t1slo0 = s[0] ^ lo
- var t1shi0 = s[1] ^ hi
- var t1slo5 = s[10] ^ lo
- var t1shi5 = s[11] ^ hi
- var t1slo10 = s[20] ^ lo
- var t1shi10 = s[21] ^ hi
- var t1slo15 = s[30] ^ lo
- var t1shi15 = s[31] ^ hi
- var t1slo20 = s[40] ^ lo
- var t1shi20 = s[41] ^ hi
- lo = lo0 ^ (lo2 << 1 | hi2 >>> 31)
- hi = hi0 ^ (hi2 << 1 | lo2 >>> 31)
- var t1slo1 = s[2] ^ lo
- var t1shi1 = s[3] ^ hi
- var t1slo6 = s[12] ^ lo
- var t1shi6 = s[13] ^ hi
- var t1slo11 = s[22] ^ lo
- var t1shi11 = s[23] ^ hi
- var t1slo16 = s[32] ^ lo
- var t1shi16 = s[33] ^ hi
- var t1slo21 = s[42] ^ lo
- var t1shi21 = s[43] ^ hi
- lo = lo1 ^ (lo3 << 1 | hi3 >>> 31)
- hi = hi1 ^ (hi3 << 1 | lo3 >>> 31)
- var t1slo2 = s[4] ^ lo
- var t1shi2 = s[5] ^ hi
- var t1slo7 = s[14] ^ lo
- var t1shi7 = s[15] ^ hi
- var t1slo12 = s[24] ^ lo
- var t1shi12 = s[25] ^ hi
- var t1slo17 = s[34] ^ lo
- var t1shi17 = s[35] ^ hi
- var t1slo22 = s[44] ^ lo
- var t1shi22 = s[45] ^ hi
- lo = lo2 ^ (lo4 << 1 | hi4 >>> 31)
- hi = hi2 ^ (hi4 << 1 | lo4 >>> 31)
- var t1slo3 = s[6] ^ lo
- var t1shi3 = s[7] ^ hi
- var t1slo8 = s[16] ^ lo
- var t1shi8 = s[17] ^ hi
- var t1slo13 = s[26] ^ lo
- var t1shi13 = s[27] ^ hi
- var t1slo18 = s[36] ^ lo
- var t1shi18 = s[37] ^ hi
- var t1slo23 = s[46] ^ lo
- var t1shi23 = s[47] ^ hi
- lo = lo3 ^ (lo0 << 1 | hi0 >>> 31)
- hi = hi3 ^ (hi0 << 1 | lo0 >>> 31)
- var t1slo4 = s[8] ^ lo
- var t1shi4 = s[9] ^ hi
- var t1slo9 = s[18] ^ lo
- var t1shi9 = s[19] ^ hi
- var t1slo14 = s[28] ^ lo
- var t1shi14 = s[29] ^ hi
- var t1slo19 = s[38] ^ lo
- var t1shi19 = s[39] ^ hi
- var t1slo24 = s[48] ^ lo
- var t1shi24 = s[49] ^ hi
- // rho & pi
- var t2slo0 = t1slo0
- var t2shi0 = t1shi0
- var t2slo16 = (t1shi5 << 4 | t1slo5 >>> 28)
- var t2shi16 = (t1slo5 << 4 | t1shi5 >>> 28)
- var t2slo7 = (t1slo10 << 3 | t1shi10 >>> 29)
- var t2shi7 = (t1shi10 << 3 | t1slo10 >>> 29)
- var t2slo23 = (t1shi15 << 9 | t1slo15 >>> 23)
- var t2shi23 = (t1slo15 << 9 | t1shi15 >>> 23)
- var t2slo14 = (t1slo20 << 18 | t1shi20 >>> 14)
- var t2shi14 = (t1shi20 << 18 | t1slo20 >>> 14)
- var t2slo10 = (t1slo1 << 1 | t1shi1 >>> 31)
- var t2shi10 = (t1shi1 << 1 | t1slo1 >>> 31)
- var t2slo1 = (t1shi6 << 12 | t1slo6 >>> 20)
- var t2shi1 = (t1slo6 << 12 | t1shi6 >>> 20)
- var t2slo17 = (t1slo11 << 10 | t1shi11 >>> 22)
- var t2shi17 = (t1shi11 << 10 | t1slo11 >>> 22)
- var t2slo8 = (t1shi16 << 13 | t1slo16 >>> 19)
- var t2shi8 = (t1slo16 << 13 | t1shi16 >>> 19)
- var t2slo24 = (t1slo21 << 2 | t1shi21 >>> 30)
- var t2shi24 = (t1shi21 << 2 | t1slo21 >>> 30)
- var t2slo20 = (t1shi2 << 30 | t1slo2 >>> 2)
- var t2shi20 = (t1slo2 << 30 | t1shi2 >>> 2)
- var t2slo11 = (t1slo7 << 6 | t1shi7 >>> 26)
- var t2shi11 = (t1shi7 << 6 | t1slo7 >>> 26)
- var t2slo2 = (t1shi12 << 11 | t1slo12 >>> 21)
- var t2shi2 = (t1slo12 << 11 | t1shi12 >>> 21)
- var t2slo18 = (t1slo17 << 15 | t1shi17 >>> 17)
- var t2shi18 = (t1shi17 << 15 | t1slo17 >>> 17)
- var t2slo9 = (t1shi22 << 29 | t1slo22 >>> 3)
- var t2shi9 = (t1slo22 << 29 | t1shi22 >>> 3)
- var t2slo5 = (t1slo3 << 28 | t1shi3 >>> 4)
- var t2shi5 = (t1shi3 << 28 | t1slo3 >>> 4)
- var t2slo21 = (t1shi8 << 23 | t1slo8 >>> 9)
- var t2shi21 = (t1slo8 << 23 | t1shi8 >>> 9)
- var t2slo12 = (t1slo13 << 25 | t1shi13 >>> 7)
- var t2shi12 = (t1shi13 << 25 | t1slo13 >>> 7)
- var t2slo3 = (t1slo18 << 21 | t1shi18 >>> 11)
- var t2shi3 = (t1shi18 << 21 | t1slo18 >>> 11)
- var t2slo19 = (t1shi23 << 24 | t1slo23 >>> 8)
- var t2shi19 = (t1slo23 << 24 | t1shi23 >>> 8)
- var t2slo15 = (t1slo4 << 27 | t1shi4 >>> 5)
- var t2shi15 = (t1shi4 << 27 | t1slo4 >>> 5)
- var t2slo6 = (t1slo9 << 20 | t1shi9 >>> 12)
- var t2shi6 = (t1shi9 << 20 | t1slo9 >>> 12)
- var t2slo22 = (t1shi14 << 7 | t1slo14 >>> 25)
- var t2shi22 = (t1slo14 << 7 | t1shi14 >>> 25)
- var t2slo13 = (t1slo19 << 8 | t1shi19 >>> 24)
- var t2shi13 = (t1shi19 << 8 | t1slo19 >>> 24)
- var t2slo4 = (t1slo24 << 14 | t1shi24 >>> 18)
- var t2shi4 = (t1shi24 << 14 | t1slo24 >>> 18)
- // chi
- s[0] = t2slo0 ^ (~t2slo1 & t2slo2)
- s[1] = t2shi0 ^ (~t2shi1 & t2shi2)
- s[10] = t2slo5 ^ (~t2slo6 & t2slo7)
- s[11] = t2shi5 ^ (~t2shi6 & t2shi7)
- s[20] = t2slo10 ^ (~t2slo11 & t2slo12)
- s[21] = t2shi10 ^ (~t2shi11 & t2shi12)
- s[30] = t2slo15 ^ (~t2slo16 & t2slo17)
- s[31] = t2shi15 ^ (~t2shi16 & t2shi17)
- s[40] = t2slo20 ^ (~t2slo21 & t2slo22)
- s[41] = t2shi20 ^ (~t2shi21 & t2shi22)
- s[2] = t2slo1 ^ (~t2slo2 & t2slo3)
- s[3] = t2shi1 ^ (~t2shi2 & t2shi3)
- s[12] = t2slo6 ^ (~t2slo7 & t2slo8)
- s[13] = t2shi6 ^ (~t2shi7 & t2shi8)
- s[22] = t2slo11 ^ (~t2slo12 & t2slo13)
- s[23] = t2shi11 ^ (~t2shi12 & t2shi13)
- s[32] = t2slo16 ^ (~t2slo17 & t2slo18)
- s[33] = t2shi16 ^ (~t2shi17 & t2shi18)
- s[42] = t2slo21 ^ (~t2slo22 & t2slo23)
- s[43] = t2shi21 ^ (~t2shi22 & t2shi23)
- s[4] = t2slo2 ^ (~t2slo3 & t2slo4)
- s[5] = t2shi2 ^ (~t2shi3 & t2shi4)
- s[14] = t2slo7 ^ (~t2slo8 & t2slo9)
- s[15] = t2shi7 ^ (~t2shi8 & t2shi9)
- s[24] = t2slo12 ^ (~t2slo13 & t2slo14)
- s[25] = t2shi12 ^ (~t2shi13 & t2shi14)
- s[34] = t2slo17 ^ (~t2slo18 & t2slo19)
- s[35] = t2shi17 ^ (~t2shi18 & t2shi19)
- s[44] = t2slo22 ^ (~t2slo23 & t2slo24)
- s[45] = t2shi22 ^ (~t2shi23 & t2shi24)
- s[6] = t2slo3 ^ (~t2slo4 & t2slo0)
- s[7] = t2shi3 ^ (~t2shi4 & t2shi0)
- s[16] = t2slo8 ^ (~t2slo9 & t2slo5)
- s[17] = t2shi8 ^ (~t2shi9 & t2shi5)
- s[26] = t2slo13 ^ (~t2slo14 & t2slo10)
- s[27] = t2shi13 ^ (~t2shi14 & t2shi10)
- s[36] = t2slo18 ^ (~t2slo19 & t2slo15)
- s[37] = t2shi18 ^ (~t2shi19 & t2shi15)
- s[46] = t2slo23 ^ (~t2slo24 & t2slo20)
- s[47] = t2shi23 ^ (~t2shi24 & t2shi20)
- s[8] = t2slo4 ^ (~t2slo0 & t2slo1)
- s[9] = t2shi4 ^ (~t2shi0 & t2shi1)
- s[18] = t2slo9 ^ (~t2slo5 & t2slo6)
- s[19] = t2shi9 ^ (~t2shi5 & t2shi6)
- s[28] = t2slo14 ^ (~t2slo10 & t2slo11)
- s[29] = t2shi14 ^ (~t2shi10 & t2shi11)
- s[38] = t2slo19 ^ (~t2slo15 & t2slo16)
- s[39] = t2shi19 ^ (~t2shi15 & t2shi16)
- s[48] = t2slo24 ^ (~t2slo20 & t2slo21)
- s[49] = t2shi24 ^ (~t2shi20 & t2shi21)
- // iota
- s[0] ^= P1600_ROUND_CONSTANTS[round * 2]
- s[1] ^= P1600_ROUND_CONSTANTS[round * 2 + 1]
- }
- }
- },{}],41:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var keccakState = require('./keccak-state-unroll')
- function Keccak () {
- // much faster than `new Array(50)`
- this.state = [
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0
- ]
- this.blockSize = null
- this.count = 0
- this.squeezing = false
- }
- Keccak.prototype.initialize = function (rate, capacity) {
- for (var i = 0; i < 50; ++i) this.state[i] = 0
- this.blockSize = rate / 8
- this.count = 0
- this.squeezing = false
- }
- Keccak.prototype.absorb = function (data) {
- for (var i = 0; i < data.length; ++i) {
- this.state[~~(this.count / 4)] ^= data[i] << (8 * (this.count % 4))
- this.count += 1
- if (this.count === this.blockSize) {
- keccakState.p1600(this.state)
- this.count = 0
- }
- }
- }
- Keccak.prototype.absorbLastFewBits = function (bits) {
- this.state[~~(this.count / 4)] ^= bits << (8 * (this.count % 4))
- if ((bits & 0x80) !== 0 && this.count === (this.blockSize - 1)) keccakState.p1600(this.state)
- this.state[~~((this.blockSize - 1) / 4)] ^= 0x80 << (8 * ((this.blockSize - 1) % 4))
- keccakState.p1600(this.state)
- this.count = 0
- this.squeezing = true
- }
- Keccak.prototype.squeeze = function (length) {
- if (!this.squeezing) this.absorbLastFewBits(0x01)
- var output = new Buffer(length)
- for (var i = 0; i < length; ++i) {
- output[i] = (this.state[~~(this.count / 4)] >>> (8 * (this.count % 4))) & 0xff
- this.count += 1
- if (this.count === this.blockSize) {
- keccakState.p1600(this.state)
- this.count = 0
- }
- }
- return output
- }
- Keccak.prototype.copy = function (dest) {
- for (var i = 0; i < 50; ++i) dest.state[i] = this.state[i]
- dest.blockSize = this.blockSize
- dest.count = this.count
- dest.squeezing = this.squeezing
- }
- module.exports = Keccak
- }).call(this,require("buffer").Buffer)
- },{"./keccak-state-unroll":40,"buffer":65}],42:[function(require,module,exports){
- module.exports = assert;
- function assert(val, msg) {
- if (!val)
- throw new Error(msg || 'Assertion failed');
- }
- assert.equal = function assertEqual(l, r, msg) {
- if (l != r)
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
- };
- },{}],43:[function(require,module,exports){
- 'use strict';
- var utils = exports;
- function toArray(msg, enc) {
- if (Array.isArray(msg))
- return msg.slice();
- if (!msg)
- return [];
- var res = [];
- if (typeof msg !== 'string') {
- for (var i = 0; i < msg.length; i++)
- res[i] = msg[i] | 0;
- return res;
- }
- if (enc === 'hex') {
- msg = msg.replace(/[^a-z0-9]+/ig, '');
- if (msg.length % 2 !== 0)
- msg = '0' + msg;
- for (var i = 0; i < msg.length; i += 2)
- res.push(parseInt(msg[i] + msg[i + 1], 16));
- } else {
- for (var i = 0; i < msg.length; i++) {
- var c = msg.charCodeAt(i);
- var hi = c >> 8;
- var lo = c & 0xff;
- if (hi)
- res.push(hi, lo);
- else
- res.push(lo);
- }
- }
- return res;
- }
- utils.toArray = toArray;
- function zero2(word) {
- if (word.length === 1)
- return '0' + word;
- else
- return word;
- }
- utils.zero2 = zero2;
- function toHex(msg) {
- var res = '';
- for (var i = 0; i < msg.length; i++)
- res += zero2(msg[i].toString(16));
- return res;
- }
- utils.toHex = toHex;
- utils.encode = function encode(arr, enc) {
- if (enc === 'hex')
- return toHex(arr);
- else
- return arr;
- };
- },{}],44:[function(require,module,exports){
- (function (Buffer){
- /*
- CryptoJS v3.1.2
- code.google.com/p/crypto-js
- (c) 2009-2013 by Jeff Mott. All rights reserved.
- code.google.com/p/crypto-js/wiki/License
- */
- /** @preserve
- (c) 2012 by Cédric Mesnil. All rights reserved.
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- - 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.
- 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.
- */
- // constants table
- var zl = [
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
- 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
- 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
- 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
- ]
- var zr = [
- 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
- 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
- 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
- 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
- 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
- ]
- var sl = [
- 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
- 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
- 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
- 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
- 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
- ]
- var sr = [
- 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
- 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
- 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
- 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
- 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
- ]
- var hl = [0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]
- var hr = [0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]
- function bytesToWords (bytes) {
- var words = []
- for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
- words[b >>> 5] |= bytes[i] << (24 - b % 32)
- }
- return words
- }
- function wordsToBytes (words) {
- var bytes = []
- for (var b = 0; b < words.length * 32; b += 8) {
- bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF)
- }
- return bytes
- }
- function processBlock (H, M, offset) {
- // swap endian
- for (var i = 0; i < 16; i++) {
- var offset_i = offset + i
- var M_offset_i = M[offset_i]
- // Swap
- M[offset_i] = (
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
- )
- }
- // Working variables
- var al, bl, cl, dl, el
- var ar, br, cr, dr, er
- ar = al = H[0]
- br = bl = H[1]
- cr = cl = H[2]
- dr = dl = H[3]
- er = el = H[4]
- // computation
- var t
- for (i = 0; i < 80; i += 1) {
- t = (al + M[offset + zl[i]]) | 0
- if (i < 16) {
- t += f1(bl, cl, dl) + hl[0]
- } else if (i < 32) {
- t += f2(bl, cl, dl) + hl[1]
- } else if (i < 48) {
- t += f3(bl, cl, dl) + hl[2]
- } else if (i < 64) {
- t += f4(bl, cl, dl) + hl[3]
- } else {// if (i<80) {
- t += f5(bl, cl, dl) + hl[4]
- }
- t = t | 0
- t = rotl(t, sl[i])
- t = (t + el) | 0
- al = el
- el = dl
- dl = rotl(cl, 10)
- cl = bl
- bl = t
- t = (ar + M[offset + zr[i]]) | 0
- if (i < 16) {
- t += f5(br, cr, dr) + hr[0]
- } else if (i < 32) {
- t += f4(br, cr, dr) + hr[1]
- } else if (i < 48) {
- t += f3(br, cr, dr) + hr[2]
- } else if (i < 64) {
- t += f2(br, cr, dr) + hr[3]
- } else {// if (i<80) {
- t += f1(br, cr, dr) + hr[4]
- }
- t = t | 0
- t = rotl(t, sr[i])
- t = (t + er) | 0
- ar = er
- er = dr
- dr = rotl(cr, 10)
- cr = br
- br = t
- }
- // intermediate hash value
- t = (H[1] + cl + dr) | 0
- H[1] = (H[2] + dl + er) | 0
- H[2] = (H[3] + el + ar) | 0
- H[3] = (H[4] + al + br) | 0
- H[4] = (H[0] + bl + cr) | 0
- H[0] = t
- }
- function f1 (x, y, z) {
- return ((x) ^ (y) ^ (z))
- }
- function f2 (x, y, z) {
- return (((x) & (y)) | ((~x) & (z)))
- }
- function f3 (x, y, z) {
- return (((x) | (~(y))) ^ (z))
- }
- function f4 (x, y, z) {
- return (((x) & (z)) | ((y) & (~(z))))
- }
- function f5 (x, y, z) {
- return ((x) ^ ((y) | (~(z))))
- }
- function rotl (x, n) {
- return (x << n) | (x >>> (32 - n))
- }
- function ripemd160 (message) {
- var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]
- if (typeof message === 'string') {
- message = new Buffer(message, 'utf8')
- }
- var m = bytesToWords(message)
- var nBitsLeft = message.length * 8
- var nBitsTotal = message.length * 8
- // Add padding
- m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32)
- m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
- (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
- (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
- )
- for (var i = 0; i < m.length; i += 16) {
- processBlock(H, m, i)
- }
- // swap endian
- for (i = 0; i < 5; i++) {
- // shortcut
- var H_i = H[i]
- // Swap
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00)
- }
- var digestbytes = wordsToBytes(H)
- return new Buffer(digestbytes)
- }
- module.exports = ripemd160
- }).call(this,require("buffer").Buffer)
- },{"buffer":65}],45:[function(require,module,exports){
- (function (Buffer){
- const assert = require('assert')
- /**
- * RLP Encoding based on: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP
- * This function takes in a data, convert it to buffer if not, and a length for recursion
- *
- * @param {Buffer,String,Integer,Array} data - will be converted to buffer
- * @returns {Buffer} - returns buffer of encoded data
- **/
- exports.encode = function (input) {
- if (input instanceof Array) {
- var output = []
- for (var i = 0; i < input.length; i++) {
- output.push(exports.encode(input[i]))
- }
- var buf = Buffer.concat(output)
- return Buffer.concat([encodeLength(buf.length, 192), buf])
- } else {
- input = toBuffer(input)
- if (input.length === 1 && input[0] < 128) {
- return input
- } else {
- return Buffer.concat([encodeLength(input.length, 128), input])
- }
- }
- }
- function safeParseInt (v, base) {
- if (v.slice(0, 2) === '00') {
- throw (new Error('invalid RLP: extra zeros'))
- }
- return parseInt(v, base)
- }
- function encodeLength (len, offset) {
- if (len < 56) {
- return new Buffer([len + offset])
- } else {
- var hexLength = intToHex(len)
- var lLength = hexLength.length / 2
- var firstByte = intToHex(offset + 55 + lLength)
- return new Buffer(firstByte + hexLength, 'hex')
- }
- }
- /**
- * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP}
- * @param {Buffer,String,Integer,Array} data - will be converted to buffer
- * @returns {Array} - returns decode Array of Buffers containg the original message
- **/
- exports.decode = function (input, stream) {
- if (!input || input.length === 0) {
- return new Buffer([])
- }
- input = toBuffer(input)
- var decoded = _decode(input)
- if (stream) {
- return decoded
- }
- assert.equal(decoded.remainder.length, 0, 'invalid remainder')
- return decoded.data
- }
- exports.getLength = function (input) {
- if (!input || input.length === 0) {
- return new Buffer([])
- }
- input = toBuffer(input)
- var firstByte = input[0]
- if (firstByte <= 0x7f) {
- return input.length
- } else if (firstByte <= 0xb7) {
- return firstByte - 0x7f
- } else if (firstByte <= 0xbf) {
- return firstByte - 0xb6
- } else if (firstByte <= 0xf7) {
- // a list between 0-55 bytes long
- return firstByte - 0xbf
- } else {
- // a list over 55 bytes long
- var llength = firstByte - 0xf6
- var length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
- return llength + length
- }
- }
- function _decode (input) {
- var length, llength, data, innerRemainder, d
- var decoded = []
- var firstByte = input[0]
- if (firstByte <= 0x7f) {
- // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding.
- return {
- data: input.slice(0, 1),
- remainder: input.slice(1)
- }
- } else if (firstByte <= 0xb7) {
- // string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string
- // The range of the first byte is [0x80, 0xb7]
- length = firstByte - 0x7f
- // set 0x80 null to 0
- if (firstByte === 0x80) {
- data = new Buffer([])
- } else {
- data = input.slice(1, length)
- }
- if (length === 2 && data[0] < 0x80) {
- throw new Error('invalid rlp encoding: byte must be less 0x80')
- }
- return {
- data: data,
- remainder: input.slice(length)
- }
- } else if (firstByte <= 0xbf) {
- llength = firstByte - 0xb6
- length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
- data = input.slice(llength, length + llength)
- if (data.length < length) {
- throw (new Error('invalid RLP'))
- }
- return {
- data: data,
- remainder: input.slice(length + llength)
- }
- } else if (firstByte <= 0xf7) {
- // a list between 0-55 bytes long
- length = firstByte - 0xbf
- innerRemainder = input.slice(1, length)
- while (innerRemainder.length) {
- d = _decode(innerRemainder)
- decoded.push(d.data)
- innerRemainder = d.remainder
- }
- return {
- data: decoded,
- remainder: input.slice(length)
- }
- } else {
- // a list over 55 bytes long
- llength = firstByte - 0xf6
- length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
- var totalLength = llength + length
- if (totalLength > input.length) {
- throw new Error('invalid rlp: total length is larger than the data')
- }
- innerRemainder = input.slice(llength, totalLength)
- if (innerRemainder.length === 0) {
- throw new Error('invalid rlp, List has a invalid length')
- }
- while (innerRemainder.length) {
- d = _decode(innerRemainder)
- decoded.push(d.data)
- innerRemainder = d.remainder
- }
- return {
- data: decoded,
- remainder: input.slice(totalLength)
- }
- }
- }
- function isHexPrefixed (str) {
- return str.slice(0, 2) === '0x'
- }
- // Removes 0x from a given String
- function stripHexPrefix (str) {
- if (typeof str !== 'string') {
- return str
- }
- return isHexPrefixed(str) ? str.slice(2) : str
- }
- function intToHex (i) {
- var hex = i.toString(16)
- if (hex.length % 2) {
- hex = '0' + hex
- }
- return hex
- }
- function padToEven (a) {
- if (a.length % 2) a = '0' + a
- return a
- }
- function intToBuffer (i) {
- var hex = intToHex(i)
- return new Buffer(hex, 'hex')
- }
- function toBuffer (v) {
- if (!Buffer.isBuffer(v)) {
- if (typeof v === 'string') {
- if (isHexPrefixed(v)) {
- v = new Buffer(padToEven(stripHexPrefix(v)), 'hex')
- } else {
- v = new Buffer(v)
- }
- } else if (typeof v === 'number') {
- if (!v) {
- v = new Buffer([])
- } else {
- v = intToBuffer(v)
- }
- } else if (v === null || v === undefined) {
- v = new Buffer([])
- } else if (v.toArray) {
- // converts a BN to a Buffer
- v = new Buffer(v.toArray())
- } else {
- throw new Error('invalid type')
- }
- }
- return v
- }
- }).call(this,require("buffer").Buffer)
- },{"assert":61,"buffer":65}],46:[function(require,module,exports){
- 'use strict'
- module.exports = require('./lib')(require('./lib/elliptic'))
- },{"./lib":50,"./lib/elliptic":49}],47:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var toString = Object.prototype.toString
- // TypeError
- exports.isArray = function (value, message) {
- if (!Array.isArray(value)) throw TypeError(message)
- }
- exports.isBoolean = function (value, message) {
- if (toString.call(value) !== '[object Boolean]') throw TypeError(message)
- }
- exports.isBuffer = function (value, message) {
- if (!Buffer.isBuffer(value)) throw TypeError(message)
- }
- exports.isFunction = function (value, message) {
- if (toString.call(value) !== '[object Function]') throw TypeError(message)
- }
- exports.isNumber = function (value, message) {
- if (toString.call(value) !== '[object Number]') throw TypeError(message)
- }
- exports.isObject = function (value, message) {
- if (toString.call(value) !== '[object Object]') throw TypeError(message)
- }
- // RangeError
- exports.isBufferLength = function (buffer, length, message) {
- if (buffer.length !== length) throw RangeError(message)
- }
- exports.isBufferLength2 = function (buffer, length1, length2, message) {
- if (buffer.length !== length1 && buffer.length !== length2) throw RangeError(message)
- }
- exports.isLengthGTZero = function (value, message) {
- if (value.length === 0) throw RangeError(message)
- }
- exports.isNumberInInterval = function (number, x, y, message) {
- if (number <= x || number >= y) throw RangeError(message)
- }
- }).call(this,{"isBuffer":require("../../../../../../../../../usr/lib/node_modules/browserify/node_modules/is-buffer/index.js")})
- },{"../../../../../../../../../usr/lib/node_modules/browserify/node_modules/is-buffer/index.js":70}],48:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var bip66 = require('bip66')
- var EC_PRIVKEY_EXPORT_DER_COMPRESSED = new Buffer([
- // begin
- 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20,
- // private key
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- // middle
- 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
- 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
- 0x21, 0x02, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
- 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
- 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
- 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x24, 0x03, 0x22, 0x00,
- // public key
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00
- ])
- var EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED = new Buffer([
- // begin
- 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20,
- // private key
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- // middle
- 0xa0, 0x81, 0xa5, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
- 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
- 0x41, 0x04, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
- 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
- 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0E, 0x11,
- 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10,
- 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
- 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00,
- // public key
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00
- ])
- var ZERO_BUFFER_32 = new Buffer([
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- ])
- exports.privateKeyExport = function (privateKey, publicKey, compressed) {
- var result = new Buffer(compressed ? EC_PRIVKEY_EXPORT_DER_COMPRESSED : EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED)
- privateKey.copy(result, compressed ? 8 : 9)
- publicKey.copy(result, compressed ? 181 : 214)
- return result
- }
- exports.privateKeyImport = function (privateKey) {
- var length = privateKey.length
- // sequence header
- var index = 0
- if (length < index + 1 || privateKey[index] !== 0x30) return
- index += 1
- // sequence length constructor
- if (length < index + 1 || !(privateKey[index] & 0x80)) return
- var lenb = privateKey[index] & 0x7f
- index += 1
- if (lenb < 1 || lenb > 2) return
- if (length < index + lenb) return
- // sequence length
- var len = privateKey[index + lenb - 1] | (lenb > 1 ? privateKey[index + lenb - 2] << 8 : 0)
- index += lenb
- if (length < index + len) return
- // sequence element 0: version number (=1)
- if (length < index + 3 ||
- privateKey[index] !== 0x02 ||
- privateKey[index + 1] !== 0x01 ||
- privateKey[index + 2] !== 0x01) {
- return
- }
- index += 3
- // sequence element 1: octet string, up to 32 bytes
- if (length < index + 2 ||
- privateKey[index] !== 0x04 ||
- privateKey[index + 1] > 0x20 ||
- length < index + 2 + privateKey[index + 1]) {
- return
- }
- return privateKey.slice(index + 2, index + 2 + privateKey[index + 1])
- }
- exports.signatureExport = function (sigObj) {
- var r = Buffer.concat([new Buffer([0]), sigObj.r])
- for (var lenR = 33, posR = 0; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR);
- var s = Buffer.concat([new Buffer([0]), sigObj.s])
- for (var lenS = 33, posS = 0; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS);
- return bip66.encode(r.slice(posR), s.slice(posS))
- }
- exports.signatureImport = function (sig) {
- var r = new Buffer(ZERO_BUFFER_32)
- var s = new Buffer(ZERO_BUFFER_32)
- try {
- var sigObj = bip66.decode(sig)
- if (sigObj.r.length === 33 && sigObj.r[0] === 0x00) sigObj.r = sigObj.r.slice(1)
- if (sigObj.r.length > 32) throw new Error('R length is too long')
- if (sigObj.s.length === 33 && sigObj.s[0] === 0x00) sigObj.s = sigObj.s.slice(1)
- if (sigObj.s.length > 32) throw new Error('S length is too long')
- } catch (err) {
- return
- }
- sigObj.r.copy(r, 32 - sigObj.r.length)
- sigObj.s.copy(s, 32 - sigObj.s.length)
- return { r: r, s: s }
- }
- exports.signatureImportLax = function (sig) {
- var r = new Buffer(ZERO_BUFFER_32)
- var s = new Buffer(ZERO_BUFFER_32)
- var length = sig.length
- var index = 0
- // sequence tag byte
- if (sig[index++] !== 0x30) return
- // sequence length byte
- var lenbyte = sig[index++]
- if (lenbyte & 0x80) {
- index += lenbyte - 0x80
- if (index > length) return
- }
- // sequence tag byte for r
- if (sig[index++] !== 0x02) return
- // length for r
- var rlen = sig[index++]
- if (rlen & 0x80) {
- lenbyte = rlen - 0x80
- if (index + lenbyte > length) return
- for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
- for (rlen = 0; lenbyte > 0; index += 1, lenbyte -= 1) rlen = (rlen << 8) + sig[index]
- }
- if (rlen > length - index) return
- var rindex = index
- index += rlen
- // sequence tag byte for s
- if (sig[index++] !== 0x02) return
- // length for s
- var slen = sig[index++]
- if (slen & 0x80) {
- lenbyte = slen - 0x80
- if (index + lenbyte > length) return
- for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
- for (slen = 0; lenbyte > 0; index += 1, lenbyte -= 1) slen = (slen << 8) + sig[index]
- }
- if (slen > length - index) return
- var sindex = index
- index += slen
- // ignore leading zeros in r
- for (; rlen > 0 && sig[rindex] === 0x00; rlen -= 1, rindex += 1);
- // copy r value
- if (rlen > 32) return
- var rvalue = sig.slice(rindex, rindex + rlen)
- rvalue.copy(r, 32 - rvalue.length)
- // ignore leading zeros in s
- for (; slen > 0 && sig[sindex] === 0x00; slen -= 1, sindex += 1);
- // copy s value
- if (slen > 32) return
- var svalue = sig.slice(sindex, sindex + slen)
- svalue.copy(s, 32 - svalue.length)
- return { r: r, s: s }
- }
- }).call(this,require("buffer").Buffer)
- },{"bip66":3,"buffer":65}],49:[function(require,module,exports){
- (function (Buffer){
- 'use strict'
- var createHash = require('create-hash')
- var BN = require('bn.js')
- var EC = require('elliptic').ec
- var messages = require('../messages.json')
- var ec = new EC('secp256k1')
- var ecparams = ec.curve
- function loadCompressedPublicKey (first, xBuffer) {
- var x = new BN(xBuffer)
- // overflow
- if (x.cmp(ecparams.p) >= 0) return null
- x = x.toRed(ecparams.red)
- // compute corresponding Y
- var y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt()
- if ((first === 0x03) !== y.isOdd()) y = y.redNeg()
- return ec.keyPair({ pub: { x: x, y: y } })
- }
- function loadUncompressedPublicKey (first, xBuffer, yBuffer) {
- var x = new BN(xBuffer)
- var y = new BN(yBuffer)
- // overflow
- if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null
- x = x.toRed(ecparams.red)
- y = y.toRed(ecparams.red)
- // is odd flag
- if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null
- // x*x*x + b = y*y
- var x3 = x.redSqr().redIMul(x)
- if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null
- return ec.keyPair({ pub: { x: x, y: y } })
- }
- function loadPublicKey (publicKey) {
- var first = publicKey[0]
- switch (first) {
- case 0x02:
- case 0x03:
- if (publicKey.length !== 33) return null
- return loadCompressedPublicKey(first, publicKey.slice(1, 33))
- case 0x04:
- case 0x06:
- case 0x07:
- if (publicKey.length !== 65) return null
- return loadUncompressedPublicKey(first, publicKey.slice(1, 33), publicKey.slice(33, 65))
- default:
- return null
- }
- }
- exports.privateKeyVerify = function (privateKey) {
- var bn = new BN(privateKey)
- return bn.cmp(ecparams.n) < 0 && !bn.isZero()
- }
- exports.privateKeyExport = function (privateKey, compressed) {
- var d = new BN(privateKey)
- if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PRIVATE_KEY_EXPORT_DER_FAIL)
- return new Buffer(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
- }
- exports.privateKeyTweakAdd = function (privateKey, tweak) {
- var bn = new BN(tweak)
- if (bn.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
- bn.iadd(new BN(privateKey))
- if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n)
- if (bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
- return bn.toArrayLike(Buffer, 'be', 32)
- }
- exports.privateKeyTweakMul = function (privateKey, tweak) {
- var bn = new BN(tweak)
- if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_MUL_FAIL)
- bn.imul(new BN(privateKey))
- if (bn.cmp(ecparams.n)) bn = bn.umod(ecparams.n)
- return bn.toArrayLike(Buffer, 'be', 32)
- }
- exports.publicKeyCreate = function (privateKey, compressed) {
- var d = new BN(privateKey)
- if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PUBLIC_KEY_CREATE_FAIL)
- return new Buffer(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
- }
- exports.publicKeyConvert = function (publicKey, compressed) {
- var pair = loadPublicKey(publicKey)
- if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- return new Buffer(pair.getPublic(compressed, true))
- }
- exports.publicKeyVerify = function (publicKey) {
- return loadPublicKey(publicKey) !== null
- }
- exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) {
- var pair = loadPublicKey(publicKey)
- if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- tweak = new BN(tweak)
- if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL)
- return new Buffer(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed))
- }
- exports.publicKeyTweakMul = function (publicKey, tweak, compressed) {
- var pair = loadPublicKey(publicKey)
- if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- tweak = new BN(tweak)
- if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_MUL_FAIL)
- return new Buffer(pair.pub.mul(tweak).encode(true, compressed))
- }
- exports.publicKeyCombine = function (publicKeys, compressed) {
- var pairs = new Array(publicKeys.length)
- for (var i = 0; i < publicKeys.length; ++i) {
- pairs[i] = loadPublicKey(publicKeys[i])
- if (pairs[i] === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- }
- var point = pairs[0].pub
- for (var j = 1; j < pairs.length; ++j) point = point.add(pairs[j].pub)
- if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_COMBINE_FAIL)
- return new Buffer(point.encode(true, compressed))
- }
- exports.signatureNormalize = function (signature) {
- var r = new BN(signature.slice(0, 32))
- var s = new BN(signature.slice(32, 64))
- if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
- var result = new Buffer(signature)
- if (s.cmp(ec.nh) === 1) ecparams.n.sub(s).toArrayLike(Buffer, 'be', 32).copy(result, 32)
- return result
- }
- exports.signatureExport = function (signature) {
- var r = signature.slice(0, 32)
- var s = signature.slice(32, 64)
- if (new BN(r).cmp(ecparams.n) >= 0 || new BN(s).cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
- return { r: r, s: s }
- }
- exports.signatureImport = function (sigObj) {
- var r = new BN(sigObj.r)
- if (r.cmp(ecparams.n) >= 0) r = new BN(0)
- var s = new BN(sigObj.s)
- if (s.cmp(ecparams.n) >= 0) s = new BN(0)
- return Buffer.concat([
- r.toArrayLike(Buffer, 'be', 32),
- s.toArrayLike(Buffer, 'be', 32)
- ])
- }
- exports.sign = function (message, privateKey, noncefn, data) {
- if (typeof noncefn === 'function') {
- var getNonce = noncefn
- noncefn = function (counter) {
- var nonce = getNonce(message, privateKey, null, data, counter)
- if (!Buffer.isBuffer(nonce) || nonce.length !== 32) throw new Error(messages.ECDSA_SIGN_FAIL)
- return new BN(nonce)
- }
- }
- var d = new BN(privateKey)
- if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.ECDSA_SIGN_FAIL)
- var result = ec.sign(message, privateKey, { canonical: true, k: noncefn, pers: data })
- return {
- signature: Buffer.concat([
- result.r.toArrayLike(Buffer, 'be', 32),
- result.s.toArrayLike(Buffer, 'be', 32)
- ]),
- recovery: result.recoveryParam
- }
- }
- exports.verify = function (message, signature, publicKey) {
- var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
- var sigr = new BN(sigObj.r)
- var sigs = new BN(sigObj.s)
- if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
- if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return false
- var pair = loadPublicKey(publicKey)
- if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y})
- }
- exports.recover = function (message, signature, recovery, compressed) {
- var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
- var sigr = new BN(sigObj.r)
- var sigs = new BN(sigObj.s)
- if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
- try {
- if (sigr.isZero() || sigs.isZero()) throw new Error()
- var point = ec.recoverPubKey(message, sigObj, recovery)
- return new Buffer(point.encode(true, compressed))
- } catch (err) {
- throw new Error(messages.ECDSA_RECOVER_FAIL)
- }
- }
- exports.ecdh = function (publicKey, privateKey) {
- var shared = exports.ecdhUnsafe(publicKey, privateKey, true)
- return createHash('sha256').update(shared).digest()
- }
- exports.ecdhUnsafe = function (publicKey, privateKey, compressed) {
- var pair = loadPublicKey(publicKey)
- if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
- var scalar = new BN(privateKey)
- if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) throw new Error(messages.ECDH_FAIL)
- return new Buffer(pair.pub.mul(scalar).encode(true, compressed))
- }
- }).call(this,require("buffer").Buffer)
- },{"../messages.json":51,"bn.js":4,"buffer":65,"create-hash":7,"elliptic":10}],50:[function(require,module,exports){
- 'use strict'
- var assert = require('./assert')
- var der = require('./der')
- var messages = require('./messages.json')
- function initCompressedValue (value, defaultValue) {
- if (value === undefined) return defaultValue
- assert.isBoolean(value, messages.COMPRESSED_TYPE_INVALID)
- return value
- }
- module.exports = function (secp256k1) {
- return {
- privateKeyVerify: function (privateKey) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- return privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)
- },
- privateKeyExport: function (privateKey, compressed) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- var publicKey = secp256k1.privateKeyExport(privateKey, compressed)
- return der.privateKeyExport(privateKey, publicKey, compressed)
- },
- privateKeyImport: function (privateKey) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- privateKey = der.privateKeyImport(privateKey)
- if (privateKey && privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)) return privateKey
- throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL)
- },
- privateKeyTweakAdd: function (privateKey, tweak) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
- assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
- return secp256k1.privateKeyTweakAdd(privateKey, tweak)
- },
- privateKeyTweakMul: function (privateKey, tweak) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
- assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
- return secp256k1.privateKeyTweakMul(privateKey, tweak)
- },
- publicKeyCreate: function (privateKey, compressed) {
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.publicKeyCreate(privateKey, compressed)
- },
- publicKeyConvert: function (publicKey, compressed) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.publicKeyConvert(publicKey, compressed)
- },
- publicKeyVerify: function (publicKey) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- return secp256k1.publicKeyVerify(publicKey)
- },
- publicKeyTweakAdd: function (publicKey, tweak, compressed) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
- assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.publicKeyTweakAdd(publicKey, tweak, compressed)
- },
- publicKeyTweakMul: function (publicKey, tweak, compressed) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
- assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.publicKeyTweakMul(publicKey, tweak, compressed)
- },
- publicKeyCombine: function (publicKeys, compressed) {
- assert.isArray(publicKeys, messages.EC_PUBLIC_KEYS_TYPE_INVALID)
- assert.isLengthGTZero(publicKeys, messages.EC_PUBLIC_KEYS_LENGTH_INVALID)
- for (var i = 0; i < publicKeys.length; ++i) {
- assert.isBuffer(publicKeys[i], messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKeys[i], 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- }
- compressed = initCompressedValue(compressed, true)
- return secp256k1.publicKeyCombine(publicKeys, compressed)
- },
- signatureNormalize: function (signature) {
- assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- return secp256k1.signatureNormalize(signature)
- },
- signatureExport: function (signature) {
- assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- var sigObj = secp256k1.signatureExport(signature)
- return der.signatureExport(sigObj)
- },
- signatureImport: function (sig) {
- assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- var sigObj = der.signatureImport(sig)
- if (sigObj) return secp256k1.signatureImport(sigObj)
- throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
- },
- signatureImportLax: function (sig) {
- assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- var sigObj = der.signatureImportLax(sig)
- if (sigObj) return secp256k1.signatureImport(sigObj)
- throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
- },
- sign: function (message, privateKey, options) {
- assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
- assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- var data = null
- var noncefn = null
- if (options !== undefined) {
- assert.isObject(options, messages.OPTIONS_TYPE_INVALID)
- if (options.data !== undefined) {
- assert.isBuffer(options.data, messages.OPTIONS_DATA_TYPE_INVALID)
- assert.isBufferLength(options.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID)
- data = options.data
- }
- if (options.noncefn !== undefined) {
- assert.isFunction(options.noncefn, messages.OPTIONS_NONCEFN_TYPE_INVALID)
- noncefn = options.noncefn
- }
- }
- return secp256k1.sign(message, privateKey, noncefn, data)
- },
- verify: function (message, signature, publicKey) {
- assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
- assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
- assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- return secp256k1.verify(message, signature, publicKey)
- },
- recover: function (message, signature, recovery, compressed) {
- assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
- assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
- assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
- assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
- assert.isNumber(recovery, messages.RECOVERY_ID_TYPE_INVALID)
- assert.isNumberInInterval(recovery, -1, 4, messages.RECOVERY_ID_VALUE_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.recover(message, signature, recovery, compressed)
- },
- ecdh: function (publicKey, privateKey) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- return secp256k1.ecdh(publicKey, privateKey)
- },
- ecdhUnsafe: function (publicKey, privateKey, compressed) {
- assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
- assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
- assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
- assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
- compressed = initCompressedValue(compressed, true)
- return secp256k1.ecdhUnsafe(publicKey, privateKey, compressed)
- }
- }
- }
- },{"./assert":47,"./der":48,"./messages.json":51}],51:[function(require,module,exports){
- module.exports={
- "COMPRESSED_TYPE_INVALID": "compressed should be a boolean",
- "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer",
- "EC_PRIVATE_KEY_LENGTH_INVALID": "private key length is invalid",
- "EC_PRIVATE_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting private key is invalid",
- "EC_PRIVATE_KEY_TWEAK_MUL_FAIL": "tweak out of range",
- "EC_PRIVATE_KEY_EXPORT_DER_FAIL": "couldn't export to DER format",
- "EC_PRIVATE_KEY_IMPORT_DER_FAIL": "couldn't import from DER format",
- "EC_PUBLIC_KEYS_TYPE_INVALID": "public keys should be an Array",
- "EC_PUBLIC_KEYS_LENGTH_INVALID": "public keys Array should have at least 1 element",
- "EC_PUBLIC_KEY_TYPE_INVALID": "public key should be a Buffer",
- "EC_PUBLIC_KEY_LENGTH_INVALID": "public key length is invalid",
- "EC_PUBLIC_KEY_PARSE_FAIL": "the public key could not be parsed or is invalid",
- "EC_PUBLIC_KEY_CREATE_FAIL": "private was invalid, try again",
- "EC_PUBLIC_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting public key is invalid",
- "EC_PUBLIC_KEY_TWEAK_MUL_FAIL": "tweak out of range",
- "EC_PUBLIC_KEY_COMBINE_FAIL": "the sum of the public keys is not valid",
- "ECDH_FAIL": "scalar was invalid (zero or overflow)",
- "ECDSA_SIGNATURE_TYPE_INVALID": "signature should be a Buffer",
- "ECDSA_SIGNATURE_LENGTH_INVALID": "signature length is invalid",
- "ECDSA_SIGNATURE_PARSE_FAIL": "couldn't parse signature",
- "ECDSA_SIGNATURE_PARSE_DER_FAIL": "couldn't parse DER signature",
- "ECDSA_SIGNATURE_SERIALIZE_DER_FAIL": "couldn't serialize signature to DER format",
- "ECDSA_SIGN_FAIL": "nonce generation function failed or private key is invalid",
- "ECDSA_RECOVER_FAIL": "couldn't recover public key from signature",
- "MSG32_TYPE_INVALID": "message should be a Buffer",
- "MSG32_LENGTH_INVALID": "message length is invalid",
- "OPTIONS_TYPE_INVALID": "options should be an Object",
- "OPTIONS_DATA_TYPE_INVALID": "options.data should be a Buffer",
- "OPTIONS_DATA_LENGTH_INVALID": "options.data length is invalid",
- "OPTIONS_NONCEFN_TYPE_INVALID": "options.noncefn should be a Function",
- "RECOVERY_ID_TYPE_INVALID": "recovery should be a Number",
- "RECOVERY_ID_VALUE_INVALID": "recovery should have value between -1 and 4",
- "TWEAK_TYPE_INVALID": "tweak should be a Buffer",
- "TWEAK_LENGTH_INVALID": "tweak length is invalid"
- }
- },{}],52:[function(require,module,exports){
- (function (Buffer){
- // prototype class for hash functions
- function Hash (blockSize, finalSize) {
- this._block = new Buffer(blockSize)
- this._finalSize = finalSize
- this._blockSize = blockSize
- this._len = 0
- this._s = 0
- }
- Hash.prototype.update = function (data, enc) {
- if (typeof data === 'string') {
- enc = enc || 'utf8'
- data = new Buffer(data, enc)
- }
- var l = this._len += data.length
- var s = this._s || 0
- var f = 0
- var buffer = this._block
- while (s < l) {
- var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize))
- var ch = (t - f)
- for (var i = 0; i < ch; i++) {
- buffer[(s % this._blockSize) + i] = data[i + f]
- }
- s += ch
- f += ch
- if ((s % this._blockSize) === 0) {
- this._update(buffer)
- }
- }
- this._s = s
- return this
- }
- Hash.prototype.digest = function (enc) {
- // Suppose the length of the message M, in bits, is l
- var l = this._len * 8
- // Append the bit 1 to the end of the message
- this._block[this._len % this._blockSize] = 0x80
- // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize
- this._block.fill(0, this._len % this._blockSize + 1)
- if (l % (this._blockSize * 8) >= this._finalSize * 8) {
- this._update(this._block)
- this._block.fill(0)
- }
- // to this append the block which is equal to the number l written in binary
- // TODO: handle case where l is > Math.pow(2, 29)
- this._block.writeInt32BE(l, this._blockSize - 4)
- var hash = this._update(this._block) || this._hash()
- return enc ? hash.toString(enc) : hash
- }
- Hash.prototype._update = function () {
- throw new Error('_update must be implemented by subclass')
- }
- module.exports = Hash
- }).call(this,require("buffer").Buffer)
- },{"buffer":65}],53:[function(require,module,exports){
- var exports = module.exports = function SHA (algorithm) {
- algorithm = algorithm.toLowerCase()
- var Algorithm = exports[algorithm]
- if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
- return new Algorithm()
- }
- exports.sha = require('./sha')
- exports.sha1 = require('./sha1')
- exports.sha224 = require('./sha224')
- exports.sha256 = require('./sha256')
- exports.sha384 = require('./sha384')
- exports.sha512 = require('./sha512')
- },{"./sha":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha384":58,"./sha512":59}],54:[function(require,module,exports){
- (function (Buffer){
- /*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
- * in FIPS PUB 180-1
- * This source code is derived from sha1.js of the same repository.
- * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
- * operation was added.
- */
- var inherits = require('inherits')
- var Hash = require('./hash')
- var K = [
- 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
- ]
- var W = new Array(80)
- function Sha () {
- this.init()
- this._w = W
- Hash.call(this, 64, 56)
- }
- inherits(Sha, Hash)
- Sha.prototype.init = function () {
- this._a = 0x67452301
- this._b = 0xefcdab89
- this._c = 0x98badcfe
- this._d = 0x10325476
- this._e = 0xc3d2e1f0
- return this
- }
- function rotl5 (num) {
- return (num << 5) | (num >>> 27)
- }
- function rotl30 (num) {
- return (num << 30) | (num >>> 2)
- }
- function ft (s, b, c, d) {
- if (s === 0) return (b & c) | ((~b) & d)
- if (s === 2) return (b & c) | (b & d) | (c & d)
- return b ^ c ^ d
- }
- Sha.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
- for (var j = 0; j < 80; ++j) {
- var s = ~~(j / 20)
- var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
- e = d
- d = c
- c = rotl30(b)
- b = a
- a = t
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- }
- Sha.prototype._hash = function () {
- var H = new Buffer(20)
- H.writeInt32BE(this._a | 0, 0)
- H.writeInt32BE(this._b | 0, 4)
- H.writeInt32BE(this._c | 0, 8)
- H.writeInt32BE(this._d | 0, 12)
- H.writeInt32BE(this._e | 0, 16)
- return H
- }
- module.exports = Sha
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"buffer":65,"inherits":34}],55:[function(require,module,exports){
- (function (Buffer){
- /*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
- * in FIPS PUB 180-1
- * Version 2.1a Copyright Paul Johnston 2000 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for details.
- */
- var inherits = require('inherits')
- var Hash = require('./hash')
- var K = [
- 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
- ]
- var W = new Array(80)
- function Sha1 () {
- this.init()
- this._w = W
- Hash.call(this, 64, 56)
- }
- inherits(Sha1, Hash)
- Sha1.prototype.init = function () {
- this._a = 0x67452301
- this._b = 0xefcdab89
- this._c = 0x98badcfe
- this._d = 0x10325476
- this._e = 0xc3d2e1f0
- return this
- }
- function rotl1 (num) {
- return (num << 1) | (num >>> 31)
- }
- function rotl5 (num) {
- return (num << 5) | (num >>> 27)
- }
- function rotl30 (num) {
- return (num << 30) | (num >>> 2)
- }
- function ft (s, b, c, d) {
- if (s === 0) return (b & c) | ((~b) & d)
- if (s === 2) return (b & c) | (b & d) | (c & d)
- return b ^ c ^ d
- }
- Sha1.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
- for (var j = 0; j < 80; ++j) {
- var s = ~~(j / 20)
- var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
- e = d
- d = c
- c = rotl30(b)
- b = a
- a = t
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- }
- Sha1.prototype._hash = function () {
- var H = new Buffer(20)
- H.writeInt32BE(this._a | 0, 0)
- H.writeInt32BE(this._b | 0, 4)
- H.writeInt32BE(this._c | 0, 8)
- H.writeInt32BE(this._d | 0, 12)
- H.writeInt32BE(this._e | 0, 16)
- return H
- }
- module.exports = Sha1
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"buffer":65,"inherits":34}],56:[function(require,module,exports){
- (function (Buffer){
- /**
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
- * in FIPS 180-2
- * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- *
- */
- var inherits = require('inherits')
- var Sha256 = require('./sha256')
- var Hash = require('./hash')
- var W = new Array(64)
- function Sha224 () {
- this.init()
- this._w = W // new Array(64)
- Hash.call(this, 64, 56)
- }
- inherits(Sha224, Sha256)
- Sha224.prototype.init = function () {
- this._a = 0xc1059ed8
- this._b = 0x367cd507
- this._c = 0x3070dd17
- this._d = 0xf70e5939
- this._e = 0xffc00b31
- this._f = 0x68581511
- this._g = 0x64f98fa7
- this._h = 0xbefa4fa4
- return this
- }
- Sha224.prototype._hash = function () {
- var H = new Buffer(28)
- H.writeInt32BE(this._a, 0)
- H.writeInt32BE(this._b, 4)
- H.writeInt32BE(this._c, 8)
- H.writeInt32BE(this._d, 12)
- H.writeInt32BE(this._e, 16)
- H.writeInt32BE(this._f, 20)
- H.writeInt32BE(this._g, 24)
- return H
- }
- module.exports = Sha224
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"./sha256":57,"buffer":65,"inherits":34}],57:[function(require,module,exports){
- (function (Buffer){
- /**
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
- * in FIPS 180-2
- * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- *
- */
- var inherits = require('inherits')
- var Hash = require('./hash')
- var K = [
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
- ]
- var W = new Array(64)
- function Sha256 () {
- this.init()
- this._w = W // new Array(64)
- Hash.call(this, 64, 56)
- }
- inherits(Sha256, Hash)
- Sha256.prototype.init = function () {
- this._a = 0x6a09e667
- this._b = 0xbb67ae85
- this._c = 0x3c6ef372
- this._d = 0xa54ff53a
- this._e = 0x510e527f
- this._f = 0x9b05688c
- this._g = 0x1f83d9ab
- this._h = 0x5be0cd19
- return this
- }
- function ch (x, y, z) {
- return z ^ (x & (y ^ z))
- }
- function maj (x, y, z) {
- return (x & y) | (z & (x | y))
- }
- function sigma0 (x) {
- return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
- }
- function sigma1 (x) {
- return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
- }
- function gamma0 (x) {
- return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
- }
- function gamma1 (x) {
- return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
- }
- Sha256.prototype._update = function (M) {
- var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- var f = this._f | 0
- var g = this._g | 0
- var h = this._h | 0
- for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
- for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
- for (var j = 0; j < 64; ++j) {
- var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
- var T2 = (sigma0(a) + maj(a, b, c)) | 0
- h = g
- g = f
- f = e
- e = (d + T1) | 0
- d = c
- c = b
- b = a
- a = (T1 + T2) | 0
- }
- this._a = (a + this._a) | 0
- this._b = (b + this._b) | 0
- this._c = (c + this._c) | 0
- this._d = (d + this._d) | 0
- this._e = (e + this._e) | 0
- this._f = (f + this._f) | 0
- this._g = (g + this._g) | 0
- this._h = (h + this._h) | 0
- }
- Sha256.prototype._hash = function () {
- var H = new Buffer(32)
- H.writeInt32BE(this._a, 0)
- H.writeInt32BE(this._b, 4)
- H.writeInt32BE(this._c, 8)
- H.writeInt32BE(this._d, 12)
- H.writeInt32BE(this._e, 16)
- H.writeInt32BE(this._f, 20)
- H.writeInt32BE(this._g, 24)
- H.writeInt32BE(this._h, 28)
- return H
- }
- module.exports = Sha256
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"buffer":65,"inherits":34}],58:[function(require,module,exports){
- (function (Buffer){
- var inherits = require('inherits')
- var SHA512 = require('./sha512')
- var Hash = require('./hash')
- var W = new Array(160)
- function Sha384 () {
- this.init()
- this._w = W
- Hash.call(this, 128, 112)
- }
- inherits(Sha384, SHA512)
- Sha384.prototype.init = function () {
- this._ah = 0xcbbb9d5d
- this._bh = 0x629a292a
- this._ch = 0x9159015a
- this._dh = 0x152fecd8
- this._eh = 0x67332667
- this._fh = 0x8eb44a87
- this._gh = 0xdb0c2e0d
- this._hh = 0x47b5481d
- this._al = 0xc1059ed8
- this._bl = 0x367cd507
- this._cl = 0x3070dd17
- this._dl = 0xf70e5939
- this._el = 0xffc00b31
- this._fl = 0x68581511
- this._gl = 0x64f98fa7
- this._hl = 0xbefa4fa4
- return this
- }
- Sha384.prototype._hash = function () {
- var H = new Buffer(48)
- function writeInt64BE (h, l, offset) {
- H.writeInt32BE(h, offset)
- H.writeInt32BE(l, offset + 4)
- }
- writeInt64BE(this._ah, this._al, 0)
- writeInt64BE(this._bh, this._bl, 8)
- writeInt64BE(this._ch, this._cl, 16)
- writeInt64BE(this._dh, this._dl, 24)
- writeInt64BE(this._eh, this._el, 32)
- writeInt64BE(this._fh, this._fl, 40)
- return H
- }
- module.exports = Sha384
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"./sha512":59,"buffer":65,"inherits":34}],59:[function(require,module,exports){
- (function (Buffer){
- var inherits = require('inherits')
- var Hash = require('./hash')
- var K = [
- 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
- 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
- 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
- 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
- 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
- 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
- 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
- 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
- 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
- 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
- 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
- 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
- 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
- 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
- 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
- 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
- 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
- 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
- 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
- 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
- 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
- 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
- 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
- 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
- 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
- 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
- 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
- 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
- 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
- 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
- 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
- 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
- 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
- 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
- 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
- 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
- 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
- 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
- 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
- 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
- ]
- var W = new Array(160)
- function Sha512 () {
- this.init()
- this._w = W
- Hash.call(this, 128, 112)
- }
- inherits(Sha512, Hash)
- Sha512.prototype.init = function () {
- this._ah = 0x6a09e667
- this._bh = 0xbb67ae85
- this._ch = 0x3c6ef372
- this._dh = 0xa54ff53a
- this._eh = 0x510e527f
- this._fh = 0x9b05688c
- this._gh = 0x1f83d9ab
- this._hh = 0x5be0cd19
- this._al = 0xf3bcc908
- this._bl = 0x84caa73b
- this._cl = 0xfe94f82b
- this._dl = 0x5f1d36f1
- this._el = 0xade682d1
- this._fl = 0x2b3e6c1f
- this._gl = 0xfb41bd6b
- this._hl = 0x137e2179
- return this
- }
- function Ch (x, y, z) {
- return z ^ (x & (y ^ z))
- }
- function maj (x, y, z) {
- return (x & y) | (z & (x | y))
- }
- function sigma0 (x, xl) {
- return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
- }
- function sigma1 (x, xl) {
- return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
- }
- function Gamma0 (x, xl) {
- return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
- }
- function Gamma0l (x, xl) {
- return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
- }
- function Gamma1 (x, xl) {
- return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
- }
- function Gamma1l (x, xl) {
- return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
- }
- function getCarry (a, b) {
- return (a >>> 0) < (b >>> 0) ? 1 : 0
- }
- Sha512.prototype._update = function (M) {
- var W = this._w
- var ah = this._ah | 0
- var bh = this._bh | 0
- var ch = this._ch | 0
- var dh = this._dh | 0
- var eh = this._eh | 0
- var fh = this._fh | 0
- var gh = this._gh | 0
- var hh = this._hh | 0
- var al = this._al | 0
- var bl = this._bl | 0
- var cl = this._cl | 0
- var dl = this._dl | 0
- var el = this._el | 0
- var fl = this._fl | 0
- var gl = this._gl | 0
- var hl = this._hl | 0
- for (var i = 0; i < 32; i += 2) {
- W[i] = M.readInt32BE(i * 4)
- W[i + 1] = M.readInt32BE(i * 4 + 4)
- }
- for (; i < 160; i += 2) {
- var xh = W[i - 15 * 2]
- var xl = W[i - 15 * 2 + 1]
- var gamma0 = Gamma0(xh, xl)
- var gamma0l = Gamma0l(xl, xh)
- xh = W[i - 2 * 2]
- xl = W[i - 2 * 2 + 1]
- var gamma1 = Gamma1(xh, xl)
- var gamma1l = Gamma1l(xl, xh)
- // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
- var Wi7h = W[i - 7 * 2]
- var Wi7l = W[i - 7 * 2 + 1]
- var Wi16h = W[i - 16 * 2]
- var Wi16l = W[i - 16 * 2 + 1]
- var Wil = (gamma0l + Wi7l) | 0
- var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
- Wil = (Wil + gamma1l) | 0
- Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
- Wil = (Wil + Wi16l) | 0
- Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
- W[i] = Wih
- W[i + 1] = Wil
- }
- for (var j = 0; j < 160; j += 2) {
- Wih = W[j]
- Wil = W[j + 1]
- var majh = maj(ah, bh, ch)
- var majl = maj(al, bl, cl)
- var sigma0h = sigma0(ah, al)
- var sigma0l = sigma0(al, ah)
- var sigma1h = sigma1(eh, el)
- var sigma1l = sigma1(el, eh)
- // t1 = h + sigma1 + ch + K[j] + W[j]
- var Kih = K[j]
- var Kil = K[j + 1]
- var chh = Ch(eh, fh, gh)
- var chl = Ch(el, fl, gl)
- var t1l = (hl + sigma1l) | 0
- var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
- t1l = (t1l + chl) | 0
- t1h = (t1h + chh + getCarry(t1l, chl)) | 0
- t1l = (t1l + Kil) | 0
- t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
- t1l = (t1l + Wil) | 0
- t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
- // t2 = sigma0 + maj
- var t2l = (sigma0l + majl) | 0
- var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
- hh = gh
- hl = gl
- gh = fh
- gl = fl
- fh = eh
- fl = el
- el = (dl + t1l) | 0
- eh = (dh + t1h + getCarry(el, dl)) | 0
- dh = ch
- dl = cl
- ch = bh
- cl = bl
- bh = ah
- bl = al
- al = (t1l + t2l) | 0
- ah = (t1h + t2h + getCarry(al, t1l)) | 0
- }
- this._al = (this._al + al) | 0
- this._bl = (this._bl + bl) | 0
- this._cl = (this._cl + cl) | 0
- this._dl = (this._dl + dl) | 0
- this._el = (this._el + el) | 0
- this._fl = (this._fl + fl) | 0
- this._gl = (this._gl + gl) | 0
- this._hl = (this._hl + hl) | 0
- this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
- this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
- this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
- this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
- this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
- this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
- this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
- this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
- }
- Sha512.prototype._hash = function () {
- var H = new Buffer(64)
- function writeInt64BE (h, l, offset) {
- H.writeInt32BE(h, offset)
- H.writeInt32BE(l, offset + 4)
- }
- writeInt64BE(this._ah, this._al, 0)
- writeInt64BE(this._bh, this._bl, 8)
- writeInt64BE(this._ch, this._cl, 16)
- writeInt64BE(this._dh, this._dl, 24)
- writeInt64BE(this._eh, this._el, 32)
- writeInt64BE(this._fh, this._fl, 40)
- writeInt64BE(this._gh, this._gl, 48)
- writeInt64BE(this._hh, this._hl, 56)
- return H
- }
- module.exports = Sha512
- }).call(this,require("buffer").Buffer)
- },{"./hash":52,"buffer":65,"inherits":34}],60:[function(require,module,exports){
- var isHexPrefixed = require('is-hex-prefixed');
- /**
- * Removes '0x' from a given `String` is present
- * @param {String} str the string value
- * @return {String|Optional} a string by pass if necessary
- */
- module.exports = function stripHexPrefix(str) {
- if (typeof str !== 'string') {
- return str;
- }
- return isHexPrefixed(str) ? str.slice(2) : str;
- }
- },{"is-hex-prefixed":35}],61:[function(require,module,exports){
- (function (global){
- 'use strict';
- // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
- // original notice:
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license MIT
- */
- function compare(a, b) {
- if (a === b) {
- return 0;
- }
- var x = a.length;
- var y = b.length;
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i];
- y = b[i];
- break;
- }
- }
- if (x < y) {
- return -1;
- }
- if (y < x) {
- return 1;
- }
- return 0;
- }
- function isBuffer(b) {
- if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
- return global.Buffer.isBuffer(b);
- }
- return !!(b != null && b._isBuffer);
- }
- // based on node assert, original notice:
- // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
- //
- // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
- //
- // Originally from narwhal.js (http://narwhaljs.org)
- // Copyright (c) 2009 Thomas Robinson <280north.com>
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the 'Software'), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- var util = require('util/');
- var hasOwn = Object.prototype.hasOwnProperty;
- var pSlice = Array.prototype.slice;
- var functionsHaveNames = (function () {
- return function foo() {}.name === 'foo';
- }());
- function pToString (obj) {
- return Object.prototype.toString.call(obj);
- }
- function isView(arrbuf) {
- if (isBuffer(arrbuf)) {
- return false;
- }
- if (typeof global.ArrayBuffer !== 'function') {
- return false;
- }
- if (typeof ArrayBuffer.isView === 'function') {
- return ArrayBuffer.isView(arrbuf);
- }
- if (!arrbuf) {
- return false;
- }
- if (arrbuf instanceof DataView) {
- return true;
- }
- if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
- return true;
- }
- return false;
- }
- // 1. The assert module provides functions that throw
- // AssertionError's when particular conditions are not met. The
- // assert module must conform to the following interface.
- var assert = module.exports = ok;
- // 2. The AssertionError is defined in assert.
- // new assert.AssertionError({ message: message,
- // actual: actual,
- // expected: expected })
- var regex = /\s*function\s+([^\(\s]*)\s*/;
- // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
- function getName(func) {
- if (!util.isFunction(func)) {
- return;
- }
- if (functionsHaveNames) {
- return func.name;
- }
- var str = func.toString();
- var match = str.match(regex);
- return match && match[1];
- }
- assert.AssertionError = function AssertionError(options) {
- this.name = 'AssertionError';
- this.actual = options.actual;
- this.expected = options.expected;
- this.operator = options.operator;
- if (options.message) {
- this.message = options.message;
- this.generatedMessage = false;
- } else {
- this.message = getMessage(this);
- this.generatedMessage = true;
- }
- var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- } else {
- // non v8 browsers so we can have a stacktrace
- var err = new Error();
- if (err.stack) {
- var out = err.stack;
- // try to strip useless frames
- var fn_name = getName(stackStartFunction);
- var idx = out.indexOf('\n' + fn_name);
- if (idx >= 0) {
- // once we have located the function frame
- // we need to strip out everything before it (and its line)
- var next_line = out.indexOf('\n', idx + 1);
- out = out.substring(next_line + 1);
- }
- this.stack = out;
- }
- }
- };
- // assert.AssertionError instanceof Error
- util.inherits(assert.AssertionError, Error);
- function truncate(s, n) {
- if (typeof s === 'string') {
- return s.length < n ? s : s.slice(0, n);
- } else {
- return s;
- }
- }
- function inspect(something) {
- if (functionsHaveNames || !util.isFunction(something)) {
- return util.inspect(something);
- }
- var rawname = getName(something);
- var name = rawname ? ': ' + rawname : '';
- return '[Function' + name + ']';
- }
- function getMessage(self) {
- return truncate(inspect(self.actual), 128) + ' ' +
- self.operator + ' ' +
- truncate(inspect(self.expected), 128);
- }
- // At present only the three keys mentioned above are used and
- // understood by the spec. Implementations or sub modules can pass
- // other keys to the AssertionError's constructor - they will be
- // ignored.
- // 3. All of the following functions must throw an AssertionError
- // when a corresponding condition is not met, with a message that
- // may be undefined if not provided. All assertion methods provide
- // both the actual and expected values to the assertion error for
- // display purposes.
- function fail(actual, expected, message, operator, stackStartFunction) {
- throw new assert.AssertionError({
- message: message,
- actual: actual,
- expected: expected,
- operator: operator,
- stackStartFunction: stackStartFunction
- });
- }
- // EXTENSION! allows for well behaved errors defined elsewhere.
- assert.fail = fail;
- // 4. Pure assertion tests whether a value is truthy, as determined
- // by !!guard.
- // assert.ok(guard, message_opt);
- // This statement is equivalent to assert.equal(true, !!guard,
- // message_opt);. To test strictly for the value true, use
- // assert.strictEqual(true, guard, message_opt);.
- function ok(value, message) {
- if (!value) fail(value, true, message, '==', assert.ok);
- }
- assert.ok = ok;
- // 5. The equality assertion tests shallow, coercive equality with
- // ==.
- // assert.equal(actual, expected, message_opt);
- assert.equal = function equal(actual, expected, message) {
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
- };
- // 6. The non-equality assertion tests for whether two objects are not equal
- // with != assert.notEqual(actual, expected, message_opt);
- assert.notEqual = function notEqual(actual, expected, message) {
- if (actual == expected) {
- fail(actual, expected, message, '!=', assert.notEqual);
- }
- };
- // 7. The equivalence assertion tests a deep equality relation.
- // assert.deepEqual(actual, expected, message_opt);
- assert.deepEqual = function deepEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
- }
- };
- assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
- }
- };
- function _deepEqual(actual, expected, strict, memos) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
- } else if (isBuffer(actual) && isBuffer(expected)) {
- return compare(actual, expected) === 0;
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (util.isDate(actual) && util.isDate(expected)) {
- return actual.getTime() === expected.getTime();
- // 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source and
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
- return actual.source === expected.source &&
- actual.global === expected.global &&
- actual.multiline === expected.multiline &&
- actual.lastIndex === expected.lastIndex &&
- actual.ignoreCase === expected.ignoreCase;
- // 7.4. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if ((actual === null || typeof actual !== 'object') &&
- (expected === null || typeof expected !== 'object')) {
- return strict ? actual === expected : actual == expected;
- // If both values are instances of typed arrays, wrap their underlying
- // ArrayBuffers in a Buffer each to increase performance
- // This optimization requires the arrays to have the same type as checked by
- // Object.prototype.toString (aka pToString). Never perform binary
- // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
- // bit patterns are not identical.
- } else if (isView(actual) && isView(expected) &&
- pToString(actual) === pToString(expected) &&
- !(actual instanceof Float32Array ||
- actual instanceof Float64Array)) {
- return compare(new Uint8Array(actual.buffer),
- new Uint8Array(expected.buffer)) === 0;
- // 7.5 For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else if (isBuffer(actual) !== isBuffer(expected)) {
- return false;
- } else {
- memos = memos || {actual: [], expected: []};
- var actualIndex = memos.actual.indexOf(actual);
- if (actualIndex !== -1) {
- if (actualIndex === memos.expected.indexOf(expected)) {
- return true;
- }
- }
- memos.actual.push(actual);
- memos.expected.push(expected);
- return objEquiv(actual, expected, strict, memos);
- }
- }
- function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
- }
- function objEquiv(a, b, strict, actualVisitedObjects) {
- if (a === null || a === undefined || b === null || b === undefined)
- return false;
- // if one is a primitive, the other must be same
- if (util.isPrimitive(a) || util.isPrimitive(b))
- return a === b;
- if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
- return false;
- var aIsArgs = isArguments(a);
- var bIsArgs = isArguments(b);
- if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
- return false;
- if (aIsArgs) {
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b, strict);
- }
- var ka = objectKeys(a);
- var kb = objectKeys(b);
- var key, i;
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length !== kb.length)
- return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] !== kb[i])
- return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
- return false;
- }
- return true;
- }
- // 8. The non-equivalence assertion tests for any deep inequality.
- // assert.notDeepEqual(actual, expected, message_opt);
- assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
- }
- };
- assert.notDeepStrictEqual = notDeepStrictEqual;
- function notDeepStrictEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
- }
- }
- // 9. The strict equality assertion tests strict equality, as determined by ===.
- // assert.strictEqual(actual, expected, message_opt);
- assert.strictEqual = function strictEqual(actual, expected, message) {
- if (actual !== expected) {
- fail(actual, expected, message, '===', assert.strictEqual);
- }
- };
- // 10. The strict non-equality assertion tests for strict inequality, as
- // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
- if (actual === expected) {
- fail(actual, expected, message, '!==', assert.notStrictEqual);
- }
- };
- function expectedException(actual, expected) {
- if (!actual || !expected) {
- return false;
- }
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
- return expected.test(actual);
- }
- try {
- if (actual instanceof expected) {
- return true;
- }
- } catch (e) {
- // Ignore. The instanceof check doesn't work for arrow functions.
- }
- if (Error.isPrototypeOf(expected)) {
- return false;
- }
- return expected.call({}, actual) === true;
- }
- function _tryBlock(block) {
- var error;
- try {
- block();
- } catch (e) {
- error = e;
- }
- return error;
- }
- function _throws(shouldThrow, block, expected, message) {
- var actual;
- if (typeof block !== 'function') {
- throw new TypeError('"block" argument must be a function');
- }
- if (typeof expected === 'string') {
- message = expected;
- expected = null;
- }
- actual = _tryBlock(block);
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
- (message ? ' ' + message : '.');
- if (shouldThrow && !actual) {
- fail(actual, expected, 'Missing expected exception' + message);
- }
- var userProvidedMessage = typeof message === 'string';
- var isUnwantedException = !shouldThrow && util.isError(actual);
- var isUnexpectedException = !shouldThrow && actual && !expected;
- if ((isUnwantedException &&
- userProvidedMessage &&
- expectedException(actual, expected)) ||
- isUnexpectedException) {
- fail(actual, expected, 'Got unwanted exception' + message);
- }
- if ((shouldThrow && actual && expected &&
- !expectedException(actual, expected)) || (!shouldThrow && actual)) {
- throw actual;
- }
- }
- // 11. Expected to throw an error:
- // assert.throws(block, Error_opt, message_opt);
- assert.throws = function(block, /*optional*/error, /*optional*/message) {
- _throws(true, block, error, message);
- };
- // EXTENSION! This is annoying to write outside this module.
- assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
- _throws(false, block, error, message);
- };
- assert.ifError = function(err) { if (err) throw err; };
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- if (hasOwn.call(obj, key)) keys.push(key);
- }
- return keys;
- };
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"util/":90}],62:[function(require,module,exports){
- 'use strict'
- exports.byteLength = byteLength
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
- function placeHoldersCount (b64) {
- var len = b64.length
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
- }
- function byteLength (b64) {
- // base64 is 4/3 + up to two characters of the original data
- return b64.length * 3 / 4 - placeHoldersCount(b64)
- }
- function toByteArray (b64) {
- var i, j, l, tmp, placeHolders, arr
- var len = b64.length
- placeHolders = placeHoldersCount(b64)
- arr = new Arr(len * 3 / 4 - placeHolders)
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? len - 4 : len
- var L = 0
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
- arr[L++] = (tmp >> 16) & 0xFF
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
- if (placeHolders === 2) {
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[L++] = tmp & 0xFF
- } else if (placeHolders === 1) {
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
- return arr
- }
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
- }
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var output = ''
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- output += lookup[tmp >> 2]
- output += lookup[(tmp << 4) & 0x3F]
- output += '=='
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
- output += lookup[tmp >> 10]
- output += lookup[(tmp >> 4) & 0x3F]
- output += lookup[(tmp << 2) & 0x3F]
- output += '='
- }
- parts.push(output)
- return parts.join('')
- }
- },{}],63:[function(require,module,exports){
- },{}],64:[function(require,module,exports){
- (function (global){
- 'use strict';
- var buffer = require('buffer');
- var Buffer = buffer.Buffer;
- var SlowBuffer = buffer.SlowBuffer;
- var MAX_LEN = buffer.kMaxLength || 2147483647;
- exports.alloc = function alloc(size, fill, encoding) {
- if (typeof Buffer.alloc === 'function') {
- return Buffer.alloc(size, fill, encoding);
- }
- if (typeof encoding === 'number') {
- throw new TypeError('encoding must not be number');
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- var enc = encoding;
- var _fill = fill;
- if (_fill === undefined) {
- enc = undefined;
- _fill = 0;
- }
- var buf = new Buffer(size);
- if (typeof _fill === 'string') {
- var fillBuf = new Buffer(_fill, enc);
- var flen = fillBuf.length;
- var i = -1;
- while (++i < size) {
- buf[i] = fillBuf[i % flen];
- }
- } else {
- buf.fill(_fill);
- }
- return buf;
- }
- exports.allocUnsafe = function allocUnsafe(size) {
- if (typeof Buffer.allocUnsafe === 'function') {
- return Buffer.allocUnsafe(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new Buffer(size);
- }
- exports.from = function from(value, encodingOrOffset, length) {
- if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
- return Buffer.from(value, encodingOrOffset, length);
- }
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number');
- }
- if (typeof value === 'string') {
- return new Buffer(value, encodingOrOffset);
- }
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
- var offset = encodingOrOffset;
- if (arguments.length === 1) {
- return new Buffer(value);
- }
- if (typeof offset === 'undefined') {
- offset = 0;
- }
- var len = length;
- if (typeof len === 'undefined') {
- len = value.byteLength - offset;
- }
- if (offset >= value.byteLength) {
- throw new RangeError('\'offset\' is out of bounds');
- }
- if (len > value.byteLength - offset) {
- throw new RangeError('\'length\' is out of bounds');
- }
- return new Buffer(value.slice(offset, offset + len));
- }
- if (Buffer.isBuffer(value)) {
- var out = new Buffer(value.length);
- value.copy(out, 0, 0, value.length);
- return out;
- }
- if (value) {
- if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
- return new Buffer(value);
- }
- if (value.type === 'Buffer' && Array.isArray(value.data)) {
- return new Buffer(value.data);
- }
- }
- throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
- }
- exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
- if (typeof Buffer.allocUnsafeSlow === 'function') {
- return Buffer.allocUnsafeSlow(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size >= MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new SlowBuffer(size);
- }
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"buffer":65}],65:[function(require,module,exports){
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license MIT
- */
- /* eslint-disable no-proto */
- 'use strict'
- var base64 = require('base64-js')
- var ieee754 = require('ieee754')
- exports.Buffer = Buffer
- exports.SlowBuffer = SlowBuffer
- exports.INSPECT_MAX_BYTES = 50
- var K_MAX_LENGTH = 0x7fffffff
- exports.kMaxLength = K_MAX_LENGTH
- /**
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
- * === true Use Uint8Array implementation (fastest)
- * === false Print warning and recommend using `buffer` v4.x which has an Object
- * implementation (most compatible, even IE6)
- *
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
- * Opera 11.6+, iOS 4.2+.
- *
- * We report that the browser does not support typed arrays if the are not subclassable
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
- * for __proto__ and has a buggy typed array implementation.
- */
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
- typeof console.error === 'function') {
- console.error(
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
- )
- }
- function typedArraySupport () {
- // Can typed array instances can be augmented?
- try {
- var arr = new Uint8Array(1)
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
- return arr.foo() === 42
- } catch (e) {
- return false
- }
- }
- function createBuffer (length) {
- if (length > K_MAX_LENGTH) {
- throw new RangeError('Invalid typed array length')
- }
- // Return an augmented `Uint8Array` instance
- var buf = new Uint8Array(length)
- buf.__proto__ = Buffer.prototype
- return buf
- }
- /**
- * The Buffer constructor returns instances of `Uint8Array` that have their
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
- * returns a single octet.
- *
- * The `Uint8Array` prototype remains unmodified.
- */
- function Buffer (arg, encodingOrOffset, length) {
- // Common case.
- if (typeof arg === 'number') {
- if (typeof encodingOrOffset === 'string') {
- throw new Error(
- 'If encoding is specified then the first argument must be a string'
- )
- }
- return allocUnsafe(arg)
- }
- return from(arg, encodingOrOffset, length)
- }
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
- if (typeof Symbol !== 'undefined' && Symbol.species &&
- Buffer[Symbol.species] === Buffer) {
- Object.defineProperty(Buffer, Symbol.species, {
- value: null,
- configurable: true,
- enumerable: false,
- writable: false
- })
- }
- Buffer.poolSize = 8192 // not used by this implementation
- function from (value, encodingOrOffset, length) {
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number')
- }
- if (value instanceof ArrayBuffer) {
- return fromArrayBuffer(value, encodingOrOffset, length)
- }
- if (typeof value === 'string') {
- return fromString(value, encodingOrOffset)
- }
- return fromObject(value)
- }
- /**
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
- * if value is a number.
- * Buffer.from(str[, encoding])
- * Buffer.from(array)
- * Buffer.from(buffer)
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
- **/
- Buffer.from = function (value, encodingOrOffset, length) {
- return from(value, encodingOrOffset, length)
- }
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
- // https://github.com/feross/buffer/pull/148
- Buffer.prototype.__proto__ = Uint8Array.prototype
- Buffer.__proto__ = Uint8Array
- function assertSize (size) {
- if (typeof size !== 'number') {
- throw new TypeError('"size" argument must be a number')
- } else if (size < 0) {
- throw new RangeError('"size" argument must not be negative')
- }
- }
- function alloc (size, fill, encoding) {
- assertSize(size)
- if (size <= 0) {
- return createBuffer(size)
- }
- if (fill !== undefined) {
- // Only pay attention to encoding if it's a string. This
- // prevents accidentally sending in a number that would
- // be interpretted as a start offset.
- return typeof encoding === 'string'
- ? createBuffer(size).fill(fill, encoding)
- : createBuffer(size).fill(fill)
- }
- return createBuffer(size)
- }
- /**
- * Creates a new filled Buffer instance.
- * alloc(size[, fill[, encoding]])
- **/
- Buffer.alloc = function (size, fill, encoding) {
- return alloc(size, fill, encoding)
- }
- function allocUnsafe (size) {
- assertSize(size)
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
- }
- /**
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
- * */
- Buffer.allocUnsafe = function (size) {
- return allocUnsafe(size)
- }
- /**
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
- */
- Buffer.allocUnsafeSlow = function (size) {
- return allocUnsafe(size)
- }
- function fromString (string, encoding) {
- if (typeof encoding !== 'string' || encoding === '') {
- encoding = 'utf8'
- }
- if (!Buffer.isEncoding(encoding)) {
- throw new TypeError('"encoding" must be a valid string encoding')
- }
- var length = byteLength(string, encoding) | 0
- var buf = createBuffer(length)
- var actual = buf.write(string, encoding)
- if (actual !== length) {
- // Writing a hex string, for example, that contains invalid characters will
- // cause everything after the first invalid character to be ignored. (e.g.
- // 'abxxcd' will be treated as 'ab')
- buf = buf.slice(0, actual)
- }
- return buf
- }
- function fromArrayLike (array) {
- var length = array.length < 0 ? 0 : checked(array.length) | 0
- var buf = createBuffer(length)
- for (var i = 0; i < length; i += 1) {
- buf[i] = array[i] & 255
- }
- return buf
- }
- function fromArrayBuffer (array, byteOffset, length) {
- if (byteOffset < 0 || array.byteLength < byteOffset) {
- throw new RangeError('\'offset\' is out of bounds')
- }
- if (array.byteLength < byteOffset + (length || 0)) {
- throw new RangeError('\'length\' is out of bounds')
- }
- var buf
- if (byteOffset === undefined && length === undefined) {
- buf = new Uint8Array(array)
- } else if (length === undefined) {
- buf = new Uint8Array(array, byteOffset)
- } else {
- buf = new Uint8Array(array, byteOffset, length)
- }
- // Return an augmented `Uint8Array` instance
- buf.__proto__ = Buffer.prototype
- return buf
- }
- function fromObject (obj) {
- if (Buffer.isBuffer(obj)) {
- var len = checked(obj.length) | 0
- var buf = createBuffer(len)
- if (buf.length === 0) {
- return buf
- }
- obj.copy(buf, 0, 0, len)
- return buf
- }
- if (obj) {
- if (ArrayBuffer.isView(obj) || 'length' in obj) {
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
- return createBuffer(0)
- }
- return fromArrayLike(obj)
- }
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
- return fromArrayLike(obj.data)
- }
- }
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
- }
- function checked (length) {
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
- // length is NaN (which is otherwise coerced to zero.)
- if (length >= K_MAX_LENGTH) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
- }
- return length | 0
- }
- function SlowBuffer (length) {
- if (+length != length) { // eslint-disable-line eqeqeq
- length = 0
- }
- return Buffer.alloc(+length)
- }
- Buffer.isBuffer = function isBuffer (b) {
- return b != null && b._isBuffer === true
- }
- Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
- if (a === b) return 0
- var x = a.length
- var y = b.length
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i]
- y = b[i]
- break
- }
- }
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
- Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'latin1':
- case 'binary':
- case 'base64':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
- }
- Buffer.concat = function concat (list, length) {
- if (!Array.isArray(list)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- if (list.length === 0) {
- return Buffer.alloc(0)
- }
- var i
- if (length === undefined) {
- length = 0
- for (i = 0; i < list.length; ++i) {
- length += list[i].length
- }
- }
- var buffer = Buffer.allocUnsafe(length)
- var pos = 0
- for (i = 0; i < list.length; ++i) {
- var buf = list[i]
- if (!Buffer.isBuffer(buf)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- buf.copy(buffer, pos)
- pos += buf.length
- }
- return buffer
- }
- function byteLength (string, encoding) {
- if (Buffer.isBuffer(string)) {
- return string.length
- }
- if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) {
- return string.byteLength
- }
- if (typeof string !== 'string') {
- string = '' + string
- }
- var len = string.length
- if (len === 0) return 0
- // Use a for loop to avoid recursion
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'ascii':
- case 'latin1':
- case 'binary':
- return len
- case 'utf8':
- case 'utf-8':
- case undefined:
- return utf8ToBytes(string).length
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return len * 2
- case 'hex':
- return len >>> 1
- case 'base64':
- return base64ToBytes(string).length
- default:
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.byteLength = byteLength
- function slowToString (encoding, start, end) {
- var loweredCase = false
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
- // property of a typed array.
- // This behaves neither like String nor Uint8Array in that we set start/end
- // to their upper/lower bounds if the value passed is out of range.
- // undefined is handled specially as per ECMA-262 6th Edition,
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
- if (start === undefined || start < 0) {
- start = 0
- }
- // Return early if start > this.length. Done here to prevent potential uint32
- // coercion fail below.
- if (start > this.length) {
- return ''
- }
- if (end === undefined || end > this.length) {
- end = this.length
- }
- if (end <= 0) {
- return ''
- }
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
- end >>>= 0
- start >>>= 0
- if (end <= start) {
- return ''
- }
- if (!encoding) encoding = 'utf8'
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
- case 'ascii':
- return asciiSlice(this, start, end)
- case 'latin1':
- case 'binary':
- return latin1Slice(this, start, end)
- case 'base64':
- return base64Slice(this, start, end)
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
- }
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
- // reliably in a browserify context because there could be multiple different
- // copies of the 'buffer' package in use. This method works even for Buffer
- // instances that were created from another copy of the `buffer` package.
- // See: https://github.com/feross/buffer/issues/154
- Buffer.prototype._isBuffer = true
- function swap (b, n, m) {
- var i = b[n]
- b[n] = b[m]
- b[m] = i
- }
- Buffer.prototype.swap16 = function swap16 () {
- var len = this.length
- if (len % 2 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 16-bits')
- }
- for (var i = 0; i < len; i += 2) {
- swap(this, i, i + 1)
- }
- return this
- }
- Buffer.prototype.swap32 = function swap32 () {
- var len = this.length
- if (len % 4 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 32-bits')
- }
- for (var i = 0; i < len; i += 4) {
- swap(this, i, i + 3)
- swap(this, i + 1, i + 2)
- }
- return this
- }
- Buffer.prototype.swap64 = function swap64 () {
- var len = this.length
- if (len % 8 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 64-bits')
- }
- for (var i = 0; i < len; i += 8) {
- swap(this, i, i + 7)
- swap(this, i + 1, i + 6)
- swap(this, i + 2, i + 5)
- swap(this, i + 3, i + 4)
- }
- return this
- }
- Buffer.prototype.toString = function toString () {
- var length = this.length
- if (length === 0) return ''
- if (arguments.length === 0) return utf8Slice(this, 0, length)
- return slowToString.apply(this, arguments)
- }
- Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
- }
- Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return '<Buffer ' + str + '>'
- }
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
- if (!Buffer.isBuffer(target)) {
- throw new TypeError('Argument must be a Buffer')
- }
- if (start === undefined) {
- start = 0
- }
- if (end === undefined) {
- end = target ? target.length : 0
- }
- if (thisStart === undefined) {
- thisStart = 0
- }
- if (thisEnd === undefined) {
- thisEnd = this.length
- }
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
- throw new RangeError('out of range index')
- }
- if (thisStart >= thisEnd && start >= end) {
- return 0
- }
- if (thisStart >= thisEnd) {
- return -1
- }
- if (start >= end) {
- return 1
- }
- start >>>= 0
- end >>>= 0
- thisStart >>>= 0
- thisEnd >>>= 0
- if (this === target) return 0
- var x = thisEnd - thisStart
- var y = end - start
- var len = Math.min(x, y)
- var thisCopy = this.slice(thisStart, thisEnd)
- var targetCopy = target.slice(start, end)
- for (var i = 0; i < len; ++i) {
- if (thisCopy[i] !== targetCopy[i]) {
- x = thisCopy[i]
- y = targetCopy[i]
- break
- }
- }
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
- //
- // Arguments:
- // - buffer - a Buffer to search
- // - val - a string, Buffer, or number
- // - byteOffset - an index into `buffer`; will be clamped to an int32
- // - encoding - an optional encoding, relevant is val is a string
- // - dir - true for indexOf, false for lastIndexOf
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
- // Empty buffer means no match
- if (buffer.length === 0) return -1
- // Normalize byteOffset
- if (typeof byteOffset === 'string') {
- encoding = byteOffset
- byteOffset = 0
- } else if (byteOffset > 0x7fffffff) {
- byteOffset = 0x7fffffff
- } else if (byteOffset < -0x80000000) {
- byteOffset = -0x80000000
- }
- byteOffset = +byteOffset // Coerce to Number.
- if (isNaN(byteOffset)) {
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
- byteOffset = dir ? 0 : (buffer.length - 1)
- }
- // Normalize byteOffset: negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset
- if (byteOffset >= buffer.length) {
- if (dir) return -1
- else byteOffset = buffer.length - 1
- } else if (byteOffset < 0) {
- if (dir) byteOffset = 0
- else return -1
- }
- // Normalize val
- if (typeof val === 'string') {
- val = Buffer.from(val, encoding)
- }
- // Finally, search either indexOf (if dir is true) or lastIndexOf
- if (Buffer.isBuffer(val)) {
- // Special case: looking for empty string/buffer always fails
- if (val.length === 0) {
- return -1
- }
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
- } else if (typeof val === 'number') {
- val = val & 0xFF // Search for a byte value [0-255]
- if (typeof Uint8Array.prototype.indexOf === 'function') {
- if (dir) {
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
- } else {
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
- }
- }
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
- }
- throw new TypeError('val must be string, number or Buffer')
- }
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
- var indexSize = 1
- var arrLength = arr.length
- var valLength = val.length
- if (encoding !== undefined) {
- encoding = String(encoding).toLowerCase()
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
- encoding === 'utf16le' || encoding === 'utf-16le') {
- if (arr.length < 2 || val.length < 2) {
- return -1
- }
- indexSize = 2
- arrLength /= 2
- valLength /= 2
- byteOffset /= 2
- }
- }
- function read (buf, i) {
- if (indexSize === 1) {
- return buf[i]
- } else {
- return buf.readUInt16BE(i * indexSize)
- }
- }
- var i
- if (dir) {
- var foundIndex = -1
- for (i = byteOffset; i < arrLength; i++) {
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
- } else {
- if (foundIndex !== -1) i -= i - foundIndex
- foundIndex = -1
- }
- }
- } else {
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
- for (i = byteOffset; i >= 0; i--) {
- var found = true
- for (var j = 0; j < valLength; j++) {
- if (read(arr, i + j) !== read(val, j)) {
- found = false
- break
- }
- }
- if (found) return i
- }
- }
- return -1
- }
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
- return this.indexOf(val, byteOffset, encoding) !== -1
- }
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
- }
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
- }
- function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
- // must be an even number of digits
- var strLen = string.length
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; ++i) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (isNaN(parsed)) return i
- buf[offset + i] = parsed
- }
- return i
- }
- function utf8Write (buf, string, offset, length) {
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
- }
- function asciiWrite (buf, string, offset, length) {
- return blitBuffer(asciiToBytes(string), buf, offset, length)
- }
- function latin1Write (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
- }
- function base64Write (buf, string, offset, length) {
- return blitBuffer(base64ToBytes(string), buf, offset, length)
- }
- function ucs2Write (buf, string, offset, length) {
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
- }
- Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Buffer#write(string)
- if (offset === undefined) {
- encoding = 'utf8'
- length = this.length
- offset = 0
- // Buffer#write(string, encoding)
- } else if (length === undefined && typeof offset === 'string') {
- encoding = offset
- length = this.length
- offset = 0
- // Buffer#write(string, offset[, length][, encoding])
- } else if (isFinite(offset)) {
- offset = offset >>> 0
- if (isFinite(length)) {
- length = length >>> 0
- if (encoding === undefined) encoding = 'utf8'
- } else {
- encoding = length
- length = undefined
- }
- } else {
- throw new Error(
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
- )
- }
- var remaining = this.length - offset
- if (length === undefined || length > remaining) length = remaining
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
- throw new RangeError('Attempt to write outside buffer bounds')
- }
- if (!encoding) encoding = 'utf8'
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'hex':
- return hexWrite(this, string, offset, length)
- case 'utf8':
- case 'utf-8':
- return utf8Write(this, string, offset, length)
- case 'ascii':
- return asciiWrite(this, string, offset, length)
- case 'latin1':
- case 'binary':
- return latin1Write(this, string, offset, length)
- case 'base64':
- // Warning: maxLength not taken into account in base64Write
- return base64Write(this, string, offset, length)
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return ucs2Write(this, string, offset, length)
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
- }
- function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
- }
- function utf8Slice (buf, start, end) {
- end = Math.min(buf.length, end)
- var res = []
- var i = start
- while (i < end) {
- var firstByte = buf[i]
- var codePoint = null
- var bytesPerSequence = (firstByte > 0xEF) ? 4
- : (firstByte > 0xDF) ? 3
- : (firstByte > 0xBF) ? 2
- : 1
- if (i + bytesPerSequence <= end) {
- var secondByte, thirdByte, fourthByte, tempCodePoint
- switch (bytesPerSequence) {
- case 1:
- if (firstByte < 0x80) {
- codePoint = firstByte
- }
- break
- case 2:
- secondByte = buf[i + 1]
- if ((secondByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
- if (tempCodePoint > 0x7F) {
- codePoint = tempCodePoint
- }
- }
- break
- case 3:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
- codePoint = tempCodePoint
- }
- }
- break
- case 4:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- fourthByte = buf[i + 3]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
- codePoint = tempCodePoint
- }
- }
- }
- }
- if (codePoint === null) {
- // we did not generate a valid codePoint so insert a
- // replacement char (U+FFFD) and advance only 1 byte
- codePoint = 0xFFFD
- bytesPerSequence = 1
- } else if (codePoint > 0xFFFF) {
- // encode to utf16 (surrogate pair dance)
- codePoint -= 0x10000
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
- codePoint = 0xDC00 | codePoint & 0x3FF
- }
- res.push(codePoint)
- i += bytesPerSequence
- }
- return decodeCodePointsArray(res)
- }
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
- // the lowest limit is Chrome, with 0x10000 args.
- // We go 1 magnitude less, for safety
- var MAX_ARGUMENTS_LENGTH = 0x1000
- function decodeCodePointsArray (codePoints) {
- var len = codePoints.length
- if (len <= MAX_ARGUMENTS_LENGTH) {
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
- }
- // Decode in chunks to avoid "call stack size exceeded".
- var res = ''
- var i = 0
- while (i < len) {
- res += String.fromCharCode.apply(
- String,
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
- )
- }
- return res
- }
- function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
- }
- function latin1Slice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
- }
- function hexSlice (buf, start, end) {
- var len = buf.length
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
- var out = ''
- for (var i = start; i < end; ++i) {
- out += toHex(buf[i])
- }
- return out
- }
- function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
- }
- return res
- }
- Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
- if (end < start) end = start
- var newBuf = this.subarray(start, end)
- // Return an augmented `Uint8Array` instance
- newBuf.__proto__ = Buffer.prototype
- return newBuf
- }
- /*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
- function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
- }
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- return val
- }
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
- return val
- }
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
- }
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
- }
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
- }
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
- }
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
- }
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
- return val
- }
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
- }
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
- }
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
- }
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
- }
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
- }
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
- }
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
- }
- function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- }
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- this[offset] = (value & 0xff)
- return offset + 1
- }
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = (value & 0xff)
- return offset + 4
- }
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
- var i = 0
- var mul = 1
- var sub = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
- var i = byteLength - 1
- var mul = 1
- var sub = 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
- return offset + byteLength
- }
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (value < 0) value = 0xff + value + 1
- this[offset] = (value & 0xff)
- return offset + 1
- }
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- return offset + 4
- }
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
- function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- if (offset < 0) throw new RangeError('Index out of range')
- }
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
- }
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
- }
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
- }
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
- }
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
- }
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (targetStart >= target.length) targetStart = target.length
- if (!targetStart) targetStart = 0
- if (end > 0 && end < start) end = start
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
- // Fatal error conditions
- if (targetStart < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - targetStart < end - start) {
- end = target.length - targetStart + start
- }
- var len = end - start
- var i
- if (this === target && start < targetStart && targetStart < end) {
- // descending copy from end
- for (i = len - 1; i >= 0; --i) {
- target[i + targetStart] = this[i + start]
- }
- } else if (len < 1000) {
- // ascending copy from start
- for (i = 0; i < len; ++i) {
- target[i + targetStart] = this[i + start]
- }
- } else {
- Uint8Array.prototype.set.call(
- target,
- this.subarray(start, start + len),
- targetStart
- )
- }
- return len
- }
- // Usage:
- // buffer.fill(number[, offset[, end]])
- // buffer.fill(buffer[, offset[, end]])
- // buffer.fill(string[, offset[, end]][, encoding])
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
- // Handle string cases:
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = this.length
- } else if (typeof end === 'string') {
- encoding = end
- end = this.length
- }
- if (val.length === 1) {
- var code = val.charCodeAt(0)
- if (code < 256) {
- val = code
- }
- }
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- } else if (typeof val === 'number') {
- val = val & 255
- }
- // Invalid ranges are not set to a default, so can range check early.
- if (start < 0 || this.length < start || this.length < end) {
- throw new RangeError('Out of range index')
- }
- if (end <= start) {
- return this
- }
- start = start >>> 0
- end = end === undefined ? this.length : end >>> 0
- if (!val) val = 0
- var i
- if (typeof val === 'number') {
- for (i = start; i < end; ++i) {
- this[i] = val
- }
- } else {
- var bytes = Buffer.isBuffer(val)
- ? val
- : new Buffer(val, encoding)
- var len = bytes.length
- for (i = 0; i < end - start; ++i) {
- this[i + start] = bytes[i % len]
- }
- }
- return this
- }
- // HELPER FUNCTIONS
- // ================
- var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
- function base64clean (str) {
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = stringtrim(str).replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
- }
- function stringtrim (str) {
- if (str.trim) return str.trim()
- return str.replace(/^\s+|\s+$/g, '')
- }
- function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
- }
- function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
- for (var i = 0; i < length; ++i) {
- codePoint = string.charCodeAt(i)
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (!leadSurrogate) {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- }
- // valid lead
- leadSurrogate = codePoint
- continue
- }
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- }
- // valid surrogate pair
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- }
- leadSurrogate = null
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x110000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
- return bytes
- }
- function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
- }
- function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- if ((units -= 2) < 0) break
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
- return byteArray
- }
- function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
- }
- function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; ++i) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
- }
- function isnan (val) {
- return val !== val // eslint-disable-line no-self-compare
- }
- },{"base64-js":62,"ieee754":68}],66:[function(require,module,exports){
- (function (Buffer){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(arg) {
- if (Array.isArray) {
- return Array.isArray(arg);
- }
- return objectToString(arg) === '[object Array]';
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- exports.isBuffer = Buffer.isBuffer;
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
- },{"../../is-buffer/index.js":70}],67:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
- }
- module.exports = EventEmitter;
- // Backwards-compat with node 0.10.x
- EventEmitter.EventEmitter = EventEmitter;
- EventEmitter.prototype._events = undefined;
- EventEmitter.prototype._maxListeners = undefined;
- // By default EventEmitters will print a warning if more than 10 listeners are
- // added to it. This is a useful default which helps finding memory leaks.
- EventEmitter.defaultMaxListeners = 10;
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
- };
- EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
- if (!this._events)
- this._events = {};
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- } else {
- // At least give some kind of context to the user
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
- err.context = er;
- throw err;
- }
- }
- }
- handler = this._events[type];
- if (isUndefined(handler))
- return false;
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- args = Array.prototype.slice.call(arguments, 1);
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- args = Array.prototype.slice.call(arguments, 1);
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
- return true;
- };
- EventEmitter.prototype.addListener = function(type, listener) {
- var m;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events)
- this._events = {};
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
- return this;
- };
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
- EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- var fired = false;
- function g() {
- this.removeListener(type, g);
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
- g.listener = listener;
- this.on(type, g);
- return this;
- };
- // emits a 'removeListener' event iff the listener was removed
- EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
- if (!this._events || !this._events[type])
- return this;
- list = this._events[type];
- length = list.length;
- position = -1;
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
- if (position < 0)
- return this;
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
- return this;
- };
- EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
- if (!this._events)
- return this;
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
- listeners = this._events[type];
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else if (listeners) {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
- return this;
- };
- EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
- };
- EventEmitter.prototype.listenerCount = function(type) {
- if (this._events) {
- var evlistener = this._events[type];
- if (isFunction(evlistener))
- return 1;
- else if (evlistener)
- return evlistener.length;
- }
- return 0;
- };
- EventEmitter.listenerCount = function(emitter, type) {
- return emitter.listenerCount(type);
- };
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- function isUndefined(arg) {
- return arg === void 0;
- }
- },{}],68:[function(require,module,exports){
- exports.read = function (buffer, offset, isLE, mLen, nBytes) {
- var e, m
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var nBits = -7
- var i = isLE ? (nBytes - 1) : 0
- var d = isLE ? -1 : 1
- var s = buffer[offset + i]
- i += d
- e = s & ((1 << (-nBits)) - 1)
- s >>= (-nBits)
- nBits += eLen
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
- m = e & ((1 << (-nBits)) - 1)
- e >>= (-nBits)
- nBits += mLen
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
- if (e === 0) {
- e = 1 - eBias
- } else if (e === eMax) {
- return m ? NaN : ((s ? -1 : 1) * Infinity)
- } else {
- m = m + Math.pow(2, mLen)
- e = e - eBias
- }
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
- }
- exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
- var e, m, c
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
- var i = isLE ? 0 : (nBytes - 1)
- var d = isLE ? 1 : -1
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
- value = Math.abs(value)
- if (isNaN(value) || value === Infinity) {
- m = isNaN(value) ? 1 : 0
- e = eMax
- } else {
- e = Math.floor(Math.log(value) / Math.LN2)
- if (value * (c = Math.pow(2, -e)) < 1) {
- e--
- c *= 2
- }
- if (e + eBias >= 1) {
- value += rt / c
- } else {
- value += rt * Math.pow(2, 1 - eBias)
- }
- if (value * c >= 2) {
- e++
- c /= 2
- }
- if (e + eBias >= eMax) {
- m = 0
- e = eMax
- } else if (e + eBias >= 1) {
- m = (value * c - 1) * Math.pow(2, mLen)
- e = e + eBias
- } else {
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
- e = 0
- }
- }
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
- e = (e << mLen) | m
- eLen += mLen
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
- buffer[offset + i - d] |= s * 128
- }
- },{}],69:[function(require,module,exports){
- arguments[4][34][0].apply(exports,arguments)
- },{"dup":34}],70:[function(require,module,exports){
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
- * @license MIT
- */
- // The _isBuffer check is for Safari 5-7 support, because it's missing
- // Object.prototype.constructor. Remove this eventually
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
- // For Node v0.10 support. Remove this eventually.
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
- },{}],71:[function(require,module,exports){
- var toString = {}.toString;
- module.exports = Array.isArray || function (arr) {
- return toString.call(arr) == '[object Array]';
- };
- },{}],72:[function(require,module,exports){
- (function (process){
- 'use strict';
- if (!process.version ||
- process.version.indexOf('v0.') === 0 ||
- process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
- module.exports = nextTick;
- } else {
- module.exports = process.nextTick;
- }
- function nextTick(fn, arg1, arg2, arg3) {
- if (typeof fn !== 'function') {
- throw new TypeError('"callback" argument must be a function');
- }
- var len = arguments.length;
- var args, i;
- switch (len) {
- case 0:
- case 1:
- return process.nextTick(fn);
- case 2:
- return process.nextTick(function afterTickOne() {
- fn.call(null, arg1);
- });
- case 3:
- return process.nextTick(function afterTickTwo() {
- fn.call(null, arg1, arg2);
- });
- case 4:
- return process.nextTick(function afterTickThree() {
- fn.call(null, arg1, arg2, arg3);
- });
- default:
- args = new Array(len - 1);
- i = 0;
- while (i < args.length) {
- args[i++] = arguments[i];
- }
- return process.nextTick(function afterTick() {
- fn.apply(null, args);
- });
- }
- }
- }).call(this,require('_process'))
- },{"_process":73}],73:[function(require,module,exports){
- // shim for using process in browser
- var process = module.exports = {};
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
- var cachedSetTimeout;
- var cachedClearTimeout;
- function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
- }
- function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
- }
- (function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
- } ())
- function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // 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
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
- }
- function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // 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.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
- }
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
- }
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
- };
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
- function noop() {}
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
- },{}],74:[function(require,module,exports){
- module.exports = require("./lib/_stream_duplex.js")
- },{"./lib/_stream_duplex.js":75}],75:[function(require,module,exports){
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
- 'use strict';
- /*<replacement>*/
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- keys.push(key);
- }return keys;
- };
- /*</replacement>*/
- module.exports = Duplex;
- /*<replacement>*/
- var processNextTick = require('process-nextick-args');
- /*</replacement>*/
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- var Readable = require('./_stream_readable');
- var Writable = require('./_stream_writable');
- util.inherits(Duplex, Readable);
- var keys = objectKeys(Writable.prototype);
- for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
- }
- function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
- Readable.call(this, options);
- Writable.call(this, options);
- if (options && options.readable === false) this.readable = false;
- if (options && options.writable === false) this.writable = false;
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
- this.once('end', onend);
- }
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended) return;
- // no more data can be written.
- // But allow more writes to happen in this tick.
- processNextTick(onEndNT, this);
- }
- function onEndNT(self) {
- self.end();
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- },{"./_stream_readable":77,"./_stream_writable":79,"core-util-is":66,"inherits":69,"process-nextick-args":72}],76:[function(require,module,exports){
- // a passthrough stream.
- // basically just the most minimal sort of Transform stream.
- // Every written chunk gets output as-is.
- 'use strict';
- module.exports = PassThrough;
- var Transform = require('./_stream_transform');
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- util.inherits(PassThrough, Transform);
- function PassThrough(options) {
- if (!(this instanceof PassThrough)) return new PassThrough(options);
- Transform.call(this, options);
- }
- PassThrough.prototype._transform = function (chunk, encoding, cb) {
- cb(null, chunk);
- };
- },{"./_stream_transform":78,"core-util-is":66,"inherits":69}],77:[function(require,module,exports){
- (function (process){
- 'use strict';
- module.exports = Readable;
- /*<replacement>*/
- var processNextTick = require('process-nextick-args');
- /*</replacement>*/
- /*<replacement>*/
- var isArray = require('isarray');
- /*</replacement>*/
- /*<replacement>*/
- var Duplex;
- /*</replacement>*/
- Readable.ReadableState = ReadableState;
- /*<replacement>*/
- var EE = require('events').EventEmitter;
- var EElistenerCount = function (emitter, type) {
- return emitter.listeners(type).length;
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = require('st' + 'ream');
- } catch (_) {} finally {
- if (!Stream) Stream = require('events').EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = require('buffer').Buffer;
- /*<replacement>*/
- var bufferShim = require('buffer-shims');
- /*</replacement>*/
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- /*<replacement>*/
- var debugUtil = require('util');
- var debug = void 0;
- if (debugUtil && debugUtil.debuglog) {
- debug = debugUtil.debuglog('stream');
- } else {
- debug = function () {};
- }
- /*</replacement>*/
- var BufferList = require('./internal/streams/BufferList');
- var StringDecoder;
- util.inherits(Readable, Stream);
- function prependListener(emitter, event, fn) {
- // Sadly this is not cacheable as some libraries bundle their own
- // event emitter implementation with them.
- if (typeof emitter.prependListener === 'function') {
- return emitter.prependListener(event, fn);
- } else {
- // This is a hack to make sure that our error handler is attached before any
- // userland ones. NEVER DO THIS. This is here only because this code needs
- // to continue to work with older versions of Node.js that do not include
- // the prependListener() method. The goal is to eventually remove this hack.
- 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]];
- }
- }
- function ReadableState(options, stream) {
- Duplex = Duplex || require('./_stream_duplex');
- options = options || {};
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- // A linked list is used to store data chunks instead of an array because the
- // linked list can remove elements from the beginning faster than
- // array.shift()
- this.buffer = new BufferList();
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- this.resumeScheduled = false;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
- function Readable(options) {
- Duplex = Duplex || require('./_stream_duplex');
- if (!(this instanceof Readable)) return new Readable(options);
- this._readableState = new ReadableState(options, this);
- // legacy
- this.readable = true;
- if (options && typeof options.read === 'function') this._read = options.read;
- Stream.call(this);
- }
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function (chunk, encoding) {
- var state = this._readableState;
- if (!state.objectMode && typeof chunk === 'string') {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = bufferShim.from(chunk, encoding);
- encoding = '';
- }
- }
- return readableAddChunk(this, state, chunk, encoding, false);
- };
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function (chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
- Readable.prototype.isPaused = function () {
- return this._readableState.flowing === false;
- };
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null) {
- state.reading = false;
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var _e = new Error('stream.unshift() after end event');
- stream.emit('error', _e);
- } else {
- var skipAdd;
- if (state.decoder && !addToFront && !encoding) {
- chunk = state.decoder.write(chunk);
- skipAdd = !state.objectMode && chunk.length === 0;
- }
- if (!addToFront) state.reading = false;
- // Don't add to the buffer if we've decoded to an empty string chunk and
- // we're not in object mode
- if (!skipAdd) {
- // if we want the data now, just emit it.
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
- if (state.needReadable) emitReadable(stream);
- }
- }
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
- return needMoreData(state);
- }
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
- }
- // backwards compatibility.
- Readable.prototype.setEncoding = function (enc) {
- if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
- };
- // Don't raise the hwm > 8MB
- var MAX_HWM = 0x800000;
- function computeNewHighWaterMark(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2 to prevent increasing hwm excessively in
- // tiny amounts
- n--;
- n |= n >>> 1;
- n |= n >>> 2;
- n |= n >>> 4;
- n |= n >>> 8;
- n |= n >>> 16;
- n++;
- }
- return n;
- }
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function howMuchToRead(n, state) {
- if (n <= 0 || state.length === 0 && state.ended) return 0;
- if (state.objectMode) return 1;
- if (n !== n) {
- // Only flow one buffer at a time
- if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
- }
- // If we're asking for more than the current hwm, then raise the hwm.
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
- if (n <= state.length) return n;
- // Don't have enough
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- }
- return state.length;
- }
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function (n) {
- debug('read', n);
- n = parseInt(n, 10);
- var state = this._readableState;
- var nOrig = n;
- if (n !== 0) state.emittedReadable = false;
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
- return null;
- }
- n = howMuchToRead(n, state);
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0) endReadable(this);
- return null;
- }
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- } else if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0) state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (!state.reading) n = howMuchToRead(nOrig, state);
- }
- var ret;
- if (n > 0) ret = fromList(n, state);else ret = null;
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- } else {
- state.length -= n;
- }
- if (state.length === 0) {
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (!state.ended) state.needReadable = true;
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended) endReadable(this);
- }
- if (ret !== null) this.emit('data', ret);
- return ret;
- };
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
- function onEofChunk(stream, state) {
- if (state.ended) return;
- if (state.decoder) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
- }
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
- }
- }
- function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
- }
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- processNextTick(maybeReadMore_, stream, state);
- }
- }
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;else len = state.length;
- }
- state.readingMore = false;
- }
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function (n) {
- this.emit('error', new Error('_read() is not implemented'));
- };
- Readable.prototype.pipe = function (dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- debug('onunpipe');
- if (readable === src) {
- cleanup();
- }
- }
- function onend() {
- debug('onend');
- dest.end();
- }
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
- var cleanedUp = false;
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- src.removeListener('data', ondata);
- cleanedUp = true;
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
- }
- // If the user pushes more data while we're writing to dest then we'll end up
- // in ondata again. However, we only want to increase awaitDrain once because
- // dest will only emit one 'drain' event for the multiple writes.
- // => Introduce a guard on increasing awaitDrain.
- var increasedAwaitDrain = false;
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- increasedAwaitDrain = false;
- var ret = dest.write(chunk);
- if (false === ret && !increasedAwaitDrain) {
- // If the user unpiped during `dest.write()`, it is possible
- // to get stuck in a permanently paused state if that write
- // also returned false.
- // => Check whether `dest` is still a piping destination.
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
- debug('false write response, pause', src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- increasedAwaitDrain = true;
- }
- src.pause();
- }
- }
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
- }
- // Make sure our error handler is attached before userland ones.
- prependListener(dest, 'error', onerror);
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
- return dest;
- };
- function pipeOnDrain(src) {
- return function () {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain) state.awaitDrain--;
- if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
- }
- Readable.prototype.unpipe = function (dest) {
- var state = this._readableState;
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0) return this;
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes) return this;
- if (!dest) dest = state.pipes;
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest) dest.emit('unpipe', this);
- return this;
- }
- // slow case. multiple pipe destinations.
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- for (var i = 0; i < len; i++) {
- dests[i].emit('unpipe', this);
- }return this;
- }
- // try to find the right one.
- var index = indexOf(state.pipes, dest);
- if (index === -1) return this;
- state.pipes.splice(index, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
- dest.emit('unpipe', this);
- return this;
- };
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function (ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
- if (ev === 'data') {
- // Start flowing on next tick if stream isn't explicitly paused
- if (this._readableState.flowing !== false) this.resume();
- } else if (ev === 'readable') {
- var state = this._readableState;
- if (!state.endEmitted && !state.readableListening) {
- state.readableListening = state.needReadable = true;
- state.emittedReadable = false;
- if (!state.reading) {
- processNextTick(nReadingNextTick, this);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
- function nReadingNextTick(self) {
- debug('readable nexttick read 0');
- self.read(0);
- }
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function () {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- resume(this, state);
- }
- return this;
- };
- function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- processNextTick(resume_, stream, state);
- }
- }
- function resume_(stream, state) {
- if (!state.reading) {
- debug('resume read 0');
- stream.read(0);
- }
- state.resumeScheduled = false;
- state.awaitDrain = 0;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading) stream.read(0);
- }
- Readable.prototype.pause = function () {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
- };
- function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- while (state.flowing && stream.read() !== null) {}
- }
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function (stream) {
- var state = this._readableState;
- var paused = false;
- var self = this;
- stream.on('end', function () {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) self.push(chunk);
- }
- self.push(null);
- });
- stream.on('data', function (chunk) {
- debug('wrapped data');
- if (state.decoder) chunk = state.decoder.write(chunk);
- // don't skip over falsy values in objectMode
- if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (this[i] === undefined && typeof stream[i] === 'function') {
- this[i] = function (method) {
- return function () {
- return stream[method].apply(stream, arguments);
- };
- }(i);
- }
- }
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function (ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function (n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
- return self;
- };
- // exposed for testing purposes only.
- Readable._fromList = fromList;
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function fromList(n, state) {
- // nothing buffered
- if (state.length === 0) return null;
- var ret;
- if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
- // read it all, truncate the list
- 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);
- state.buffer.clear();
- } else {
- // read part of list
- ret = fromListPartial(n, state.buffer, state.decoder);
- }
- return ret;
- }
- // Extracts only enough buffered data to satisfy the amount requested.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function fromListPartial(n, list, hasStrings) {
- var ret;
- if (n < list.head.data.length) {
- // slice is the same for buffers and strings
- ret = list.head.data.slice(0, n);
- list.head.data = list.head.data.slice(n);
- } else if (n === list.head.data.length) {
- // first chunk is a perfect match
- ret = list.shift();
- } else {
- // result spans more than one buffer
- ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
- }
- return ret;
- }
- // Copies a specified amount of characters from the list of buffered data
- // chunks.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function copyFromBufferString(n, list) {
- var p = list.head;
- var c = 1;
- var ret = p.data;
- n -= ret.length;
- while (p = p.next) {
- var str = p.data;
- var nb = n > str.length ? str.length : n;
- if (nb === str.length) ret += str;else ret += str.slice(0, n);
- n -= nb;
- if (n === 0) {
- if (nb === str.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = str.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
- }
- // Copies a specified amount of bytes from the list of buffered data chunks.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function copyFromBuffer(n, list) {
- var ret = bufferShim.allocUnsafe(n);
- var p = list.head;
- var c = 1;
- p.data.copy(ret);
- n -= p.data.length;
- while (p = p.next) {
- var buf = p.data;
- var nb = n > buf.length ? buf.length : n;
- buf.copy(ret, ret.length - n, 0, nb);
- n -= nb;
- if (n === 0) {
- if (nb === buf.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = buf.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
- }
- function endReadable(stream) {
- var state = stream._readableState;
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
- if (!state.endEmitted) {
- state.ended = true;
- processNextTick(endReadableNT, state, stream);
- }
- }
- function endReadableNT(state, stream) {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- }
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
- function indexOf(xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- }).call(this,require('_process'))
- },{"./_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){
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
- 'use strict';
- module.exports = Transform;
- var Duplex = require('./_stream_duplex');
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- util.inherits(Transform, Duplex);
- function TransformState(stream) {
- this.afterTransform = function (er, data) {
- return afterTransform(stream, er, data);
- };
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- this.writeencoding = null;
- }
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
- var cb = ts.writecb;
- if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
- ts.writechunk = null;
- ts.writecb = null;
- if (data !== null && data !== undefined) stream.push(data);
- cb(er);
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
- function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
- Duplex.call(this, options);
- this._transformState = new TransformState(this);
- var stream = this;
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
- if (typeof options.flush === 'function') this._flush = options.flush;
- }
- // When the writable side finishes, then flush out anything remaining.
- this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er, data) {
- done(stream, er, data);
- });else done(stream);
- });
- }
- Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('_transform() is not implemented');
- };
- Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
- };
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function (n) {
- var ts = this._transformState;
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
- function done(stream, er, data) {
- if (er) return stream.emit('error', er);
- if (data !== null && data !== undefined) stream.push(data);
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
- if (ws.length) throw new Error('Calling transform done when ws.length != 0');
- if (ts.transforming) throw new Error('Calling transform done when still transforming');
- return stream.push(null);
- }
- },{"./_stream_duplex":75,"core-util-is":66,"inherits":69}],79:[function(require,module,exports){
- (function (process){
- // A bit simpler than readable streams.
- // Implement an async ._write(chunk, encoding, cb), and it'll handle all
- // the drain event emission and buffering.
- 'use strict';
- module.exports = Writable;
- /*<replacement>*/
- var processNextTick = require('process-nextick-args');
- /*</replacement>*/
- /*<replacement>*/
- var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
- /*</replacement>*/
- /*<replacement>*/
- var Duplex;
- /*</replacement>*/
- Writable.WritableState = WritableState;
- /*<replacement>*/
- var util = require('core-util-is');
- util.inherits = require('inherits');
- /*</replacement>*/
- /*<replacement>*/
- var internalUtil = {
- deprecate: require('util-deprecate')
- };
- /*</replacement>*/
- /*<replacement>*/
- var Stream;
- (function () {
- try {
- Stream = require('st' + 'ream');
- } catch (_) {} finally {
- if (!Stream) Stream = require('events').EventEmitter;
- }
- })();
- /*</replacement>*/
- var Buffer = require('buffer').Buffer;
- /*<replacement>*/
- var bufferShim = require('buffer-shims');
- /*</replacement>*/
- util.inherits(Writable, Stream);
- function nop() {}
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- this.next = null;
- }
- function WritableState(options, stream) {
- Duplex = Duplex || require('./_stream_duplex');
- options = options || {};
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
- // cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
- // drain event flag.
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
- // a flag to see when we're in the middle of a write.
- this.writing = false;
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function (er) {
- onwrite(stream, er);
- };
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
- // the amount that is being written when _write is called.
- this.writelen = 0;
- this.bufferedRequest = null;
- this.lastBufferedRequest = null;
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
- // count buffered requests
- this.bufferedRequestCount = 0;
- // allocate the first CorkedRequest, there is always
- // one allocated and free to use, and we maintain at most two
- this.corkedRequestsFree = new CorkedRequest(this);
- }
- WritableState.prototype.getBuffer = function getBuffer() {
- var current = this.bufferedRequest;
- var out = [];
- while (current) {
- out.push(current);
- current = current.next;
- }
- return out;
- };
- (function () {
- try {
- Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function () {
- return this.getBuffer();
- }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
- });
- } catch (_) {}
- })();
- // Test _writableState for inheritance to account for Duplex streams,
- // whose prototype chain only points to Readable.
- var realHasInstance;
- if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
- realHasInstance = Function.prototype[Symbol.hasInstance];
- Object.defineProperty(Writable, Symbol.hasInstance, {
- value: function (object) {
- if (realHasInstance.call(this, object)) return true;
- return object && object._writableState instanceof WritableState;
- }
- });
- } else {
- realHasInstance = function (object) {
- return object instanceof this;
- };
- }
- function Writable(options) {
- Duplex = Duplex || require('./_stream_duplex');
- // Writable ctor is applied to Duplexes, too.
- // `realHasInstance` is necessary because using plain `instanceof`
- // would return false, as no `_writableState` property is attached.
- // Trying to use the custom `instanceof` for Writable here will also break the
- // Node.js LazyTransform implementation, which has a non-trivial getter for
- // `_writableState` that would lead to infinite recursion.
- if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
- return new Writable(options);
- }
- this._writableState = new WritableState(options, this);
- // legacy.
- this.writable = true;
- if (options) {
- if (typeof options.write === 'function') this._write = options.write;
- if (typeof options.writev === 'function') this._writev = options.writev;
- }
- Stream.call(this);
- }
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function () {
- this.emit('error', new Error('Cannot pipe, not readable'));
- };
- function writeAfterEnd(stream, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- processNextTick(cb, er);
- }
- // If we get something that is not a buffer, string, null, or undefined,
- // and we're not in objectMode, then that's an error.
- // Otherwise stream chunks are all considered to be of length=1, and the
- // watermarks determine how many objects to keep in the buffer, rather than
- // how many bytes or characters.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- var er = false;
- // Always throw error if a null is written
- // if we are not in object mode then throw
- // if it is not a buffer, string, or undefined.
- if (chunk === null) {
- er = new TypeError('May not write null values to stream');
- } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- if (er) {
- stream.emit('error', er);
- processNextTick(cb, er);
- valid = false;
- }
- return valid;
- }
- Writable.prototype.write = function (chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
- if (typeof cb !== 'function') cb = nop;
- if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
- }
- return ret;
- };
- Writable.prototype.cork = function () {
- var state = this._writableState;
- state.corked++;
- };
- Writable.prototype.uncork = function () {
- var state = this._writableState;
- if (state.corked) {
- state.corked--;
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
- }
- };
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
- // node::ParseEncoding() requires lower case.
- if (typeof encoding === 'string') encoding = encoding.toLowerCase();
- 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);
- this._writableState.defaultEncoding = encoding;
- return this;
- };
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
- chunk = bufferShim.from(chunk, encoding);
- }
- return chunk;
- }
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
- var len = state.objectMode ? 1 : chunk.length;
- state.length += len;
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret) state.needDrain = true;
- if (state.writing || state.corked) {
- var last = state.lastBufferedRequest;
- state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
- if (last) {
- last.next = state.lastBufferedRequest;
- } else {
- state.bufferedRequest = state.lastBufferedRequest;
- }
- state.bufferedRequestCount += 1;
- } else {
- doWrite(stream, state, false, len, chunk, encoding, cb);
- }
- return ret;
- }
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
- function onwriteError(stream, state, sync, er, cb) {
- --state.pendingcb;
- if (sync) processNextTick(cb, er);else cb(er);
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
- onwriteStateUpdate(state);
- if (er) onwriteError(stream, state, sync, er, cb);else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(state);
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
- clearBuffer(stream, state);
- }
- if (sync) {
- /*<replacement>*/
- asyncWrite(afterWrite, stream, state, finished, cb);
- /*</replacement>*/
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
- function afterWrite(stream, state, finished, cb) {
- if (!finished) onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
- }
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- var entry = state.bufferedRequest;
- if (stream._writev && entry && entry.next) {
- // Fast case, write everything using _writev()
- var l = state.bufferedRequestCount;
- var buffer = new Array(l);
- var holder = state.corkedRequestsFree;
- holder.entry = entry;
- var count = 0;
- while (entry) {
- buffer[count] = entry;
- entry = entry.next;
- count += 1;
- }
- doWrite(stream, state, true, state.length, buffer, '', holder.finish);
- // doWrite is almost always async, defer these to save a bit of time
- // as the hot path ends with doWrite
- state.pendingcb++;
- state.lastBufferedRequest = null;
- if (holder.next) {
- state.corkedRequestsFree = holder.next;
- holder.next = null;
- } else {
- state.corkedRequestsFree = new CorkedRequest(state);
- }
- } else {
- // Slow case, write chunks one-by-one
- while (entry) {
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
- doWrite(stream, state, false, len, chunk, encoding, cb);
- entry = entry.next;
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- break;
- }
- }
- if (entry === null) state.lastBufferedRequest = null;
- }
- state.bufferedRequestCount = 0;
- state.bufferedRequest = entry;
- state.bufferProcessing = false;
- }
- Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('_write() is not implemented'));
- };
- Writable.prototype._writev = null;
- Writable.prototype.end = function (chunk, encoding, cb) {
- var state = this._writableState;
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
- if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished) endWritable(this, state, cb);
- };
- function needFinish(state) {
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
- }
- function prefinish(stream, state) {
- if (!state.prefinished) {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
- function finishMaybe(stream, state) {
- var need = needFinish(state);
- if (need) {
- if (state.pendingcb === 0) {
- prefinish(stream, state);
- state.finished = true;
- stream.emit('finish');
- } else {
- prefinish(stream, state);
- }
- }
- return need;
- }
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished) processNextTick(cb);else stream.once('finish', cb);
- }
- state.ended = true;
- stream.writable = false;
- }
- // It seems a linked list but it is not
- // there will be only 2 of these for each stream
- function CorkedRequest(state) {
- var _this = this;
- this.next = null;
- this.entry = null;
- this.finish = function (err) {
- var entry = _this.entry;
- _this.entry = null;
- while (entry) {
- var cb = entry.callback;
- state.pendingcb--;
- cb(err);
- entry = entry.next;
- }
- if (state.corkedRequestsFree) {
- state.corkedRequestsFree.next = _this;
- } else {
- state.corkedRequestsFree = _this;
- }
- };
- }
- }).call(this,require('_process'))
- },{"./_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){
- 'use strict';
- var Buffer = require('buffer').Buffer;
- /*<replacement>*/
- var bufferShim = require('buffer-shims');
- /*</replacement>*/
- module.exports = BufferList;
- function BufferList() {
- this.head = null;
- this.tail = null;
- this.length = 0;
- }
- BufferList.prototype.push = function (v) {
- var entry = { data: v, next: null };
- if (this.length > 0) this.tail.next = entry;else this.head = entry;
- this.tail = entry;
- ++this.length;
- };
- BufferList.prototype.unshift = function (v) {
- var entry = { data: v, next: this.head };
- if (this.length === 0) this.tail = entry;
- this.head = entry;
- ++this.length;
- };
- BufferList.prototype.shift = function () {
- if (this.length === 0) return;
- var ret = this.head.data;
- if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
- --this.length;
- return ret;
- };
- BufferList.prototype.clear = function () {
- this.head = this.tail = null;
- this.length = 0;
- };
- BufferList.prototype.join = function (s) {
- if (this.length === 0) return '';
- var p = this.head;
- var ret = '' + p.data;
- while (p = p.next) {
- ret += s + p.data;
- }return ret;
- };
- BufferList.prototype.concat = function (n) {
- if (this.length === 0) return bufferShim.alloc(0);
- if (this.length === 1) return this.head.data;
- var ret = bufferShim.allocUnsafe(n >>> 0);
- var p = this.head;
- var i = 0;
- while (p) {
- p.data.copy(ret, i);
- i += p.data.length;
- p = p.next;
- }
- return ret;
- };
- },{"buffer":65,"buffer-shims":64}],81:[function(require,module,exports){
- module.exports = require("./lib/_stream_passthrough.js")
- },{"./lib/_stream_passthrough.js":76}],82:[function(require,module,exports){
- (function (process){
- var Stream = (function (){
- try {
- return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
- } catch(_){}
- }());
- exports = module.exports = require('./lib/_stream_readable.js');
- exports.Stream = Stream || exports;
- exports.Readable = exports;
- exports.Writable = require('./lib/_stream_writable.js');
- exports.Duplex = require('./lib/_stream_duplex.js');
- exports.Transform = require('./lib/_stream_transform.js');
- exports.PassThrough = require('./lib/_stream_passthrough.js');
- if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
- module.exports = Stream;
- }
- }).call(this,require('_process'))
- },{"./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){
- module.exports = require("./lib/_stream_transform.js")
- },{"./lib/_stream_transform.js":78}],84:[function(require,module,exports){
- module.exports = require("./lib/_stream_writable.js")
- },{"./lib/_stream_writable.js":79}],85:[function(require,module,exports){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- module.exports = Stream;
- var EE = require('events').EventEmitter;
- var inherits = require('inherits');
- inherits(Stream, EE);
- Stream.Readable = require('readable-stream/readable.js');
- Stream.Writable = require('readable-stream/writable.js');
- Stream.Duplex = require('readable-stream/duplex.js');
- Stream.Transform = require('readable-stream/transform.js');
- Stream.PassThrough = require('readable-stream/passthrough.js');
- // Backwards-compat with node 0.4.x
- Stream.Stream = Stream;
- // old-style streams. Note that the pipe method (the only relevant
- // part of this class) is overridden in the Readable class.
- function Stream() {
- EE.call(this);
- }
- Stream.prototype.pipe = function(dest, options) {
- var source = this;
- function ondata(chunk) {
- if (dest.writable) {
- if (false === dest.write(chunk) && source.pause) {
- source.pause();
- }
- }
- }
- source.on('data', ondata);
- function ondrain() {
- if (source.readable && source.resume) {
- source.resume();
- }
- }
- dest.on('drain', ondrain);
- // If the 'end' option is not supplied, dest.end() will be called when
- // source gets the 'end' or 'close' events. Only dest.end() once.
- if (!dest._isStdio && (!options || options.end !== false)) {
- source.on('end', onend);
- source.on('close', onclose);
- }
- var didOnEnd = false;
- function onend() {
- if (didOnEnd) return;
- didOnEnd = true;
- dest.end();
- }
- function onclose() {
- if (didOnEnd) return;
- didOnEnd = true;
- if (typeof dest.destroy === 'function') dest.destroy();
- }
- // don't leave dangling pipes when there are errors.
- function onerror(er) {
- cleanup();
- if (EE.listenerCount(this, 'error') === 0) {
- throw er; // Unhandled stream error in pipe.
- }
- }
- source.on('error', onerror);
- dest.on('error', onerror);
- // remove all the event listeners that were added.
- function cleanup() {
- source.removeListener('data', ondata);
- dest.removeListener('drain', ondrain);
- source.removeListener('end', onend);
- source.removeListener('close', onclose);
- source.removeListener('error', onerror);
- dest.removeListener('error', onerror);
- source.removeListener('end', cleanup);
- source.removeListener('close', cleanup);
- dest.removeListener('close', cleanup);
- }
- source.on('end', cleanup);
- source.on('close', cleanup);
- dest.on('close', cleanup);
- dest.emit('pipe', source);
- // Allow for unix-like usage: A.pipe(B).pipe(C)
- return dest;
- };
- },{"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){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var Buffer = require('buffer').Buffer;
- var isBufferEncoding = Buffer.isEncoding
- || function(encoding) {
- switch (encoding && encoding.toLowerCase()) {
- 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;
- default: return false;
- }
- }
- function assertEncoding(encoding) {
- if (encoding && !isBufferEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
- }
- }
- // StringDecoder provides an interface for efficiently splitting a series of
- // buffers into a series of JS strings without breaking apart multi-byte
- // characters. CESU-8 is handled as part of the UTF-8 encoding.
- //
- // @TODO Handling all encodings inside a single object makes it very difficult
- // to reason about this code, so it should be split up in the future.
- // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
- // points as used by CESU-8.
- var StringDecoder = exports.StringDecoder = function(encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
- assertEncoding(encoding);
- switch (this.encoding) {
- case 'utf8':
- // CESU-8 represents each of Surrogate Pair by 3-bytes
- this.surrogateSize = 3;
- break;
- case 'ucs2':
- case 'utf16le':
- // UTF-16 represents each of Surrogate Pair by 2-bytes
- this.surrogateSize = 2;
- this.detectIncompleteChar = utf16DetectIncompleteChar;
- break;
- case 'base64':
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
- this.surrogateSize = 3;
- this.detectIncompleteChar = base64DetectIncompleteChar;
- break;
- default:
- this.write = passThroughWrite;
- return;
- }
- // Enough space to store all bytes of a single character. UTF-8 needs 4
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
- this.charBuffer = new Buffer(6);
- // Number of bytes received for the current incomplete multi-byte character.
- this.charReceived = 0;
- // Number of bytes expected for the current incomplete multi-byte character.
- this.charLength = 0;
- };
- // write decodes the given buffer and returns it as JS string that is
- // guaranteed to not contain any partial multi-byte characters. Any partial
- // character found at the end of the buffer is buffered up, and will be
- // returned when calling write again with the remaining bytes.
- //
- // Note: Converting a Buffer containing an orphan surrogate to a String
- // currently works, but converting a String to a Buffer (via `new Buffer`, or
- // Buffer#write) will replace incomplete surrogates with the unicode
- // replacement character. See https://codereview.chromium.org/121173009/ .
- StringDecoder.prototype.write = function(buffer) {
- var charStr = '';
- // if our last write ended with an incomplete multibyte character
- while (this.charLength) {
- // determine how many remaining bytes this buffer has to offer for this char
- var available = (buffer.length >= this.charLength - this.charReceived) ?
- this.charLength - this.charReceived :
- buffer.length;
- // add the new bytes to the char buffer
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
- this.charReceived += available;
- if (this.charReceived < this.charLength) {
- // still not enough chars in this buffer? wait for more ...
- return '';
- }
- // remove bytes belonging to the current character from the buffer
- buffer = buffer.slice(available, buffer.length);
- // get the character that was split
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- var charCode = charStr.charCodeAt(charStr.length - 1);
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- this.charLength += this.surrogateSize;
- charStr = '';
- continue;
- }
- this.charReceived = this.charLength = 0;
- // if there are no more bytes in this buffer, just emit our char
- if (buffer.length === 0) {
- return charStr;
- }
- break;
- }
- // determine and set charLength / charReceived
- this.detectIncompleteChar(buffer);
- var end = buffer.length;
- if (this.charLength) {
- // buffer the incomplete character bytes we got
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
- end -= this.charReceived;
- }
- charStr += buffer.toString(this.encoding, 0, end);
- var end = charStr.length - 1;
- var charCode = charStr.charCodeAt(end);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- var size = this.surrogateSize;
- this.charLength += size;
- this.charReceived += size;
- this.charBuffer.copy(this.charBuffer, size, 0, size);
- buffer.copy(this.charBuffer, 0, 0, size);
- return charStr.substring(0, end);
- }
- // or just emit the charStr
- return charStr;
- };
- // detectIncompleteChar determines if there is an incomplete UTF-8 character at
- // the end of the given buffer. If so, it sets this.charLength to the byte
- // length that character, and sets this.charReceived to the number of bytes
- // that are available for this character.
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
- // determine how many bytes we have to check at the end of this buffer
- var i = (buffer.length >= 3) ? 3 : buffer.length;
- // Figure out if one of the last i bytes of our buffer announces an
- // incomplete char.
- for (; i > 0; i--) {
- var c = buffer[buffer.length - i];
- // See http://en.wikipedia.org/wiki/UTF-8#Description
- // 110XXXXX
- if (i == 1 && c >> 5 == 0x06) {
- this.charLength = 2;
- break;
- }
- // 1110XXXX
- if (i <= 2 && c >> 4 == 0x0E) {
- this.charLength = 3;
- break;
- }
- // 11110XXX
- if (i <= 3 && c >> 3 == 0x1E) {
- this.charLength = 4;
- break;
- }
- }
- this.charReceived = i;
- };
- StringDecoder.prototype.end = function(buffer) {
- var res = '';
- if (buffer && buffer.length)
- res = this.write(buffer);
- if (this.charReceived) {
- var cr = this.charReceived;
- var buf = this.charBuffer;
- var enc = this.encoding;
- res += buf.slice(0, cr).toString(enc);
- }
- return res;
- };
- function passThroughWrite(buffer) {
- return buffer.toString(this.encoding);
- }
- function utf16DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 2;
- this.charLength = this.charReceived ? 2 : 0;
- }
- function base64DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 3;
- this.charLength = this.charReceived ? 3 : 0;
- }
- },{"buffer":65}],87:[function(require,module,exports){
- (function (global){
- /**
- * Module exports.
- */
- module.exports = deprecate;
- /**
- * Mark that a method should not be used.
- * Returns a modified function which warns once by default.
- *
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
- *
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
- * will throw an Error when invoked.
- *
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
- * will invoke `console.trace()` instead of `console.error()`.
- *
- * @param {Function} fn - the function to deprecate
- * @param {String} msg - the string to print to the console when `fn` is invoked
- * @returns {Function} a new "deprecated" version of `fn`
- * @api public
- */
- function deprecate (fn, msg) {
- if (config('noDeprecation')) {
- return fn;
- }
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (config('throwDeprecation')) {
- throw new Error(msg);
- } else if (config('traceDeprecation')) {
- console.trace(msg);
- } else {
- console.warn(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
- return deprecated;
- }
- /**
- * Checks `localStorage` for boolean values for the given `name`.
- *
- * @param {String} name
- * @returns {Boolean}
- * @api private
- */
- function config (name) {
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
- try {
- if (!global.localStorage) return false;
- } catch (_) {
- return false;
- }
- var val = global.localStorage[name];
- if (null == val) return false;
- return String(val).toLowerCase() === 'true';
- }
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{}],88:[function(require,module,exports){
- arguments[4][34][0].apply(exports,arguments)
- },{"dup":34}],89:[function(require,module,exports){
- module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object'
- && typeof arg.copy === 'function'
- && typeof arg.fill === 'function'
- && typeof arg.readUInt8 === 'function';
- }
- },{}],90:[function(require,module,exports){
- (function (process,global){
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
- var formatRegExp = /%[sdj%]/g;
- exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
- };
- // Mark that a method should not be used.
- // Returns a modified function which warns once by default.
- // If --no-deprecation is set, then it is a no-op.
- exports.deprecate = function(fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
- if (process.noDeprecation === true) {
- return fn;
- }
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
- return deprecated;
- };
- var debugs = {};
- var debugEnviron;
- exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
- }
- }
- return debugs[set];
- };
- /**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
- /* legacy: obj, showHidden, depth, colors*/
- function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
- }
- exports.inspect = inspect;
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
- inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
- };
- // Don't use 'blue' not visible on cmd.exe
- inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
- };
- function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
- }
- }
- function stylizeNoColor(str, styleType) {
- return str;
- }
- function arrayToHash(array) {
- var hash = {};
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
- return hash;
- }
- function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value)
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
- var base = '', array = false, braces = ['{', '}'];
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
- }
- }
- ctx.seen.push(value);
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
- });
- }
- ctx.seen.pop();
- return reduceToSingleString(output, base, braces);
- }
- function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value))
- return ctx.stylize('' + value, 'number');
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
- }
- function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
- }
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
- } else {
- output.push('');
- }
- }
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
- }
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
- }
- }
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
- return name + ': ' + str;
- }
- function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
- }
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(ar) {
- return Array.isArray(ar);
- }
- exports.isArray = isArray;
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
- function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
- function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
- function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
- exports.isBuffer = require('./support/isBuffer');
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
- function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
- }
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
- // 26 Feb 16:19:34
- function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
- }
- // log is just a thin wrapper to console.log that prepends a timestamp
- exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
- };
- /**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
- exports.inherits = require('inherits');
- exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
- };
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- },{"./support/isBuffer":89,"_process":73,"inherits":88}]},{},[1]);
- (function(web3){
- var MOVES = {
- SELECT : 3,
- BET : 5,
- CALL : 7,
- PROOF : 11,
- FOLD : 13,
- LEAVE : 17
- };
- var ROUNDTYPES = {
- READY : 666,
- SELECT : MOVES.SELECT,
- BET : MOVES.BET,
- CALLFOLD: MOVES.CALL * MOVES.FOLD,
- PROVE : MOVES.PROOF
- };
- var ROUNDS = [
- // ROUNDTYPES.READY,
- ROUNDTYPES.SELECT,
- ROUNDTYPES.BET,
- ROUNDTYPES.CALLFOLD,
- ROUNDTYPES.SELECT,
- ROUNDTYPES.BET,
- ROUNDTYPES.CALLFOLD,
- ROUNDTYPES.SELECT,
- ROUNDTYPES.BET,
- ROUNDTYPES.CALLFOLD,
- ROUNDTYPES.PROVE,
- ROUNDTYPES.BET,
- ROUNDTYPES.CALLFOLD,
- ROUNDTYPES.PROVE,
- ROUNDTYPES.PROVE
- ];
- var SELECTINDEXES = [1,0,0,2,0,0,3,0,0,5,0,0,6,7];
- var PROOFTOSELECT = [0,1,4,7];
- web3.Game = {
- MOVES : MOVES,
- ROUNDS : ROUNDS,
- ROUNDTYPES : ROUNDTYPES
- };
- var _stack = [];
- var _roundStack = [];
-
- var _isAlreadySelected = {
- };
- var currentState = {};
- var _gameState = {};
- var _onStateChange;
- var _onRoundChange;
- // SAVE MOVES //
- web3.Game.saveMove = function(move){
- currentState[move.who] = move;
- if(currentState[getOther(move.who)])
- return this.saveState();
- if(move.type == MOVES.FOLD){ // TODO -- this is propably wrong but i can hhandle it ftm
- return this.saveState();
- }
- return true;
- };
- web3.Game.isAvailableNow = function(type){
- return ROUNDS[_roundStack.length] % type == 0;
- }
- web3.Game.isValidMove = function(move){ // GAME STATE CONTRAINT FUNCTION
- var type = move.type;
- if(!this.isAvailableNow(type))return false;
- switch(type){
- case MOVES.SELECT :
- var opp = getOther(move.who);
- if(!isCorrectSelectIndex(move.data.selectIndex))return false;
- if(_gameState.selected[opp][move.data[opp] % 6])return false;
- if(_gameState.hidden[move.who][move.data.selectIndex])return false; // already selected
- if(move.data[move.who].length != 66)return false;
- return true;
- case MOVES.PROOF :
- var data = move.data[move.who];
- //if(web3.sha3(JSON.stringify(data)) != _roundStack[SELECTINDEXES.indexOf(move.data.selectIndex%4)][move.who].data[move.who])return false;
- if(_gameState.selected[getOther(move.who)][move.data[move.who] % 6])return false;
- if(_gameState.hidden[move.who][move.data.selectIndex%4] != web3.sha3(JSON.stringify(data)))return false;
- return true;
- case MOVES.BET :
- var data = move.data.amount;
- if( data < 0 || parseInt(data) != data)return false;
- if( _gameState.coins[move.who] < data )return false;
- if( _gameState.coins[getOther(move.who)] < data)return false;
- return true;
- case MOVES.FOLD :
- if( _gameState.bets[getOther(move.who)] < _gameState.bets[move.who] )return false;
- return true;
- case MOVES.CALL :
- return true;
- }
- };
- web3.Game.performMove = function(move){ // GAME STATE CHANGING FUNCTION
- if(!this.isValidMove(move))return false;
- switch(move.type){
- case MOVES.SELECT :
- var opp = getOther(move.who);
- _gameState.selected[opp][move.data[opp] % 6] = SELECTINDEXES[_roundStack.length];
- _gameState.hidden[move.who][move.data.selectIndex] = move.data[move.who]; // Dictionary of hidden hashes
- break;
- case MOVES.PROOF :
- var data = move.data[move.who];
- if(web3.sha3(JSON.stringify(data)) != _gameState.hidden[move.who][this.getCurrentProofIndex()%4])return false;
- _gameState.hidden[move.who][this.getCurrentProofIndex()%4] = data;
- break;
- case MOVES.BET :
- var data = move.data.amount;
- _gameState.coins[move.who] -= data;
- _gameState.pot += data;
- _gameState.bets[move.who] = data;
- break;
- case MOVES.FOLD :
- _gameState.fold[move.who] = true;
- break;
- case MOVES.CALL :
- var def = Math.step(_gameState.bets[getOther(move.who)] - _gameState.bets[move.who]);
- _gameState.coins[move.who] -= def;
- _gameState.pot += def;
- break;
- }
- return this.saveMove(move);
- };
- web3.Game.getCurrentProofIndex = function(){
- return SELECTINDEXES[_roundStack.length];
- };
- web3.Game.saveProof = function(index, proof){
- this.proofs[index] = proof;
- };
- // SAVE ROUND //
- web3.Game.saveRound = function(){
- _stack.push(_roundStack);
- _roundStack = [];
-
- // TODO calculate winner!!!
- //
- _isAlreadySelected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
- _isAlreadySelected[web3.eth.opponentAccount] = [0,0,0,0,0,0];
- _gameState.coins[web3.eth.defaultAccount] -= 1;
- _gameState.coins[web3.eth.opponentAccount] -= 1;
-
- _gameState.hidden[web3.eth.defaultAccount] = {};
- _gameState.hidden[web3.eth.opponentAccount] = {};
- _gameState.pot = 2;
- _gameState.round++;
- _gameState.roundstate = 0;
- _gameState.bets[web3.eth.defaultAccount] = 0;
- _gameState.bets[web3.eth.opponentAccount] = 0
- _gameState.selected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
- _gameState.selected[web3.eth.opponentAccount] = [0,0,0,0,0,0];
- _gameState.fold[web3.eth.defaultAccount] = false;
- _gameState.fold[web3.eth.opponentAccount] = false;
- this.proofs = {};
- this.saveToDB();
- if(_onRoundChange)_onRoundChange();
- return true;
- };
- // GAME STATE ///
- web3.Game.saveState = function(){
- _roundStack.push(currentState);
- _gameState.roundstate ++;
- currentState = {};
- if(_onStateChange)_onStateChange();
- if(this.isValidRound())return this.saveRound();
- this.saveToDB();
- return true;
- };
- web3.Game.checkRound = function(){
- if(this.isValidRound())return this.saveRound();
- return false;
- }
- web3.Game.setOnStateChange = function(fn){_onStateChange = fn;}
- web3.Game.clearOnStateChange = function(){delete _onStateChange;}
- web3.Game.setOnRoundChange = function(fn){_onRoundChange = fn;}
- web3.Game.clearOnRoundChange = function(){delete _onRoundChange;}
- // ROUND //
- // function hasRoundFinished(){
- // //_roundStack;
- // if(web3.Game.isValidRound(currentState)){
- // web3.Game.saveRound();
- // }
- // else{
- // // Something is invalid!!!
- // console.log(currentState);
- // throw new Error("This state is not valid! ^^");
- // }
- // }
- web3.Game._givemoney = function(addr){
- _gameState.coins[addr] += _gameState.pot;
- _gameState.pot = 0;
- };
- web3.Game.isValidRound = function(){
- if(_gameState.fold[web3.eth.defaultAccount]){
- this._givemoney(web3.eth.opponentAccount);
- return true;
- }
- if(_gameState.fold[web3.eth.opponentAccount]){
- this._givemoney(web3.eth.defaultAccount);
- return true;
- }
-
- if(_gameState.roundstate == SELECTINDEXES.length){
- var sums = this.findSums();
- if(sums[web3.eth.defaultAccount] > sums[web3.eth.opponentAccount]){ // TODO - check equality
- this._givemoney(web3.eth.defaultAccount);
- return true;
- }
- else{
- this._givemoney(web3.eth.opponentAccount);
- return true;
- }
- }
- return false;
- };
- // MOVE CREATION ///
- web3.Game._createMove = function (type, data){
- if( type != web3.Game.MOVES.SELECT &&
- type != web3.Game.MOVES.BET &&
- type != web3.Game.MOVES.FOLD &&
- type != web3.Game.MOVES.CALL &&
- type != web3.Game.MOVES.PROOF &&
- type != web3.Game.MOVES.LEAVE )
- throw new Error("This type of move doesnt exist. Type : " + type);
- var move = {
- who : web3.eth.defaultAccount,
- type : type,
- data : JSON.parse(JSON.stringify(data))
- //lastState : _calculateLastStateHash()
- };
- return move;
- };
-
- web3.Game.createSelectMove = function (mdata1, mdata2){
- if(!this.isAvailableNow(MOVES.SELECT))throw new Error("This type of move is not available now");
- data1 = this.applyRotation(mdata1);
- data2 = this.applyRotation(mdata2);
- if(data1 < 0 || data1 > 5 )throw new Error("A SELECT Move is always between [0-5]");
- if(data2 < 0 || data2 > 5 )throw new Error("A SELECT Move is always between [0-5]");
- if(_gameState.selected[web3.eth.opponentAccount][data2])throw new Error("You cannot select an already selected column");
- if(_isAlreadySelected[web3.eth.defaultAccount][data1])throw new Error("You cannot select an already selected column");
- var cryptoData1 = _findRandomBigNumber(data1, 6);
- var cryptoData2 = _findRandomBigNumber(data2, 6);
- _isAlreadySelected[web3.eth.defaultAccount][data1] = SELECTINDEXES[_roundStack.length];
- var cryptoData = {
- selectIndex : SELECTINDEXES[_roundStack.length]
- };
- cryptoData[web3.eth.defaultAccount] = web3.sha3(''+cryptoData1);
- cryptoData[web3.eth.opponentAccount] = cryptoData2;
-
- var move = this._createMove(web3.Game.MOVES.SELECT, cryptoData);
- cryptoData[web3.eth.defaultAccount] = cryptoData1;
- var proof = this.createProofMove(cryptoData);
- return {
- move : move,
- proof: proof
- };
- };
- web3.Game.createBetMove = function (amount){
- if(!this.isAvailableNow(MOVES.BET))throw new Error("This type of move is not available now");
- if(amount < 0 || parseInt(amount) != amount)throw new Error("Amount parameter must be positive integer or 0!")
- 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 );
- 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 );
- var cryptoData = {
- amount : amount
- };
- var move = this._createMove(web3.Game.MOVES.BET, cryptoData);
- return move;
- };
- web3.Game.createCallMove = function (data){
- if(!this.isAvailableNow(MOVES.CALL))throw new Error("This type of move is not available now");
- var cryptoData = {
- };
- var move = this._createMove(web3.Game.MOVES.CALL, cryptoData);
- return move;
- };
- web3.Game.createFoldMove = function (data){
- if(!this.isAvailableNow(MOVES.FOLD))throw new Error("This type of move is not available now");
- var cryptoData = {
- };
- var move = this._createMove(web3.Game.MOVES.FOLD, cryptoData);
- return move;
- };
- web3.Game.createProofMove = function (data){
- var r = this._createMove(web3.Game.MOVES.PROOF, data);
- return r;
- };
- web3.Game.getProofMove = function (index){
- return this.proofs[index];
- };
- web3.Game.saveToDB = function(){
- web3.db.putString(web3.db.DBNAME,"THEREAREDATA","true");
-
- web3.db.putString(web3.db.DBNAME,"_stack",JSON.stringify(_stack));
- web3.db.putString(web3.db.DBNAME,"_roundStack",JSON.stringify(_roundStack));
- web3.db.putString(web3.db.DBNAME,"_isAlreadySelected",JSON.stringify(_isAlreadySelected));
- web3.db.putString(web3.db.DBNAME,"_currentState",JSON.stringify(currentState));
- web3.db.putString(web3.db.DBNAME,"_gameState",JSON.stringify(_gameState));
- web3.db.putString(web3.db.DBNAME,"_stack",JSON.stringify(_stack));
- web3.db.putString(web3.db.DBNAME,"proofs",JSON.stringify(this.proofs));
- }
- web3.Game.clearDB = function(){
- web3.db.putString(web3.db.DBNAME,"THEREAREDATA",undefined);
- }
- web3.Game.loadFromDB = function(){
- if(!web3.db.getString(web3.db.DBNAME,"THEREAREDATA"))return;
- _stack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_stack"));
- _roundStack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_roundStack"));
- _isAlreadySelected = JSON.parse(web3.db.getString(web3.db.DBNAME,"_isAlreadySelected"));
- _currentState = JSON.parse(web3.db.getString(web3.db.DBNAME,"_currentState"));
- _gameState = JSON.parse(web3.db.getString(web3.db.DBNAME,"_gameState"));
- _stack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_stack"));
- this.proofs = JSON.parse(web3.db.getString(web3.db.DBNAME,"proofs"));
- }
- //////////////////////
- /// GAME HELPERS ////
- web3.Game.calculateMySum =function (){
- };
- web3.Game.calculateMyMoney = function(){
- };
- web3.Game.getMapArray = function(){
- return this._maparray;
- };
- web3.Game.getState = function(){
- return _gameState;
- };
- web3.Game.getStack = function(){
- return _stack;
- };
- web3.Game.getRoundStack = function(){
- return _roundStack;
- };
- web3.Game.haveSelected = function(i){
- i = this.applyRotation(i);
- return _isAlreadySelected[web3.eth.defaultAccount][i] != 0;
- };
- web3.Game.isMyNumber = function(i,j){
- j = this.applyRotation(j);
- return _isAlreadySelected[web3.eth.defaultAccount][j] == _gameState.selected[web3.eth.defaultAccount][i]
- && _isAlreadySelected[web3.eth.defaultAccount][j] != 0;
- };
- web3.Game.findSums = function(){
- var sums = {
- [web3.eth.defaultAccount] : 0,
- [web3.eth.opponentAccount]: 0
- };
- var map = calculateMapArray(this.maphash, this._mapRotation);
- for(var i=0;i<6;i++)
- for (var j = 0; j < 6; j++)
- if(web3.Game.isMyNumber(i,j))
- sums[web3.eth.defaultAccount] += map[i][j];
- else if(web3.Game.isOpponentNumber(i,j))
- sums[web3.eth.opponentAccount] += map[i][j];
- return sums;
- };
- web3.Game.isOpponentNumber = function(i,j){
- j = this.applyRotation(j);
- 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" ;
- };
- web3.Game.reset = function(){
- web3.Game.init();
- }
- web3.Game.setMapRotation = function(r){
- this._mapRotation = r;
- this._maparray = calculateMapArray(this.maphash, this._mapRotation);
- };
- web3.Game.getMapRotation = function(){
- return web3.Game._mapRotation;
- };
- web3.Game.applyRotation = function(d){
- if(this._mapRotation == 1){
- d = 5 - d;
- }
- return d;
- };
- var _applyStateRotation = function(arr){
- var a = [];
- for(var i = 0; i < arr.length; i ++){
- a.push(arr[5-i]);
- }
- return a;
- };
- web3.Game.applyStateRotation = function(s){
- var r = JSON.parse(JSON.stringify(s));
- if(this._mapRotation == 1){
- r.selected[web3.eth.opponentAccount] = _applyStateRotation(s.selected[web3.eth.opponentAccount]);
- }
- return r;
- };
- /// INIT //
- web3.Game.init = function(mapHash){
- this.maphash = mapHash;
- this._maparray = calculateMapArray(this.maphash);
- _stack = [];
- _roundStack = [];
- currentState = {};
- _isAlreadySelected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
- _isAlreadySelected[web3.eth.opponentAccount]= [0,0,0,0,0,0];
-
- _gameState = {
- coins : {
- [web3.eth.defaultAccount] : 99, // TODO CHANGE web3.eth.defaultAccount and opAcc to be settable to object
- [web3.eth.opponentAccount]: 99
- },
- selected :{
- [web3.eth.defaultAccount] : [0,0,0,0,0,0],
- [web3.eth.opponentAccount]: [0,0,0,0,0,0]
- },
- pot : 2,
- round : 1,
- roundstate : 0,
- bets : {
- [web3.eth.defaultAccount] : 0,
- [web3.eth.opponentAccount]: 0
- },
- fold : {
- [web3.eth.defaultAccount] : 0,
- [web3.eth.opponentAccount]: 0
- },
- hidden :{
- [web3.eth.defaultAccount] : {},
- [web3.eth.opponentAccount]: {}
- }
- };
- this.proofs = {};
- };
- // STATE INTERCEPTOR
- web3.Game._stateInterceptor = function(data, original){
- if(data.signature.data.stateConflict){
- if( data.signature.data.myCurrentState ){
- // verify and reset Game
- return false;
- }
- // send My state
- var data = {
- myCurrentState : {
- stack : web3.Game.getStack()
- }
- };
- return false;
- }
- return data;
- };
- function isCorrectSelectIndex(index){
- return SELECTINDEXES[_roundStack.length] == index;
- }
- // PRIVATE HELPERS //
- function _calculateLastStateHash(){
- var hash = web3.sha3(_gameState);
- return hash;
- }
- function _findRandomBigNumber(num, field){
- var randomNumber = Math.floor(10000000000 + Math.random() * 90000000000);
- while(randomNumber % field != num){
- randomNumber++;
- }
- return randomNumber;
- }
- function getOther(acc){
- return acc == web3.eth.defaultAccount ? web3.eth.opponentAccount : web3.eth.defaultAccount;
- }
- /////////////////////
- //// CALCULATIONS ///
- /////////////////////
- function hashToNumbers(hash){
- var nums = [];
- hash = hash.substr(2);
- for(var i=0;i<32;i++){
- var b = hash.substr(2*i, 2*i+2);
- nums.push(web3.toDecimal('0x'+b));
- }
- return nums;
- }
- /////////////////////
- function getNewMapHash(mapHash){
- return web3.sha3(web3.sha3(web3.sha3(mapHash)));
- }
- function calculateMapArray(mapHash, rot){
- console.log("Calculating map array for map hash: " + mapHash);
- var first32Hash = mapHash,
- second32Hash = web3.sha3(first32Hash),
- third32Hash = web3.sha3(second32Hash);
- // Make hash to numbers
- var numbers = hashToNumbers(first32Hash)
- .concat(hashToNumbers(second32Hash))
- .concat(hashToNumbers(third32Hash));
- // init mapArray
- var maparray = [];
- for(var i=0;i<6;i++){
- maparray.push([]);
- for(var j=0;j<6;j++){
- maparray[i][j] = i*6 + j + 1;
- }
- }
- ///
- /// helper local swapPosition
- function swapPositions(a,b){
- a = a % 36
- ai = a % 6;
- aj = parseInt(a / 6);
-
- b = b % 36
- bi = b % 6;
- bj = parseInt(b / 6);
- var temp = maparray[ai][aj];
- maparray[ai][aj] = maparray[bi][bj];
- maparray[bi][bj] = temp;
- }
- ///
- for(var i=0;i<numbers.length;i++){
- swapPositions(i, numbers[i]);
- }
- ////////////////////////////////
- //console.log(maparray);
- ////////////////////////////////
- // Rotate based on rot
- if(rot == 1){
- var f = 3;
- var c = 3;
- var n = 6;
- for(var k = 0;k < 3;k++)
- for( var x = 0; x < f; x++ ){
- for(var y = 0; y <c;y++ ){
- var temp = maparray[x][y];
- maparray[x][y] = maparray[y][n-1-x];
- maparray[y][n-1-x] = maparray[n-1-x][n-1-y];
- maparray[n-1-x][n-1-y] = maparray[n-1-y][x];
- maparray[n-1-y][x] = temp;
- }
- }
- }
- return maparray;
- }
- // Math Helpers
- Math.step = function(x){return x < 0 ? 0 : x;};
- })(web3);
- (function(web3){
- web3.Lib = {};
- var _toRVS = function(data){
- var res = {};
- var signed = data.signature;
- res.r = web3.Utils.toBuffer(signed.slice(0,66));
- res.s = web3.Utils.toBuffer("0x"+signed.slice(66,130));
- res.v = web3.Utils.bufferToInt(web3.Utils.toBuffer("0x"+signed.slice(130,132)));
- res.m = web3.Utils.toBuffer(web3.sha3("\x19Ethereum Signed Message:\n" + data.data.length + data.data));
- return res;
- }
- web3.Lib.signData = function(acc, data){
- var hash = web3.sha3(JSON.stringify(data));
- var signed = web3.eth.sign(acc, web3.toHex(JSON.stringify(data)));
- console.log("Requested sign by account : " + acc);
- return {
- data : JSON.stringify(data),
- dataHash : hash,
- signature: signed
- };
- }
- web3.Lib.verifySignature = function(acc, data){
- var data = _toRVS(data);
- // SimpleStorage.sig_verify(web3.Utils.bufferToHex(this.m), sig).then(function(r){
- // console.log("SmartContract BEST verification : ");
- // console.log(r);
- // });
- var pubKey = web3.Utils.ecrecover(data.m, data.v, data.r, data.s);
- var addrBuf = web3.Utils.pubToAddress(pubKey);
- var addr = web3.Utils.bufferToHex(addrBuf);
- return acc == addr;
- }
- // CHANGE web3.db to localStorage!!!
- web3.db.getString = function(a,k){
- return localStorage[a+k];
- }
- web3.db.putString = function(a,k,v){
- localStorage.setItem(a+k,v);
- }
- ////////////////////////////////
- web3.Lib.DB = {
- _dbname : "defaultDBName",
- setJSON : function(k,d){
- web3.db.putString(this._dbname, k, JSON.stringify(d));
- },
- getSON : function(d){
- return JSON.parse(web3.db.getString(this._dbname,d));
- },
- set : function(k,d){
- web3.db.putString(this._dbname, k, d);
- },
- get : function(d){
- return web3.db.getString(this._dbname,d);
- },
- setDB : function(name){
- this._dbname = name;
- }
- };
- web3.Lib.initWhisper = function(channel, fn) {
- if(typeof channel == undefined)
- channel = web3.sha3("[]Custom Lobby").substr(2);
- function _setFunction(fn){
- EmbarkJS.Messages.listenTo({topic: [channel]}).then(fn);
- };
- function send(msg){
- EmbarkJS.Messages.sendMessage({topic: channel, data: msg});
- };
- console.log("Whisper version : " + web3.version.whisper);
- return new Promise(function(resolve, reject){
- web3.version.getWhisper(function(err, res) {
- if (err) {
- console.log("[!] --> No Whisper - no communication");
- reject(err);
- } else {
- //EmbarkJS.Messages.setProvider('whisper');
- if(fn){
- _setFunction(fn);
- }
- var r = {
- func : fn,
- channel : channel,
- setFunction : _setFunction,
- send : send
- };
- resolve(r);
- }
- });
- });
-
- }
- })(web3);
- (function(){
- var RESENDTIME = 2000;
- function resendOnFail(){
- setTimeout(resendOnFail, RESENDTIME);
- // var length = Object.keys(myClass._ACKs).length;
- // for(var i in myClass._ACKs){
- // myClass.sendPacket(myClass._ACKs[i]);
- // }
- myClass.queue.trySend();
- };
- var randomNumber = parseInt(Math.random() * 100000.0);
- console.log(randomNumber);
- var myClass = {
- queue : {
- _queue: [],
- send : function(data){
- // Create
- console.log("Move added to the queue: " + web3.sha3(data.signature.data));
- this._queue.push(data);
- console.log(this._queue);
- },
- pop : function(data){
- },
- trySend : function(){
- if(!this._queue.length)return;
- var data = this._queue[0];
- myClass.sockets[myClass._channel].send(data);
- },
- _getHash : function(){
- if(!this._queue.length)return undefined;
- var data = this._queue[0];
- var hash = web3.sha3(data.signature.data); // already stringified!
- //console.log(hash);
- return hash;
- },
- recievedACK : function(data){
- if(data.ACK){
- //console.log("Testing recieved ACK : " + data.signature.data.ackSignature);
- if(data.signature.data.ackSignature == this._getHash()){
- //save ACK in stack
- var item = this._queue.shift();
- console.log("recievedACK for : " + data.signature.data.ackSignature);
- console.log(this._queue);
- return item;
- }
- }
- return false;
- }
- },
- sockets : {},
- _channel: "defaultGAMECHANNEL1",
- _fn : function(){},
- _proof : false,
- _address : "",
- _solo : false,
- _ACKs : {},
- _interceptors : [],
- _interceptor : function(data){
- var temp = data;
- for(var i=0; i < myClass._interceptors.length ; i++){
- temp = myClass._interceptors[i].call(myClass, temp, data);
- if(temp === false){
- return false;
- }
- }
- return true;
- },
- __soloInterceptor : function(data){
- if(this._solo && data.who != this._address)return false;
- if(!this.verifyMessage(data)){
- console.log("Verification Failed for:");
- console.log(data);
- return false;
- }
- // parse Data !!!
- data.signature.data = JSON.parse(data.signature.data);
- if(data.ACK){
- this.queue.recievedACK(data);
- }
- return data;
- //
- },
- __proofInterceptor : function(data){
- if(data.signature.data.proof){
- //console.log("Proof.. Sending last packet!");
- this.saveProof(data);
- this.sendLastPacket();
- this.sendACK(data);
- return false;
- }
- else{
- if(this._proof){
- if(this.verifyProof(data, this._proof)){
- //console.log("GOOD PROOF");
- this.sendACK(data);
- this.clearProof();
- return data.signature.data;
- }
- else{
- // BAD PROOF REPORT!!
- //console.log("BAD PROOF");
- return false;
- }
- }
- else{
- return false;
- //console.log("-Discarding");
- // i have no proof...
- // i can either save or discard
- }
- }
- return data;
- },
- __saveDataInterceptor : function(data,original) {
- // save original to a stack!!!;
- return data;
- },
- setSolo : function(add){
- this._address = add;
- this._solo = true;
- },
- setSoloInterceptor : function(){
- this._interceptors.push(this.__soloInterceptor);
- },
- setProofInterceptor : function(){
- this._interceptors.push(this.__proofInterceptor);
- },
- setSaveInterceptor : function(){
- this._interceptors.push(this.__saveDataInterceptor);
- },
- addInterceptor : function(fn){
- this._interceptors.push(fn);
- },
- startListening : function(){
- var self = this;
- // Establish whisper connection //
- return web3.Lib.initWhisper(this._channel)
- .then(function(w){
- w.setFunction(self._interceptor); // w.setFunction ( interceptor of fn that will handle ACKs and will send the next on queue!!)
- self.sockets[self._channel] = w;
- });
- },
- stopListening : function(){
- // todo
- },
- sendPacketWaitForVerification : function(packet){
-
- packet.randomNumber = randomNumber++;
- this._vpacket = packet;
- // console.log("PREPARING : ")
- // console.log(packet);
- this.sendProof(packet);
- if(this._proof)this.sendLastPacket();
- },
- sendLastPacket : function(){
- if(this._vpacket){
- // console.log("SENDING:");
- // console.log(this._vpacket);
- this.sendPacket(this._vpacket);
- delete this._vpacket;
- }
- },
- sendPacket : function(packet){
- var sign = web3.Lib.signData(web3.eth.defaultAccount, packet);
- return this.queue.send({
- who : web3.eth.defaultAccount,
- signature : sign
- });
- },
- sendProof : function(data){
- var hash = web3.sha3(JSON.stringify(data));
- var dataToSign = { datahash : hash, proof : true};
- var sign = web3.Lib.signData(web3.eth.defaultAccount, dataToSign );
- this.queue.send({
- who : web3.eth.defaultAccount,
- signature : sign
- });
- },
- clearProof : function(){
- delete this._proof;
- },
- saveProof : function(p){
- this._proof = p;
- },
- verifyMessage : function(packet){
- return web3.Lib.verifySignature(packet.who, packet.signature);
- },
- verifyProof : function(packet, proof){
- var hash = web3.sha3(JSON.stringify(packet.signature.data));
- if( proof.signature.data.datahash != hash )return false;
- return true;
- },
- sendACK : function(packet){
- // Send Verification For Signed Data
- //var dataToSign = JSON.stringify(packet);//data.signature.dataHash.substr(2);
- var hash = web3.sha3(JSON.stringify(packet.signature.data));
- var dataToSign = {
- ackSignature : hash
- };
- var verificationForSignature = web3.Lib.signData(web3.eth.defaultAccount, dataToSign);
- this.sockets[this._channel].send({
- who : web3.eth.defaultAccount,
- signature : verificationForSignature,
- ACK : true
- });
- },
- setChannel : function(ch){
- this._channel = ch;
- },
- init : function(){
- setTimeout(resendOnFail, RESENDTIME);
- }
- };
- web3.NetLib = myClass;
- })();
|