aliyun-oss-sdk.js 730 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790
  1. // Aliyun OSS SDK for JavaScript v4.11.4
  2. // Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved.
  3. // License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE
  4. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OSS = f()}})(function(){var define,module,exports;return (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){
  5. 'use strict';
  6. var OSS = require('./browser/client');
  7. OSS.Buffer = require('buffer').Buffer;
  8. OSS.co = require('co');
  9. OSS.urllib = require('../shims/xhr');
  10. module.exports = OSS;
  11. },{"../shims/xhr":229,"./browser/client":2,"buffer":31,"co":36}],2:[function(require,module,exports){
  12. (function (process,Buffer){
  13. 'use strict';
  14. var _regenerator = require('babel-runtime/regenerator');
  15. var _regenerator2 = _interopRequireDefault(_regenerator);
  16. var _keys = require('babel-runtime/core-js/object/keys');
  17. var _keys2 = _interopRequireDefault(_keys);
  18. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19. var debug = require('debug')('ali-oss');
  20. var crypto = require('./../../shims/crypto.js');
  21. var path = require('path');
  22. var copy = require('copy-to');
  23. var mime = require('mime');
  24. var xml = require('xml2js');
  25. var ms = require('humanize-ms');
  26. var AgentKeepalive = require('agentkeepalive');
  27. var merge = require('merge-descriptors');
  28. var urlutil = require('url');
  29. var is = require('is-type-of');
  30. var platform = require('platform');
  31. var utility = require('utility');
  32. var urllib = require('urllib');
  33. var pkg = require('./version');
  34. var dateFormat = require('dateformat');
  35. var bowser = require('bowser');
  36. var globalHttpAgent = new AgentKeepalive();
  37. /**
  38. * Expose `Client`
  39. */
  40. module.exports = Client;
  41. function Client(options, ctx) {
  42. if (!(this instanceof Client)) {
  43. return new Client(options, ctx);
  44. }
  45. if (options && options.inited) {
  46. this.options = options;
  47. } else {
  48. this.options = Client.initOptions(options);
  49. }
  50. // support custom agent and urllib client
  51. if (this.options.urllib) {
  52. this.urllib = this.options.urllib;
  53. } else {
  54. this.urllib = urllib;
  55. this.agent = this.options.agent || globalHttpAgent;
  56. }
  57. this.ctx = ctx;
  58. this.userAgent = this._getUserAgent();
  59. // record the time difference between client and server
  60. this.amendTimeSkewed = 0;
  61. }
  62. Client.initOptions = function initOptions(options) {
  63. if (!options || !options.accessKeyId || !options.accessKeySecret) {
  64. throw new Error('require accessKeyId, accessKeySecret');
  65. }
  66. var opts = {
  67. region: 'oss-cn-hangzhou',
  68. internal: false,
  69. secure: false,
  70. bucket: null,
  71. endpoint: null,
  72. cname: false
  73. };
  74. for (var key in options) {
  75. if (options[key] === undefined) continue;
  76. opts[key] = options[key];
  77. }
  78. opts.accessKeyId = opts.accessKeyId.trim();
  79. opts.accessKeySecret = opts.accessKeySecret.trim();
  80. if (opts.timeout) {
  81. opts.timeout = ms(opts.timeout);
  82. }
  83. if (opts.endpoint) {
  84. opts.endpoint = setEndpoint(opts.endpoint);
  85. } else if (opts.region) {
  86. opts.endpoint = setRegion(opts.region, opts.internal, opts.secure);
  87. } else {
  88. throw new Error('require options.endpoint or options.region');
  89. }
  90. opts.inited = true;
  91. return opts;
  92. };
  93. /**
  94. * prototype
  95. */
  96. var proto = Client.prototype;
  97. /**
  98. * Object operations
  99. */
  100. merge(proto, require('./object'));
  101. // /**
  102. // * Bucket operations
  103. // */
  104. // merge(proto, require('./bucket'));
  105. /**
  106. * Multipart operations
  107. */
  108. merge(proto, require('./multipart'));
  109. /**
  110. * ImageClient class
  111. */
  112. // Client.ImageClient = require('./image')(Client);
  113. // /**
  114. // * Cluster Client class
  115. // */
  116. // Client.ClusterClient = require('./cluster')(Client);
  117. /**
  118. * STS Client class
  119. */
  120. // Client.STS = require('./sts');
  121. /**
  122. * Aysnc wrapper
  123. */
  124. Client.Wrapper = require('./wrapper');
  125. /**
  126. * get OSS signature
  127. * @param {String} stringToSign
  128. * @return {String} the signature
  129. */
  130. proto.signature = function signature(stringToSign) {
  131. debug('authorization stringToSign: %s', stringToSign);
  132. var signature = crypto.createHmac('sha1', this.options.accessKeySecret);
  133. signature = signature.update(new Buffer(stringToSign, 'utf8')).digest('base64');
  134. return signature;
  135. };
  136. /**
  137. * get author header
  138. *
  139. * "Authorization: OSS " + Access Key Id + ":" + Signature
  140. *
  141. * Signature = base64(hmac-sha1(Access Key Secret + "\n"
  142. * + VERB + "\n"
  143. * + CONTENT-MD5 + "\n"
  144. * + CONTENT-TYPE + "\n"
  145. * + DATE + "\n"
  146. * + CanonicalizedOSSHeaders
  147. * + CanonicalizedResource))
  148. *
  149. * @param {String} method
  150. * @param {String} resource
  151. * @param {Object} header
  152. * @return {String}
  153. *
  154. * @api private
  155. */
  156. proto.authorization = function authorization(method, resource, subres, headers) {
  157. var params = [method.toUpperCase(), headers['Content-Md5'] || '', getHeader(headers, 'Content-Type'), headers['x-oss-date']];
  158. var ossHeaders = {};
  159. for (var key in headers) {
  160. var lkey = key.toLowerCase().trim();
  161. if (lkey.indexOf('x-oss-') === 0) {
  162. ossHeaders[lkey] = ossHeaders[lkey] || [];
  163. ossHeaders[lkey].push(String(headers[key]).trim());
  164. }
  165. }
  166. var ossHeadersList = [];
  167. (0, _keys2.default)(ossHeaders).sort().forEach(function (key) {
  168. ossHeadersList.push(key + ':' + ossHeaders[key].join(','));
  169. });
  170. params = params.concat(ossHeadersList);
  171. var resourceStr = '';
  172. resourceStr += resource;
  173. var subresList = [];
  174. if (subres) {
  175. if (is.string(subres)) {
  176. subresList.push(subres);
  177. } else if (is.array(subres)) {
  178. subresList = subresList.concat(subres);
  179. } else {
  180. for (var k in subres) {
  181. var item = subres[k] ? k + '=' + subres[k] : k;
  182. subresList.push(item);
  183. }
  184. }
  185. }
  186. if (subresList.length > 0) {
  187. subresList = subresList.sort(function (a, b) {
  188. return a > b;
  189. });
  190. resourceStr += '?' + subresList.join('&');
  191. }
  192. debug('CanonicalizedResource: %s', resourceStr);
  193. params.push(resourceStr);
  194. var stringToSign = params.join('\n');
  195. var auth = 'OSS ' + this.options.accessKeyId + ':';
  196. return auth + this.signature(stringToSign);
  197. };
  198. /**
  199. * create request params
  200. * See `request`
  201. * @api private
  202. */
  203. proto.createRequest = function createRequest(params) {
  204. var headers = {
  205. 'x-oss-date': dateFormat(+new Date() + this.amendTimeSkewed, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
  206. 'x-oss-user-agent': this.userAgent,
  207. 'User-Agent': this.userAgent
  208. };
  209. if (this.options.stsToken) {
  210. headers['x-oss-security-token'] = this.options.stsToken;
  211. }
  212. copy(params.headers).to(headers);
  213. if (!getHeader(headers, 'Content-Type')) {
  214. if (params.mime === mime.default_type) {
  215. params.mime = '';
  216. }
  217. if (params.mime && params.mime.indexOf('/') > 0) {
  218. headers['Content-Type'] = params.mime;
  219. } else {
  220. headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')) || 'application/octet-stream';
  221. }
  222. }
  223. if (params.content) {
  224. headers['Content-Md5'] = crypto.createHash('md5').update(new Buffer(params.content, 'utf8')).digest('base64');
  225. if (!headers['Content-Length']) {
  226. headers['Content-Length'] = params.content.length;
  227. }
  228. }
  229. var authResource = this._getResource(params);
  230. headers.authorization = this.authorization(params.method, authResource, params.subres, headers);
  231. var url = this._getReqUrl(params);
  232. debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream);
  233. var timeout = params.timeout || this.options.timeout;
  234. var reqParams = {
  235. agent: this.agent,
  236. method: params.method,
  237. content: params.content,
  238. stream: params.stream,
  239. headers: headers,
  240. timeout: timeout,
  241. writeStream: params.writeStream,
  242. customResponse: params.customResponse,
  243. ctx: params.ctx || this.ctx
  244. };
  245. return {
  246. url: url,
  247. params: reqParams
  248. };
  249. };
  250. /**
  251. * request oss server
  252. * @param {Object} params
  253. * - {String} object
  254. * - {String} bucket
  255. * - {Object} [headers]
  256. * - {Object} [query]
  257. * - {Buffer} [content]
  258. * - {Stream} [stream]
  259. * - {Stream} [writeStream]
  260. * - {String} [mime]
  261. * - {Boolean} [xmlResponse]
  262. * - {Boolean} [customResponse]
  263. * - {Number} [timeout]
  264. * - {Object} [ctx] request context, default is `this.ctx`
  265. *
  266. * @api private
  267. */
  268. proto.request = /*#__PURE__*/_regenerator2.default.mark(function request(params) {
  269. var reqParams, result, reqErr, err;
  270. return _regenerator2.default.wrap(function request$(_context) {
  271. while (1) {
  272. switch (_context.prev = _context.next) {
  273. case 0:
  274. reqParams = this.createRequest(params);
  275. _context.prev = 1;
  276. _context.next = 4;
  277. return this.urllib.request(reqParams.url, reqParams.params);
  278. case 4:
  279. result = _context.sent;
  280. debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers);
  281. _context.next = 11;
  282. break;
  283. case 8:
  284. _context.prev = 8;
  285. _context.t0 = _context['catch'](1);
  286. reqErr = _context.t0;
  287. case 11:
  288. if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) {
  289. _context.next = 23;
  290. break;
  291. }
  292. _context.next = 14;
  293. return this.requestError(result);
  294. case 14:
  295. err = _context.sent;
  296. if (!(err.code === 'RequestTimeTooSkewed')) {
  297. _context.next = 20;
  298. break;
  299. }
  300. this.amendTimeSkewed = +new Date(err.serverTime) - new Date();
  301. _context.next = 19;
  302. return this.request(params);
  303. case 19:
  304. return _context.abrupt('return', _context.sent);
  305. case 20:
  306. err.params = params;
  307. _context.next = 27;
  308. break;
  309. case 23:
  310. if (!reqErr) {
  311. _context.next = 27;
  312. break;
  313. }
  314. _context.next = 26;
  315. return this.requestError(reqErr);
  316. case 26:
  317. err = _context.sent;
  318. case 27:
  319. if (!err) {
  320. _context.next = 29;
  321. break;
  322. }
  323. throw err;
  324. case 29:
  325. if (!params.xmlResponse) {
  326. _context.next = 33;
  327. break;
  328. }
  329. _context.next = 32;
  330. return this.parseXML(result.data);
  331. case 32:
  332. result.data = _context.sent;
  333. case 33:
  334. return _context.abrupt('return', result);
  335. case 34:
  336. case 'end':
  337. return _context.stop();
  338. }
  339. }
  340. }, request, this, [[1, 8]]);
  341. });
  342. proto._getResource = function _getResource(params) {
  343. var resource = '/';
  344. if (params.bucket) resource += params.bucket + '/';
  345. if (params.object) resource += params.object;
  346. return resource;
  347. };
  348. proto._isIP = function _isIP(host) {
  349. var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
  350. return ipv4Regex.test(host);
  351. };
  352. proto._escape = function _escape(name) {
  353. return utility.encodeURIComponent(name).replace(/%2F/g, '/');
  354. };
  355. proto._getReqUrl = function _getReqUrl(params) {
  356. var ep = {};
  357. copy(this.options.endpoint).to(ep);
  358. var isIP = this._isIP(ep.hostname);
  359. var isCname = this.options.cname;
  360. if (params.bucket && !isCname && !isIP) {
  361. ep.host = params.bucket + '.' + ep.host;
  362. }
  363. var path = '/';
  364. if (params.bucket && isIP) {
  365. path += params.bucket + '/';
  366. }
  367. if (params.object) {
  368. // Preserve '/' in result url
  369. path += this._escape(params.object);
  370. }
  371. ep.pathname = path;
  372. var query = {};
  373. if (params.query) {
  374. merge(query, params.query);
  375. }
  376. if (params.subres) {
  377. var subresAsQuery = {};
  378. if (is.string(params.subres)) {
  379. subresAsQuery[params.subres] = '';
  380. } else if (is.array(params.subres)) {
  381. params.subres.forEach(function (k) {
  382. subresAsQuery[k] = '';
  383. });
  384. } else {
  385. subresAsQuery = params.subres;
  386. }
  387. merge(query, subresAsQuery);
  388. }
  389. ep.query = query;
  390. // As '%20' is not recognized by OSS server, we must convert it to '+'.
  391. return urlutil.format(ep).replace(/%20/g, '+');
  392. };
  393. /*
  394. * Get User-Agent for browser & node.js
  395. * @example
  396. * aliyun-sdk-nodejs/4.1.2 Node.js 5.3.0 on Darwin 64-bit
  397. * aliyun-sdk-js/4.1.2 Safari 9.0 on Apple iPhone(iOS 9.2.1)
  398. * aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit
  399. */
  400. proto._getUserAgent = function _getUserAgent() {
  401. var agent = process && process.browser ? 'js' : 'nodejs';
  402. var sdk = 'aliyun-sdk-' + agent + '/' + pkg.version;
  403. var plat = platform.description;
  404. if (!plat && process) {
  405. plat = 'Node.js ' + process.version.slice(1) + ' on ' + process.platform + ' ' + process.arch;
  406. }
  407. return sdk + ' ' + plat;
  408. };
  409. /*
  410. * Check Browser And Version
  411. * @param {String} [name] browser name: like IE, Chrome, Firefox
  412. * @param {String} [version] browser major version: like 10(IE 10.x), 55(Chrome 55.x), 50(Firefox 50.x)
  413. * @return {Bool} true or false
  414. * @api private
  415. */
  416. proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) {
  417. return bowser.name == name && bowser.version.split('.')[0] == version;
  418. };
  419. /**
  420. * thunkify xml.parseString
  421. * @param {String|Buffer} str
  422. *
  423. * @api private
  424. */
  425. proto.parseXML = function parseXMLThunk(str) {
  426. return function parseXML(done) {
  427. if (Buffer.isBuffer(str)) {
  428. str = str.toString();
  429. }
  430. xml.parseString(str, {
  431. explicitRoot: false,
  432. explicitArray: false
  433. }, done);
  434. };
  435. };
  436. /**
  437. * generater a request error with request response
  438. * @param {Object} result
  439. *
  440. * @api private
  441. */
  442. proto.requestError = /*#__PURE__*/_regenerator2.default.mark(function requestError(result) {
  443. var err, message, info;
  444. return _regenerator2.default.wrap(function requestError$(_context2) {
  445. while (1) {
  446. switch (_context2.prev = _context2.next) {
  447. case 0:
  448. if (!(!result.data || !result.data.length)) {
  449. _context2.next = 4;
  450. break;
  451. }
  452. if (result.status === -1 || result.status === -2) {
  453. //-1 is net error , -2 is timeout
  454. err = new Error(result.message);
  455. err.name = result.name;
  456. err.status = result.status;
  457. err.code = result.name;
  458. } else {
  459. // HEAD not exists resource
  460. if (result.status === 404) {
  461. err = new Error('Object not exists');
  462. err.name = 'NoSuchKeyError';
  463. err.status = 404;
  464. err.code = 'NoSuchKey';
  465. } else if (result.status === 412) {
  466. err = new Error('Pre condition failed');
  467. err.name = 'PreconditionFailedError';
  468. err.status = 412;
  469. err.code = 'PreconditionFailed';
  470. } else {
  471. err = new Error('Unknow error, status: ' + result.status);
  472. err.name = 'UnknowError';
  473. err.status = result.status;
  474. }
  475. err.requestId = result.headers['x-oss-request-id'];
  476. err.host = '';
  477. }
  478. _context2.next = 28;
  479. break;
  480. case 4:
  481. message = String(result.data);
  482. debug('request response error data: %s', message);
  483. _context2.prev = 6;
  484. _context2.next = 9;
  485. return this.parseXML(message) || {};
  486. case 9:
  487. info = _context2.sent;
  488. _context2.next = 19;
  489. break;
  490. case 12:
  491. _context2.prev = 12;
  492. _context2.t0 = _context2['catch'](6);
  493. debug(message);
  494. _context2.t0.message += '\nraw xml: ' + message;
  495. _context2.t0.status = result.status;
  496. _context2.t0.requestId = result.headers['x-oss-request-id'];
  497. return _context2.abrupt('return', _context2.t0);
  498. case 19:
  499. message = info.Message || 'unknow request error, status: ' + result.status;
  500. if (info.Condition) {
  501. message += ' (condition: ' + info.Condition + ')';
  502. }
  503. err = new Error(message);
  504. err.name = info.Code ? info.Code + 'Error' : 'UnknowError';
  505. err.status = result.status;
  506. err.code = info.Code;
  507. err.requestId = info.RequestId;
  508. err.hostId = info.HostId;
  509. err.serverTime = info.ServerTime;
  510. case 28:
  511. debug('generate error %j', err);
  512. return _context2.abrupt('return', err);
  513. case 30:
  514. case 'end':
  515. return _context2.stop();
  516. }
  517. }
  518. }, requestError, this, [[6, 12]]);
  519. });
  520. function getHeader(headers, name) {
  521. return headers[name] || headers[name.toLowerCase()];
  522. }
  523. function setEndpoint(endpoint) {
  524. var url = urlutil.parse(endpoint);
  525. if (!url.protocol) {
  526. url = urlutil.parse('http://' + endpoint);
  527. }
  528. if (url.protocol != 'http:' && url.protocol != 'https:') {
  529. throw new Error('Endpoint protocol must be http or https.');
  530. }
  531. return url;
  532. }
  533. function setRegion(region, internal, secure) {
  534. var protocol = secure ? 'https://' : 'http://';
  535. var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
  536. var prefix = 'vpc100-oss-cn-';
  537. // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
  538. if (region.substr(0, prefix.length) === prefix) {
  539. suffix = '.aliyuncs.com';
  540. }
  541. return urlutil.parse(protocol + region + suffix);
  542. }
  543. }).call(this,require('_process'),require("buffer").Buffer)
  544. },{"./../../shims/crypto.js":226,"./multipart":3,"./object":4,"./version":5,"./wrapper":6,"_process":159,"agentkeepalive":7,"babel-runtime/core-js/object/keys":18,"babel-runtime/regenerator":27,"bowser":29,"buffer":31,"copy-to":38,"dateformat":141,"debug":142,"humanize-ms":147,"is-type-of":152,"merge-descriptors":154,"mime":227,"path":156,"platform":157,"url":191,"urllib":229,"utility":228,"xml2js":202}],3:[function(require,module,exports){
  545. (function (Buffer){
  546. 'use strict';
  547. // var debug = require('debug')('ali-oss:multipart');
  548. // var fs = require('fs');
  549. var _from = require('babel-runtime/core-js/array/from');
  550. var _from2 = _interopRequireDefault(_from);
  551. var _regenerator = require('babel-runtime/regenerator');
  552. var _regenerator2 = _interopRequireDefault(_regenerator);
  553. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  554. var is = require('is-type-of');
  555. // var destroy = require('destroy');
  556. // var eoe = require('end-or-error');
  557. var util = require('util');
  558. var path = require('path');
  559. var mime = require('mime');
  560. var gather = require('co-gather');
  561. var proto = exports;
  562. /**
  563. * Multipart operations
  564. */
  565. /**
  566. * Upload a file to OSS using multipart uploads
  567. * @param {String} name
  568. * @param {String|File} file
  569. * @param {Object} options
  570. */
  571. proto.multipartUpload = /*#__PURE__*/_regenerator2.default.mark(function multipartUpload(name, file, options) {
  572. var minPartSize, filename, fileSize, stream, result, ret, uploadId, partSize, checkpoint;
  573. return _regenerator2.default.wrap(function multipartUpload$(_context) {
  574. while (1) {
  575. switch (_context.prev = _context.next) {
  576. case 0:
  577. options = options || {};
  578. if (!(options.checkpoint && options.checkpoint.uploadId)) {
  579. _context.next = 5;
  580. break;
  581. }
  582. _context.next = 4;
  583. return this._resumeMultipart(options.checkpoint, options);
  584. case 4:
  585. return _context.abrupt('return', _context.sent);
  586. case 5:
  587. minPartSize = 100 * 1024;
  588. filename = is.file(file) ? file.name : file;
  589. options.mime = options.mime || mime.getType(path.extname(filename));
  590. options.headers = options.headers || {};
  591. this._convertMetaToHeaders(options.meta, options.headers);
  592. _context.next = 12;
  593. return this._getFileSize(file);
  594. case 12:
  595. fileSize = _context.sent;
  596. if (!(fileSize < minPartSize)) {
  597. _context.next = 25;
  598. break;
  599. }
  600. stream = this._createStream(file, 0, fileSize);
  601. options.contentLength = fileSize;
  602. _context.next = 18;
  603. return this.putStream(name, stream, options);
  604. case 18:
  605. result = _context.sent;
  606. if (!(options && options.progress)) {
  607. _context.next = 22;
  608. break;
  609. }
  610. _context.next = 22;
  611. return options.progress(1);
  612. case 22:
  613. ret = {
  614. res: result.res,
  615. bucket: this.options.bucket,
  616. name: name,
  617. etag: result.res.headers.etag
  618. };
  619. if (options.headers && options.headers['x-oss-callback']) {
  620. ret.data = JSON.parse(result.data.toString());
  621. }
  622. return _context.abrupt('return', ret);
  623. case 25:
  624. if (!(options.partSize && options.partSize < minPartSize)) {
  625. _context.next = 27;
  626. break;
  627. }
  628. throw new Error('partSize must not be smaller than ' + minPartSize);
  629. case 27:
  630. _context.next = 29;
  631. return this._initMultipartUpload(name, options);
  632. case 29:
  633. result = _context.sent;
  634. uploadId = result.uploadId;
  635. partSize = this._getPartSize(fileSize, options.partSize);
  636. checkpoint = {
  637. file: file,
  638. name: name,
  639. fileSize: fileSize,
  640. partSize: partSize,
  641. uploadId: uploadId,
  642. doneParts: []
  643. };
  644. if (!(options && options.progress)) {
  645. _context.next = 36;
  646. break;
  647. }
  648. _context.next = 36;
  649. return options.progress(0, checkpoint, result.res);
  650. case 36:
  651. _context.next = 38;
  652. return this._resumeMultipart(checkpoint, options);
  653. case 38:
  654. return _context.abrupt('return', _context.sent);
  655. case 39:
  656. case 'end':
  657. return _context.stop();
  658. }
  659. }
  660. }, multipartUpload, this);
  661. });
  662. /*
  663. * Resume multipart upload from checkpoint. The checkpoint will be
  664. * updated after each successful part upload.
  665. * @param {Object} checkpoint the checkpoint
  666. * @param {Object} options
  667. */
  668. proto._resumeMultipart = /*#__PURE__*/_regenerator2.default.mark(function _resumeMultipart(checkpoint, options) {
  669. var file, fileSize, partSize, uploadId, doneParts, name, partOffs, numParts, uploadPartJob, all, done, todo, i, jobs, defaultParallel, parallel, results, error;
  670. return _regenerator2.default.wrap(function _resumeMultipart$(_context3) {
  671. while (1) {
  672. switch (_context3.prev = _context3.next) {
  673. case 0:
  674. file = checkpoint.file;
  675. fileSize = checkpoint.fileSize;
  676. partSize = checkpoint.partSize;
  677. uploadId = checkpoint.uploadId;
  678. doneParts = checkpoint.doneParts;
  679. name = checkpoint.name;
  680. partOffs = this._divideParts(fileSize, partSize);
  681. numParts = partOffs.length;
  682. uploadPartJob = /*#__PURE__*/_regenerator2.default.mark(function uploadPartJob(self, partNo) {
  683. var pi, data, result;
  684. return _regenerator2.default.wrap(function uploadPartJob$(_context2) {
  685. while (1) {
  686. switch (_context2.prev = _context2.next) {
  687. case 0:
  688. pi = partOffs[partNo - 1];
  689. data = {
  690. stream: self._createStream(file, pi.start, pi.end),
  691. size: pi.end - pi.start
  692. };
  693. _context2.next = 4;
  694. return self._uploadPart(name, uploadId, partNo, data);
  695. case 4:
  696. result = _context2.sent;
  697. doneParts.push({
  698. number: partNo,
  699. etag: result.res.headers.etag
  700. });
  701. checkpoint.doneParts = doneParts;
  702. if (!(options && options.progress)) {
  703. _context2.next = 10;
  704. break;
  705. }
  706. _context2.next = 10;
  707. return options.progress(doneParts.length / numParts, checkpoint, result.res);
  708. case 10:
  709. case 'end':
  710. return _context2.stop();
  711. }
  712. }
  713. }, uploadPartJob, this);
  714. });
  715. all = (0, _from2.default)(new Array(numParts), function (x, i) {
  716. return i + 1;
  717. });
  718. done = doneParts.map(function (p) {
  719. return p.number;
  720. });
  721. todo = all.filter(function (p) {
  722. return done.indexOf(p) < 0;
  723. });
  724. if (!this.checkBrowserAndVersion('Internet Explorer', '10')) {
  725. _context3.next = 22;
  726. break;
  727. }
  728. i = 0;
  729. case 14:
  730. if (!(i < todo.length)) {
  731. _context3.next = 20;
  732. break;
  733. }
  734. _context3.next = 17;
  735. return uploadPartJob(this, todo[i]);
  736. case 17:
  737. i++;
  738. _context3.next = 14;
  739. break;
  740. case 20:
  741. _context3.next = 39;
  742. break;
  743. case 22:
  744. // upload in parallel
  745. jobs = [];
  746. for (i = 0; i < todo.length; i++) {
  747. jobs.push(uploadPartJob(this, todo[i]));
  748. }
  749. defaultParallel = 5;
  750. parallel = options.parallel || defaultParallel;
  751. _context3.next = 28;
  752. return gather(jobs, parallel);
  753. case 28:
  754. results = _context3.sent;
  755. i = 0;
  756. case 30:
  757. if (!(i < results.length)) {
  758. _context3.next = 39;
  759. break;
  760. }
  761. if (!results[i].isError) {
  762. _context3.next = 36;
  763. break;
  764. }
  765. error = results[i].error;
  766. error.partNum = i;
  767. error.message = 'Failed to upload some parts with error: ' + results[i].error.toString() + " part_num: " + i;
  768. throw error;
  769. case 36:
  770. i++;
  771. _context3.next = 30;
  772. break;
  773. case 39:
  774. _context3.next = 41;
  775. return this._completeMultipartUpload(name, uploadId, doneParts, options);
  776. case 41:
  777. return _context3.abrupt('return', _context3.sent);
  778. case 42:
  779. case 'end':
  780. return _context3.stop();
  781. }
  782. }
  783. }, _resumeMultipart, this);
  784. });
  785. /**
  786. * List the on-going multipart uploads
  787. * https://help.aliyun.com/document_detail/31997.html
  788. * @param {Object} options
  789. * @return {Array} the multipart uploads
  790. */
  791. proto.listUploads = /*#__PURE__*/_regenerator2.default.mark(function listUploads(query, options) {
  792. var params, result, uploads;
  793. return _regenerator2.default.wrap(function listUploads$(_context4) {
  794. while (1) {
  795. switch (_context4.prev = _context4.next) {
  796. case 0:
  797. options = options || {};
  798. options.subres = 'uploads';
  799. params = this._objectRequestParams('GET', '', options);
  800. params.query = query;
  801. params.xmlResponse = true;
  802. params.successStatuses = [200];
  803. _context4.next = 8;
  804. return this.request(params);
  805. case 8:
  806. result = _context4.sent;
  807. uploads = result.data.Upload || [];
  808. if (!Array.isArray(uploads)) {
  809. uploads = [uploads];
  810. }
  811. uploads = uploads.map(function (up) {
  812. return {
  813. name: up.Key,
  814. uploadId: up.UploadId,
  815. initiated: up.Initiated
  816. };
  817. });
  818. return _context4.abrupt('return', {
  819. res: result.res,
  820. uploads: uploads,
  821. bucket: result.data.Bucket,
  822. nextKeyMarker: result.data.NextKeyMarker,
  823. nextUploadIdMarker: result.data.NextUploadIdMarker,
  824. isTruncated: result.data.IsTruncated === 'true'
  825. });
  826. case 13:
  827. case 'end':
  828. return _context4.stop();
  829. }
  830. }
  831. }, listUploads, this);
  832. });
  833. /**
  834. * Abort a multipart upload transaction
  835. * @param {String} name the object name
  836. * @param {String} uploadId the upload id
  837. * @param {Object} options
  838. */
  839. proto.abortMultipartUpload = /*#__PURE__*/_regenerator2.default.mark(function abortMultipartUpload(name, uploadId, options) {
  840. var params, result;
  841. return _regenerator2.default.wrap(function abortMultipartUpload$(_context5) {
  842. while (1) {
  843. switch (_context5.prev = _context5.next) {
  844. case 0:
  845. options = options || {};
  846. options.subres = { uploadId: uploadId };
  847. params = this._objectRequestParams('DELETE', name, options);
  848. params.successStatuses = [204];
  849. _context5.next = 6;
  850. return this.request(params);
  851. case 6:
  852. result = _context5.sent;
  853. return _context5.abrupt('return', {
  854. res: result.res
  855. });
  856. case 8:
  857. case 'end':
  858. return _context5.stop();
  859. }
  860. }
  861. }, abortMultipartUpload, this);
  862. });
  863. /**
  864. * Initiate a multipart upload transaction
  865. * @param {String} name the object name
  866. * @param {Object} options
  867. * @return {String} upload id
  868. */
  869. proto._initMultipartUpload = /*#__PURE__*/_regenerator2.default.mark(function _initMultipartUpload(name, options) {
  870. var params, result;
  871. return _regenerator2.default.wrap(function _initMultipartUpload$(_context6) {
  872. while (1) {
  873. switch (_context6.prev = _context6.next) {
  874. case 0:
  875. options = options || {};
  876. options.headers = options.headers || {};
  877. this._convertMetaToHeaders(options.meta, options.headers);
  878. options.subres = 'uploads';
  879. params = this._objectRequestParams('POST', name, options);
  880. params.mime = options.mime;
  881. params.xmlResponse = true;
  882. params.successStatuses = [200];
  883. _context6.next = 10;
  884. return this.request(params);
  885. case 10:
  886. result = _context6.sent;
  887. return _context6.abrupt('return', {
  888. res: result.res,
  889. bucket: result.data.Bucket,
  890. name: result.data.Key,
  891. uploadId: result.data.UploadId
  892. });
  893. case 12:
  894. case 'end':
  895. return _context6.stop();
  896. }
  897. }
  898. }, _initMultipartUpload, this);
  899. });
  900. /**
  901. * Upload a part in a multipart upload transaction
  902. * @param {String} name the object name
  903. * @param {String} uploadId the upload id
  904. * @param {Integer} partNo the part number
  905. * @param {Object} data the body data
  906. * @param {Object} options
  907. */
  908. proto._uploadPart = /*#__PURE__*/_regenerator2.default.mark(function _uploadPart(name, uploadId, partNo, data, options) {
  909. var params, result;
  910. return _regenerator2.default.wrap(function _uploadPart$(_context7) {
  911. while (1) {
  912. switch (_context7.prev = _context7.next) {
  913. case 0:
  914. options = options || {};
  915. options.headers = {
  916. 'Content-Length': data.size
  917. };
  918. options.subres = {
  919. partNumber: partNo,
  920. uploadId: uploadId
  921. };
  922. params = this._objectRequestParams('PUT', name, options);
  923. params.mime = options.mime;
  924. params.stream = data.stream;
  925. params.successStatuses = [200];
  926. _context7.next = 9;
  927. return this.request(params);
  928. case 9:
  929. result = _context7.sent;
  930. data.stream = null;
  931. params.stream = null;
  932. return _context7.abrupt('return', {
  933. name: name,
  934. etag: result.res.headers.etag,
  935. res: result.res
  936. });
  937. case 13:
  938. case 'end':
  939. return _context7.stop();
  940. }
  941. }
  942. }, _uploadPart, this);
  943. });
  944. /**
  945. * Complete a multipart upload transaction
  946. * @param {String} name the object name
  947. * @param {String} uploadId the upload id
  948. * @param {Array} parts the uploaded parts
  949. * @param {Object} options
  950. */
  951. proto._completeMultipartUpload = /*#__PURE__*/_regenerator2.default.mark(function _completeMultipartUpload(name, uploadId, parts, options) {
  952. var xml, i, p, params, result, ret;
  953. return _regenerator2.default.wrap(function _completeMultipartUpload$(_context8) {
  954. while (1) {
  955. switch (_context8.prev = _context8.next) {
  956. case 0:
  957. parts.sort(function (a, b) {
  958. return a.number - b.number;
  959. });
  960. xml = '<?xml version="1.0" encoding="UTF-8"?>\n<CompleteMultipartUpload>\n';
  961. for (i = 0; i < parts.length; i++) {
  962. p = parts[i];
  963. xml += '<Part>\n';
  964. xml += '<PartNumber>' + p.number + '</PartNumber>\n';
  965. xml += '<ETag>' + p.etag + '</ETag>\n';
  966. xml += '</Part>\n';
  967. }
  968. xml += '</CompleteMultipartUpload>';
  969. options = options || {};
  970. options.subres = { uploadId: uploadId };
  971. params = this._objectRequestParams('POST', name, options);
  972. params.mime = 'xml';
  973. params.content = xml;
  974. if (!(options.headers && options.headers['x-oss-callback'])) {
  975. params.xmlResponse = true;
  976. }
  977. params.successStatuses = [200];
  978. _context8.next = 13;
  979. return this.request(params);
  980. case 13:
  981. result = _context8.sent;
  982. ret = {
  983. res: result.res,
  984. bucket: params.bucket,
  985. name: name,
  986. etag: result.res.headers['etag']
  987. };
  988. if (options.headers && options.headers['x-oss-callback']) {
  989. ret.data = JSON.parse(result.data.toString());
  990. }
  991. return _context8.abrupt('return', ret);
  992. case 17:
  993. case 'end':
  994. return _context8.stop();
  995. }
  996. }
  997. }, _completeMultipartUpload, this);
  998. });
  999. is.file = function (file) {
  1000. return typeof File !== 'undefined' && file instanceof File;
  1001. };
  1002. /**
  1003. * Get file size
  1004. */
  1005. proto._getFileSize = /*#__PURE__*/_regenerator2.default.mark(function _getFileSize(file) {
  1006. var stat;
  1007. return _regenerator2.default.wrap(function _getFileSize$(_context9) {
  1008. while (1) {
  1009. switch (_context9.prev = _context9.next) {
  1010. case 0:
  1011. if (!is.buffer(file)) {
  1012. _context9.next = 4;
  1013. break;
  1014. }
  1015. return _context9.abrupt('return', file.length);
  1016. case 4:
  1017. if (!is.file(file)) {
  1018. _context9.next = 6;
  1019. break;
  1020. }
  1021. return _context9.abrupt('return', file.size);
  1022. case 6:
  1023. if (!is.string(file)) {
  1024. _context9.next = 11;
  1025. break;
  1026. }
  1027. _context9.next = 9;
  1028. return this._statFile(file);
  1029. case 9:
  1030. stat = _context9.sent;
  1031. return _context9.abrupt('return', stat.size);
  1032. case 11:
  1033. throw new Error('_getFileSize requires Buffer/File/String.');
  1034. case 12:
  1035. case 'end':
  1036. return _context9.stop();
  1037. }
  1038. }
  1039. }, _getFileSize, this);
  1040. });
  1041. /*
  1042. * Readable stream for Web File
  1043. */
  1044. var Readable = require('stream').Readable;
  1045. function WebFileReadStream(file, options) {
  1046. if (!(this instanceof WebFileReadStream)) {
  1047. return new WebFileReadStream(file, options);
  1048. }
  1049. Readable.call(this, options);
  1050. this.file = file;
  1051. this.reader = new FileReader();
  1052. this.start = 0;
  1053. this.finish = false;
  1054. this.fileBuffer;
  1055. }
  1056. util.inherits(WebFileReadStream, Readable);
  1057. WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
  1058. if (this.fileBuffer) {
  1059. var pushRet = true;
  1060. while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
  1061. var start = this.start;
  1062. var end = start + size;
  1063. end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
  1064. this.start = end;
  1065. pushRet = this.push(this.fileBuffer.slice(start, end));
  1066. }
  1067. }
  1068. };
  1069. WebFileReadStream.prototype._read = function _read(size) {
  1070. if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || 0 == this.start && !this.file) {
  1071. if (!this.finish) {
  1072. this.fileBuffer = null;
  1073. this.finish = true;
  1074. }
  1075. this.push(null);
  1076. return;
  1077. }
  1078. var defaultReadSize = 16 * 1024;
  1079. size = size ? size : defaultReadSize;
  1080. var that = this;
  1081. this.reader.onload = function (e) {
  1082. that.fileBuffer = new Buffer(new Uint8Array(e.target.result));
  1083. that.file = null;
  1084. that.readFileAndPush(size);
  1085. };
  1086. if (0 == this.start) {
  1087. this.reader.readAsArrayBuffer(this.file);
  1088. } else {
  1089. this.readFileAndPush(size);
  1090. }
  1091. };
  1092. proto._createStream = function _createStream(file, start, end) {
  1093. if (is.file(file)) {
  1094. return new WebFileReadStream(file.slice(start, end));
  1095. }
  1096. // else if (is.string(file)) {
  1097. // return fs.createReadStream(file, {
  1098. // start: start,
  1099. // end: end - 1
  1100. // });
  1101. // }
  1102. else {
  1103. throw new Error('_createStream requires File/String.');
  1104. }
  1105. };
  1106. proto._getPartSize = function _getPartSize(fileSize, partSize) {
  1107. var maxNumParts = 10 * 1000;
  1108. var defaultPartSize = 1 * 1024 * 1024;
  1109. if (!partSize) {
  1110. return defaultPartSize;
  1111. }
  1112. return Math.max(Math.ceil(fileSize / maxNumParts), partSize);
  1113. };
  1114. proto._divideParts = function _divideParts(fileSize, partSize) {
  1115. var numParts = Math.ceil(fileSize / partSize);
  1116. var partOffs = [];
  1117. for (var i = 0; i < numParts; i++) {
  1118. var start = partSize * i;
  1119. var end = Math.min(start + partSize, fileSize);
  1120. partOffs.push({
  1121. start: start,
  1122. end: end
  1123. });
  1124. }
  1125. return partOffs;
  1126. };
  1127. }).call(this,require("buffer").Buffer)
  1128. },{"babel-runtime/core-js/array/from":11,"babel-runtime/regenerator":27,"buffer":31,"co-gather":34,"is-type-of":152,"mime":227,"path":156,"stream":183,"util":196}],4:[function(require,module,exports){
  1129. 'use strict';
  1130. var _regenerator = require('babel-runtime/regenerator');
  1131. var _regenerator2 = _interopRequireDefault(_regenerator);
  1132. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1133. var debug = require('debug')('ali-oss:object');
  1134. var utility = require('utility');
  1135. // var crypto = require('crypto');
  1136. var fs = require('fs');
  1137. var is = require('is-type-of');
  1138. // var eoe = require('end-or-error');
  1139. var urlutil = require('url');
  1140. var copy = require('copy-to');
  1141. var path = require('path');
  1142. var mime = require('mime');
  1143. // var assert = require('assert');
  1144. var proto = exports;
  1145. /**
  1146. * Object operations
  1147. */
  1148. /**
  1149. * append an object from String(file path)/Buffer/ReadableStream
  1150. * @param {String} name the object key
  1151. * @param {Mixed} file String(file path)/Buffer/ReadableStream
  1152. * @param {Object} options
  1153. * @return {Object}
  1154. */
  1155. proto.append = /*#__PURE__*/_regenerator2.default.mark(function _callee(name, file, options) {
  1156. var result;
  1157. return _regenerator2.default.wrap(function _callee$(_context) {
  1158. while (1) {
  1159. switch (_context.prev = _context.next) {
  1160. case 0:
  1161. options = options || {};
  1162. if (options.position === undefined) options.position = '0';
  1163. options.subres = {
  1164. append: '',
  1165. position: options.position
  1166. };
  1167. options.method = 'POST';
  1168. _context.next = 6;
  1169. return this.put(name, file, options);
  1170. case 6:
  1171. result = _context.sent;
  1172. result.nextAppendPosition = result.res.headers['x-oss-next-append-position'];
  1173. return _context.abrupt('return', result);
  1174. case 9:
  1175. case 'end':
  1176. return _context.stop();
  1177. }
  1178. }
  1179. }, _callee, this);
  1180. });
  1181. /**
  1182. * put an object from String(file path)/Buffer/ReadableStream
  1183. * @param {String} name the object key
  1184. * @param {Mixed} file String(file path)/Buffer/ReadableStream
  1185. * @param {Object} options
  1186. * @return {Object}
  1187. */
  1188. proto.put = /*#__PURE__*/_regenerator2.default.mark(function put(name, file, options) {
  1189. var content, stream, method, params, result, ret;
  1190. return _regenerator2.default.wrap(function put$(_context2) {
  1191. while (1) {
  1192. switch (_context2.prev = _context2.next) {
  1193. case 0:
  1194. options = options || {};
  1195. if (!is.buffer(file)) {
  1196. _context2.next = 5;
  1197. break;
  1198. }
  1199. content = file;
  1200. _context2.next = 23;
  1201. break;
  1202. case 5:
  1203. if (!is.string(file)) {
  1204. _context2.next = 16;
  1205. break;
  1206. }
  1207. options.mime = options.mime || mime.getType(path.extname(file));
  1208. stream = fs.createReadStream(file);
  1209. _context2.next = 10;
  1210. return this._getFileSize(file);
  1211. case 10:
  1212. options.contentLength = _context2.sent;
  1213. _context2.next = 13;
  1214. return this.putStream(name, stream, options);
  1215. case 13:
  1216. return _context2.abrupt('return', _context2.sent);
  1217. case 16:
  1218. if (!is.readableStream(file)) {
  1219. _context2.next = 22;
  1220. break;
  1221. }
  1222. _context2.next = 19;
  1223. return this.putStream(name, file, options);
  1224. case 19:
  1225. return _context2.abrupt('return', _context2.sent);
  1226. case 22:
  1227. throw new TypeError('Must provide String/Buffer/ReadableStream for put.');
  1228. case 23:
  1229. options.headers = options.headers || {};
  1230. this._convertMetaToHeaders(options.meta, options.headers);
  1231. method = options.method || 'PUT';
  1232. params = this._objectRequestParams(method, name, options);
  1233. params.mime = options.mime;
  1234. params.content = content;
  1235. params.successStatuses = [200];
  1236. _context2.next = 32;
  1237. return this.request(params);
  1238. case 32:
  1239. result = _context2.sent;
  1240. ret = {
  1241. name: name,
  1242. url: this._objectUrl(name),
  1243. res: result.res
  1244. };
  1245. if (options.headers && options.headers['x-oss-callback']) {
  1246. ret.data = JSON.parse(result.data.toString());
  1247. }
  1248. return _context2.abrupt('return', ret);
  1249. case 36:
  1250. case 'end':
  1251. return _context2.stop();
  1252. }
  1253. }
  1254. }, put, this);
  1255. });
  1256. /**
  1257. * put an object from ReadableStream. If `options.contentLength` is
  1258. * not provided, chunked encoding is used.
  1259. * @param {String} name the object key
  1260. * @param {Readable} stream the ReadableStream
  1261. * @param {Object} options
  1262. * @return {Object}
  1263. */
  1264. proto.putStream = /*#__PURE__*/_regenerator2.default.mark(function putStream(name, stream, options) {
  1265. var method, params, result, ret;
  1266. return _regenerator2.default.wrap(function putStream$(_context3) {
  1267. while (1) {
  1268. switch (_context3.prev = _context3.next) {
  1269. case 0:
  1270. options = options || {};
  1271. options.headers = options.headers || {};
  1272. if (options.contentLength) {
  1273. options.headers['Content-Length'] = options.contentLength;
  1274. } else {
  1275. options.headers['Transfer-Encoding'] = 'chunked';
  1276. }
  1277. this._convertMetaToHeaders(options.meta, options.headers);
  1278. method = options.method || 'PUT';
  1279. params = this._objectRequestParams(method, name, options);
  1280. params.mime = options.mime;
  1281. params.stream = stream;
  1282. params.successStatuses = [200];
  1283. _context3.next = 11;
  1284. return this.request(params);
  1285. case 11:
  1286. result = _context3.sent;
  1287. ret = {
  1288. name: name,
  1289. url: this._objectUrl(name),
  1290. res: result.res
  1291. };
  1292. if (options.headers && options.headers['x-oss-callback']) {
  1293. ret.data = JSON.parse(result.data.toString());
  1294. }
  1295. return _context3.abrupt('return', ret);
  1296. case 15:
  1297. case 'end':
  1298. return _context3.stop();
  1299. }
  1300. }
  1301. }, putStream, this);
  1302. });
  1303. proto.head = /*#__PURE__*/_regenerator2.default.mark(function head(name, options) {
  1304. var params, result, data, k;
  1305. return _regenerator2.default.wrap(function head$(_context4) {
  1306. while (1) {
  1307. switch (_context4.prev = _context4.next) {
  1308. case 0:
  1309. params = this._objectRequestParams('HEAD', name, options);
  1310. params.successStatuses = [200, 304];
  1311. _context4.next = 4;
  1312. return this.request(params);
  1313. case 4:
  1314. result = _context4.sent;
  1315. data = {
  1316. meta: null,
  1317. res: result.res,
  1318. status: result.status
  1319. };
  1320. if (result.status === 200) {
  1321. for (k in result.headers) {
  1322. if (k.indexOf('x-oss-meta-') === 0) {
  1323. if (!data.meta) {
  1324. data.meta = {};
  1325. }
  1326. data.meta[k.substring(11)] = result.headers[k];
  1327. }
  1328. }
  1329. }
  1330. return _context4.abrupt('return', data);
  1331. case 8:
  1332. case 'end':
  1333. return _context4.stop();
  1334. }
  1335. }
  1336. }, head, this);
  1337. });
  1338. proto.get = /*#__PURE__*/_regenerator2.default.mark(function get(name, file, options) {
  1339. var writeStream, needDestroy, result, params;
  1340. return _regenerator2.default.wrap(function get$(_context5) {
  1341. while (1) {
  1342. switch (_context5.prev = _context5.next) {
  1343. case 0:
  1344. writeStream = null;
  1345. needDestroy = false;
  1346. if (is.writableStream(file)) {
  1347. writeStream = file;
  1348. } else if (is.string(file)) {
  1349. writeStream = fs.createWriteStream(file);
  1350. needDestroy = true;
  1351. } else {
  1352. // get(name, options)
  1353. options = file;
  1354. }
  1355. options = options || {};
  1356. if (options.process) {
  1357. options.subres = options.subres || {};
  1358. options.subres['x-oss-process'] = options.process;
  1359. }
  1360. _context5.prev = 5;
  1361. params = this._objectRequestParams('GET', name, options);
  1362. params.writeStream = writeStream;
  1363. params.successStatuses = [200, 206, 304];
  1364. _context5.next = 11;
  1365. return this.request(params);
  1366. case 11:
  1367. result = _context5.sent;
  1368. if (needDestroy) {
  1369. writeStream.destroy();
  1370. }
  1371. _context5.next = 23;
  1372. break;
  1373. case 15:
  1374. _context5.prev = 15;
  1375. _context5.t0 = _context5['catch'](5);
  1376. if (!needDestroy) {
  1377. _context5.next = 22;
  1378. break;
  1379. }
  1380. writeStream.destroy();
  1381. // should delete the exists file before throw error
  1382. debug('get error: %s, delete the exists file %s', _context5.t0, file);
  1383. _context5.next = 22;
  1384. return this._deleteFileSafe(file);
  1385. case 22:
  1386. throw _context5.t0;
  1387. case 23:
  1388. return _context5.abrupt('return', {
  1389. res: result.res,
  1390. content: result.data
  1391. });
  1392. case 24:
  1393. case 'end':
  1394. return _context5.stop();
  1395. }
  1396. }
  1397. }, get, this, [[5, 15]]);
  1398. });
  1399. proto.getStream = /*#__PURE__*/_regenerator2.default.mark(function getStream(name, options) {
  1400. var params, result;
  1401. return _regenerator2.default.wrap(function getStream$(_context6) {
  1402. while (1) {
  1403. switch (_context6.prev = _context6.next) {
  1404. case 0:
  1405. options = options || {};
  1406. params = this._objectRequestParams('GET', name, options);
  1407. params.customResponse = true;
  1408. params.successStatuses = [200, 206, 304];
  1409. _context6.next = 6;
  1410. return this.request(params);
  1411. case 6:
  1412. result = _context6.sent;
  1413. return _context6.abrupt('return', {
  1414. stream: result.res,
  1415. res: {
  1416. status: result.status,
  1417. headers: result.headers
  1418. }
  1419. });
  1420. case 8:
  1421. case 'end':
  1422. return _context6.stop();
  1423. }
  1424. }
  1425. }, getStream, this);
  1426. });
  1427. proto.delete = /*#__PURE__*/_regenerator2.default.mark(function _delete(name, options) {
  1428. var params, result;
  1429. return _regenerator2.default.wrap(function _delete$(_context7) {
  1430. while (1) {
  1431. switch (_context7.prev = _context7.next) {
  1432. case 0:
  1433. params = this._objectRequestParams('DELETE', name, options);
  1434. params.successStatuses = [204];
  1435. _context7.next = 4;
  1436. return this.request(params);
  1437. case 4:
  1438. result = _context7.sent;
  1439. return _context7.abrupt('return', {
  1440. res: result.res
  1441. });
  1442. case 6:
  1443. case 'end':
  1444. return _context7.stop();
  1445. }
  1446. }
  1447. }, _delete, this);
  1448. });
  1449. proto.deleteMulti = /*#__PURE__*/_regenerator2.default.mark(function deleteMulti(names, options) {
  1450. var xml, i, params, result, r, deleted;
  1451. return _regenerator2.default.wrap(function deleteMulti$(_context8) {
  1452. while (1) {
  1453. switch (_context8.prev = _context8.next) {
  1454. case 0:
  1455. options = options || {};
  1456. xml = '<?xml version="1.0" encoding="UTF-8"?>\n<Delete>\n';
  1457. if (options.quiet) {
  1458. xml += ' <Quiet>true</Quiet>\n';
  1459. } else {
  1460. xml += ' <Quiet>false</Quiet>\n';
  1461. }
  1462. for (i = 0; i < names.length; i++) {
  1463. xml += ' <Object><Key>' + utility.escape(this._objectName(names[i])) + '</Key></Object>\n';
  1464. }
  1465. xml += '</Delete>';
  1466. debug('delete multi objects: %s', xml);
  1467. options.subres = 'delete';
  1468. params = this._objectRequestParams('POST', '', options);
  1469. params.mime = 'xml';
  1470. params.content = xml;
  1471. params.xmlResponse = true;
  1472. params.successStatuses = [200];
  1473. _context8.next = 14;
  1474. return this.request(params);
  1475. case 14:
  1476. result = _context8.sent;
  1477. r = result.data;
  1478. deleted = r && r.Deleted || null;
  1479. if (deleted) {
  1480. if (!Array.isArray(deleted)) {
  1481. deleted = [deleted];
  1482. }
  1483. deleted = deleted.map(function (item) {
  1484. return item.Key;
  1485. });
  1486. }
  1487. return _context8.abrupt('return', {
  1488. res: result.res,
  1489. deleted: deleted
  1490. });
  1491. case 19:
  1492. case 'end':
  1493. return _context8.stop();
  1494. }
  1495. }
  1496. }, deleteMulti, this);
  1497. });
  1498. proto.copy = /*#__PURE__*/_regenerator2.default.mark(function copy(name, sourceName, options) {
  1499. var k, params, result, data;
  1500. return _regenerator2.default.wrap(function copy$(_context9) {
  1501. while (1) {
  1502. switch (_context9.prev = _context9.next) {
  1503. case 0:
  1504. options = options || {};
  1505. options.headers = options.headers || {};
  1506. for (k in options.headers) {
  1507. options.headers['x-oss-copy-source-' + k.toLowerCase()] = options.headers[k];
  1508. }
  1509. if (options.meta) {
  1510. options.headers['x-oss-metadata-directive'] = 'REPLACE';
  1511. }
  1512. this._convertMetaToHeaders(options.meta, options.headers);
  1513. if (sourceName[0] !== '/') {
  1514. // no specify bucket name
  1515. sourceName = '/' + this.options.bucket + '/' + encodeURIComponent(sourceName);
  1516. } else {
  1517. sourceName = '/' + encodeURIComponent(sourceName.slice(1));
  1518. }
  1519. options.headers['x-oss-copy-source'] = sourceName;
  1520. params = this._objectRequestParams('PUT', name, options);
  1521. params.xmlResponse = true;
  1522. params.successStatuses = [200, 304];
  1523. _context9.next = 12;
  1524. return this.request(params);
  1525. case 12:
  1526. result = _context9.sent;
  1527. data = result.data;
  1528. if (data) {
  1529. data = {
  1530. etag: data.ETag,
  1531. lastModified: data.LastModified
  1532. };
  1533. }
  1534. return _context9.abrupt('return', {
  1535. data: data,
  1536. res: result.res
  1537. });
  1538. case 16:
  1539. case 'end':
  1540. return _context9.stop();
  1541. }
  1542. }
  1543. }, copy, this);
  1544. });
  1545. proto.putMeta = /*#__PURE__*/_regenerator2.default.mark(function putMeta(name, meta, options) {
  1546. return _regenerator2.default.wrap(function putMeta$(_context10) {
  1547. while (1) {
  1548. switch (_context10.prev = _context10.next) {
  1549. case 0:
  1550. _context10.next = 2;
  1551. return this.copy(name, name, {
  1552. meta: meta || {},
  1553. timeout: options && options.timeout,
  1554. ctx: options && options.ctx
  1555. });
  1556. case 2:
  1557. return _context10.abrupt('return', _context10.sent);
  1558. case 3:
  1559. case 'end':
  1560. return _context10.stop();
  1561. }
  1562. }
  1563. }, putMeta, this);
  1564. });
  1565. proto.list = /*#__PURE__*/_regenerator2.default.mark(function list(query, options) {
  1566. var params, result, objects, that, prefixes;
  1567. return _regenerator2.default.wrap(function list$(_context11) {
  1568. while (1) {
  1569. switch (_context11.prev = _context11.next) {
  1570. case 0:
  1571. // prefix, marker, max-keys, delimiter
  1572. params = this._objectRequestParams('GET', '', options);
  1573. params.query = query;
  1574. params.xmlResponse = true;
  1575. params.successStatuses = [200];
  1576. _context11.next = 6;
  1577. return this.request(params);
  1578. case 6:
  1579. result = _context11.sent;
  1580. objects = result.data.Contents;
  1581. that = this;
  1582. if (objects) {
  1583. if (!Array.isArray(objects)) {
  1584. objects = [objects];
  1585. }
  1586. objects = objects.map(function (obj) {
  1587. return {
  1588. name: obj.Key,
  1589. url: that._objectUrl(obj.Key),
  1590. lastModified: obj.LastModified,
  1591. etag: obj.ETag,
  1592. type: obj.Type,
  1593. size: Number(obj.Size),
  1594. storageClass: obj.StorageClass,
  1595. owner: {
  1596. id: obj.Owner.ID,
  1597. displayName: obj.Owner.DisplayName
  1598. }
  1599. };
  1600. });
  1601. }
  1602. prefixes = result.data.CommonPrefixes || null;
  1603. if (prefixes) {
  1604. if (!Array.isArray(prefixes)) {
  1605. prefixes = [prefixes];
  1606. }
  1607. prefixes = prefixes.map(function (item) {
  1608. return item.Prefix;
  1609. });
  1610. }
  1611. return _context11.abrupt('return', {
  1612. res: result.res,
  1613. objects: objects,
  1614. prefixes: prefixes,
  1615. nextMarker: result.data.NextMarker || null,
  1616. isTruncated: result.data.IsTruncated === 'true'
  1617. });
  1618. case 13:
  1619. case 'end':
  1620. return _context11.stop();
  1621. }
  1622. }
  1623. }, list, this);
  1624. });
  1625. /*
  1626. * Set object's ACL
  1627. * @param {String} name the object key
  1628. * @param {String} acl the object ACL
  1629. * @param {Object} options
  1630. */
  1631. proto.putACL = /*#__PURE__*/_regenerator2.default.mark(function putACL(name, acl, options) {
  1632. var params, result;
  1633. return _regenerator2.default.wrap(function putACL$(_context12) {
  1634. while (1) {
  1635. switch (_context12.prev = _context12.next) {
  1636. case 0:
  1637. options = options || {};
  1638. options.subres = 'acl';
  1639. options.headers = options.headers || {};
  1640. options.headers['x-oss-object-acl'] = acl;
  1641. name = this._objectName(name);
  1642. params = this._objectRequestParams('PUT', name, options);
  1643. params.successStatuses = [200];
  1644. _context12.next = 9;
  1645. return this.request(params);
  1646. case 9:
  1647. result = _context12.sent;
  1648. return _context12.abrupt('return', {
  1649. res: result.res
  1650. });
  1651. case 11:
  1652. case 'end':
  1653. return _context12.stop();
  1654. }
  1655. }
  1656. }, putACL, this);
  1657. });
  1658. /*
  1659. * Get object's ACL
  1660. * @param {String} name the object key
  1661. * @param {Object} options
  1662. * @return {Object}
  1663. */
  1664. proto.getACL = /*#__PURE__*/_regenerator2.default.mark(function getACL(name, options) {
  1665. var params, result;
  1666. return _regenerator2.default.wrap(function getACL$(_context13) {
  1667. while (1) {
  1668. switch (_context13.prev = _context13.next) {
  1669. case 0:
  1670. options = options || {};
  1671. options.subres = 'acl';
  1672. name = this._objectName(name);
  1673. params = this._objectRequestParams('GET', name, options);
  1674. params.successStatuses = [200];
  1675. params.xmlResponse = true;
  1676. _context13.next = 8;
  1677. return this.request(params);
  1678. case 8:
  1679. result = _context13.sent;
  1680. return _context13.abrupt('return', {
  1681. acl: result.data.AccessControlList.Grant,
  1682. owner: {
  1683. id: result.data.Owner.ID,
  1684. displayName: result.data.Owner.DisplayName
  1685. },
  1686. res: result.res
  1687. });
  1688. case 10:
  1689. case 'end':
  1690. return _context13.stop();
  1691. }
  1692. }
  1693. }, getACL, this);
  1694. });
  1695. proto.signatureUrl = function (name, options) {
  1696. name = this._objectName(name);
  1697. var params = {
  1698. bucket: this.options.bucket,
  1699. object: name
  1700. };
  1701. options = options || {};
  1702. var expires = utility.timestamp() + (options.expires || 1800);
  1703. var resource = this._getResource(params);
  1704. var query = {};
  1705. var signList = [];
  1706. for (var k in options.response) {
  1707. var key = 'response-' + k.toLowerCase();
  1708. query[key] = options.response[k];
  1709. signList.push(key + '=' + options.response[k]);
  1710. }
  1711. if (this.options.stsToken) {
  1712. query['security-token'] = this.options.stsToken;
  1713. signList.push('security-token=' + this.options.stsToken);
  1714. }
  1715. if (options.process) {
  1716. var processKeyword = 'x-oss-process';
  1717. query[processKeyword] = options.process;
  1718. var item = processKeyword + '=' + options.process;
  1719. signList.push(item);
  1720. }
  1721. if (signList.length > 0) {
  1722. signList.sort();
  1723. resource += '?' + signList.join('&');
  1724. }
  1725. var stringToSign = [options.method || 'GET', options['content-md5'] || '', // Content-MD5
  1726. options['content-type'] || '', // Content-Type
  1727. expires, resource].join('\n');
  1728. var signature = this.signature(stringToSign);
  1729. var url = urlutil.parse(this._getReqUrl(params));
  1730. url.query = {
  1731. OSSAccessKeyId: this.options.accessKeyId,
  1732. Expires: expires,
  1733. Signature: signature
  1734. };
  1735. copy(query).to(url.query);
  1736. return url.format();
  1737. };
  1738. /**
  1739. * Get Object url by name
  1740. * @param {String} name - object name
  1741. * @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint`.
  1742. * @return {String} object url
  1743. */
  1744. proto.getObjectUrl = function (name, baseUrl) {
  1745. if (!baseUrl) {
  1746. baseUrl = this.options.endpoint.format();
  1747. } else if (baseUrl[baseUrl.length - 1] !== '/') {
  1748. baseUrl += '/';
  1749. }
  1750. return baseUrl + this._escape(this._objectName(name));
  1751. };
  1752. proto._objectUrl = function (name) {
  1753. return this._getReqUrl({ bucket: this.options.bucket, object: name });
  1754. };
  1755. /**
  1756. * generator request params
  1757. * @return {Object} params
  1758. *
  1759. * @api private
  1760. */
  1761. proto._objectRequestParams = function (method, name, options) {
  1762. if (!this.options.bucket) {
  1763. throw new Error('Please create a bucket first');
  1764. }
  1765. options = options || {};
  1766. name = this._objectName(name);
  1767. var params = {
  1768. object: name,
  1769. bucket: this.options.bucket,
  1770. method: method,
  1771. subres: options && options.subres,
  1772. timeout: options && options.timeout,
  1773. ctx: options && options.ctx
  1774. };
  1775. if (options.headers) {
  1776. params.headers = options.headers;
  1777. }
  1778. return params;
  1779. };
  1780. proto._objectName = function (name) {
  1781. return name.replace(/^\/+/, '');
  1782. };
  1783. proto._statFile = function (filepath) {
  1784. return function (callback) {
  1785. fs.stat(filepath, callback);
  1786. };
  1787. };
  1788. proto._convertMetaToHeaders = function (meta, headers) {
  1789. if (!meta) {
  1790. return;
  1791. }
  1792. for (var k in meta) {
  1793. headers['x-oss-meta-' + k] = meta[k];
  1794. }
  1795. };
  1796. proto._deleteFileSafe = function (filepath) {
  1797. return function (callback) {
  1798. fs.exists(filepath, function (exists) {
  1799. if (!exists) {
  1800. return callback();
  1801. }
  1802. fs.unlink(filepath, function (err) {
  1803. if (err) {
  1804. debug('unlink %j error: %s', filepath, err);
  1805. }
  1806. callback();
  1807. });
  1808. });
  1809. };
  1810. };
  1811. },{"babel-runtime/regenerator":27,"copy-to":38,"debug":142,"fs":30,"is-type-of":152,"mime":227,"path":156,"url":191,"utility":228}],5:[function(require,module,exports){
  1812. "use strict";
  1813. exports.version = "4.11.4";
  1814. },{}],6:[function(require,module,exports){
  1815. 'use strict';
  1816. var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  1817. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  1818. var _keys = require('babel-runtime/core-js/object/keys');
  1819. var _keys2 = _interopRequireDefault(_keys);
  1820. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1821. var co = require('co');
  1822. var OssClient = require('./client');
  1823. module.exports = Client;
  1824. function isGenerator(obj) {
  1825. return obj && 'function' == typeof obj.next && 'function' == typeof obj.throw;
  1826. }
  1827. function isGeneratorFunction(obj) {
  1828. if (!obj) return false;
  1829. var constructor = obj.constructor;
  1830. if (!constructor) return false;
  1831. if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true;
  1832. return isGenerator(constructor.prototype) || isGenerator(obj.prototype);
  1833. }
  1834. function wrap(ObjectClass, options) {
  1835. var client = new ObjectClass(options);
  1836. var props = (0, _keys2.default)(client);
  1837. var protoProps = (0, _keys2.default)((0, _getPrototypeOf2.default)(client));
  1838. props.concat(protoProps).forEach(function (key) {
  1839. if (isGeneratorFunction(client[key])) {
  1840. this[key] = co.wrap(client[key]).bind(client);
  1841. } else {
  1842. this[key] = client[key];
  1843. }
  1844. }, this);
  1845. }
  1846. function Client(options) {
  1847. if (!(this instanceof Client)) {
  1848. return new Client(options);
  1849. }
  1850. wrap.call(this, OssClient, options);
  1851. }
  1852. Client.STS = function STSClient(options) {
  1853. if (!(this instanceof STSClient)) {
  1854. return new STSClient(options);
  1855. }
  1856. wrap.call(this, OssClient.STS, options);
  1857. };
  1858. },{"./client":2,"babel-runtime/core-js/object/get-prototype-of":17,"babel-runtime/core-js/object/keys":18,"co":36}],7:[function(require,module,exports){
  1859. module.exports = noop;
  1860. module.exports.HttpsAgent = noop;
  1861. // Noop function for browser since native api's don't use agents.
  1862. function noop () {}
  1863. },{}],8:[function(require,module,exports){
  1864. module.exports = require('./register')().Promise
  1865. },{"./register":10}],9:[function(require,module,exports){
  1866. "use strict"
  1867. // global key for user preferred registration
  1868. var REGISTRATION_KEY = '@@any-promise/REGISTRATION',
  1869. // Prior registration (preferred or detected)
  1870. registered = null
  1871. /**
  1872. * Registers the given implementation. An implementation must
  1873. * be registered prior to any call to `require("any-promise")`,
  1874. * typically on application load.
  1875. *
  1876. * If called with no arguments, will return registration in
  1877. * following priority:
  1878. *
  1879. * For Node.js:
  1880. *
  1881. * 1. Previous registration
  1882. * 2. global.Promise if node.js version >= 0.12
  1883. * 3. Auto detected promise based on first sucessful require of
  1884. * known promise libraries. Note this is a last resort, as the
  1885. * loaded library is non-deterministic. node.js >= 0.12 will
  1886. * always use global.Promise over this priority list.
  1887. * 4. Throws error.
  1888. *
  1889. * For Browser:
  1890. *
  1891. * 1. Previous registration
  1892. * 2. window.Promise
  1893. * 3. Throws error.
  1894. *
  1895. * Options:
  1896. *
  1897. * Promise: Desired Promise constructor
  1898. * global: Boolean - Should the registration be cached in a global variable to
  1899. * allow cross dependency/bundle registration? (default true)
  1900. */
  1901. module.exports = function(root, loadImplementation){
  1902. return function register(implementation, opts){
  1903. implementation = implementation || null
  1904. opts = opts || {}
  1905. // global registration unless explicitly {global: false} in options (default true)
  1906. var registerGlobal = opts.global !== false;
  1907. // load any previous global registration
  1908. if(registered === null && registerGlobal){
  1909. registered = root[REGISTRATION_KEY] || null
  1910. }
  1911. if(registered !== null
  1912. && implementation !== null
  1913. && registered.implementation !== implementation){
  1914. // Throw error if attempting to redefine implementation
  1915. throw new Error('any-promise already defined as "'+registered.implementation+
  1916. '". You can only register an implementation before the first '+
  1917. ' call to require("any-promise") and an implementation cannot be changed')
  1918. }
  1919. if(registered === null){
  1920. // use provided implementation
  1921. if(implementation !== null && typeof opts.Promise !== 'undefined'){
  1922. registered = {
  1923. Promise: opts.Promise,
  1924. implementation: implementation
  1925. }
  1926. } else {
  1927. // require implementation if implementation is specified but not provided
  1928. registered = loadImplementation(implementation)
  1929. }
  1930. if(registerGlobal){
  1931. // register preference globally in case multiple installations
  1932. root[REGISTRATION_KEY] = registered
  1933. }
  1934. }
  1935. return registered
  1936. }
  1937. }
  1938. },{}],10:[function(require,module,exports){
  1939. "use strict";
  1940. module.exports = require('./loader')(window, loadImplementation)
  1941. /**
  1942. * Browser specific loadImplementation. Always uses `window.Promise`
  1943. *
  1944. * To register a custom implementation, must register with `Promise` option.
  1945. */
  1946. function loadImplementation(){
  1947. if(typeof window.Promise === 'undefined'){
  1948. throw new Error("any-promise browser requires a polyfill or explicit registration"+
  1949. " e.g: require('any-promise/register/bluebird')")
  1950. }
  1951. return {
  1952. Promise: window.Promise,
  1953. implementation: 'window.Promise'
  1954. }
  1955. }
  1956. },{"./loader":9}],11:[function(require,module,exports){
  1957. module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
  1958. },{"core-js/library/fn/array/from":39}],12:[function(require,module,exports){
  1959. module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
  1960. },{"core-js/library/fn/json/stringify":40}],13:[function(require,module,exports){
  1961. module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
  1962. },{"core-js/library/fn/object/assign":41}],14:[function(require,module,exports){
  1963. module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
  1964. },{"core-js/library/fn/object/create":42}],15:[function(require,module,exports){
  1965. module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
  1966. },{"core-js/library/fn/object/define-property":43}],16:[function(require,module,exports){
  1967. module.exports = { "default": require("core-js/library/fn/object/get-own-property-names"), __esModule: true };
  1968. },{"core-js/library/fn/object/get-own-property-names":44}],17:[function(require,module,exports){
  1969. module.exports = { "default": require("core-js/library/fn/object/get-prototype-of"), __esModule: true };
  1970. },{"core-js/library/fn/object/get-prototype-of":45}],18:[function(require,module,exports){
  1971. module.exports = { "default": require("core-js/library/fn/object/keys"), __esModule: true };
  1972. },{"core-js/library/fn/object/keys":46}],19:[function(require,module,exports){
  1973. module.exports = { "default": require("core-js/library/fn/set-immediate"), __esModule: true };
  1974. },{"core-js/library/fn/set-immediate":47}],20:[function(require,module,exports){
  1975. module.exports = { "default": require("core-js/library/fn/string/from-code-point"), __esModule: true };
  1976. },{"core-js/library/fn/string/from-code-point":48}],21:[function(require,module,exports){
  1977. module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
  1978. },{"core-js/library/fn/symbol":50}],22:[function(require,module,exports){
  1979. module.exports = { "default": require("core-js/library/fn/symbol/has-instance"), __esModule: true };
  1980. },{"core-js/library/fn/symbol/has-instance":49}],23:[function(require,module,exports){
  1981. module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
  1982. },{"core-js/library/fn/symbol/iterator":51}],24:[function(require,module,exports){
  1983. "use strict";
  1984. exports.__esModule = true;
  1985. exports.default = function (instance, Constructor) {
  1986. if (!(instance instanceof Constructor)) {
  1987. throw new TypeError("Cannot call a class as a function");
  1988. }
  1989. };
  1990. },{}],25:[function(require,module,exports){
  1991. "use strict";
  1992. exports.__esModule = true;
  1993. var _defineProperty = require("../core-js/object/define-property");
  1994. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  1995. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1996. exports.default = function () {
  1997. function defineProperties(target, props) {
  1998. for (var i = 0; i < props.length; i++) {
  1999. var descriptor = props[i];
  2000. descriptor.enumerable = descriptor.enumerable || false;
  2001. descriptor.configurable = true;
  2002. if ("value" in descriptor) descriptor.writable = true;
  2003. (0, _defineProperty2.default)(target, descriptor.key, descriptor);
  2004. }
  2005. }
  2006. return function (Constructor, protoProps, staticProps) {
  2007. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  2008. if (staticProps) defineProperties(Constructor, staticProps);
  2009. return Constructor;
  2010. };
  2011. }();
  2012. },{"../core-js/object/define-property":15}],26:[function(require,module,exports){
  2013. "use strict";
  2014. exports.__esModule = true;
  2015. var _iterator = require("../core-js/symbol/iterator");
  2016. var _iterator2 = _interopRequireDefault(_iterator);
  2017. var _symbol = require("../core-js/symbol");
  2018. var _symbol2 = _interopRequireDefault(_symbol);
  2019. var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
  2020. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2021. exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
  2022. return typeof obj === "undefined" ? "undefined" : _typeof(obj);
  2023. } : function (obj) {
  2024. return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
  2025. };
  2026. },{"../core-js/symbol":21,"../core-js/symbol/iterator":23}],27:[function(require,module,exports){
  2027. module.exports = require("regenerator-runtime");
  2028. },{"regenerator-runtime":179}],28:[function(require,module,exports){
  2029. 'use strict'
  2030. exports.byteLength = byteLength
  2031. exports.toByteArray = toByteArray
  2032. exports.fromByteArray = fromByteArray
  2033. var lookup = []
  2034. var revLookup = []
  2035. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  2036. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  2037. for (var i = 0, len = code.length; i < len; ++i) {
  2038. lookup[i] = code[i]
  2039. revLookup[code.charCodeAt(i)] = i
  2040. }
  2041. revLookup['-'.charCodeAt(0)] = 62
  2042. revLookup['_'.charCodeAt(0)] = 63
  2043. function placeHoldersCount (b64) {
  2044. var len = b64.length
  2045. if (len % 4 > 0) {
  2046. throw new Error('Invalid string. Length must be a multiple of 4')
  2047. }
  2048. // the number of equal signs (place holders)
  2049. // if there are two placeholders, than the two characters before it
  2050. // represent one byte
  2051. // if there is only one, then the three characters before it represent 2 bytes
  2052. // this is just a cheap hack to not do indexOf twice
  2053. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  2054. }
  2055. function byteLength (b64) {
  2056. // base64 is 4/3 + up to two characters of the original data
  2057. return (b64.length * 3 / 4) - placeHoldersCount(b64)
  2058. }
  2059. function toByteArray (b64) {
  2060. var i, l, tmp, placeHolders, arr
  2061. var len = b64.length
  2062. placeHolders = placeHoldersCount(b64)
  2063. arr = new Arr((len * 3 / 4) - placeHolders)
  2064. // if there are placeholders, only get up to the last complete 4 chars
  2065. l = placeHolders > 0 ? len - 4 : len
  2066. var L = 0
  2067. for (i = 0; i < l; i += 4) {
  2068. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  2069. arr[L++] = (tmp >> 16) & 0xFF
  2070. arr[L++] = (tmp >> 8) & 0xFF
  2071. arr[L++] = tmp & 0xFF
  2072. }
  2073. if (placeHolders === 2) {
  2074. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  2075. arr[L++] = tmp & 0xFF
  2076. } else if (placeHolders === 1) {
  2077. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  2078. arr[L++] = (tmp >> 8) & 0xFF
  2079. arr[L++] = tmp & 0xFF
  2080. }
  2081. return arr
  2082. }
  2083. function tripletToBase64 (num) {
  2084. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  2085. }
  2086. function encodeChunk (uint8, start, end) {
  2087. var tmp
  2088. var output = []
  2089. for (var i = start; i < end; i += 3) {
  2090. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  2091. output.push(tripletToBase64(tmp))
  2092. }
  2093. return output.join('')
  2094. }
  2095. function fromByteArray (uint8) {
  2096. var tmp
  2097. var len = uint8.length
  2098. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  2099. var output = ''
  2100. var parts = []
  2101. var maxChunkLength = 16383 // must be multiple of 3
  2102. // go through the array every three bytes, we'll deal with trailing stuff later
  2103. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  2104. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  2105. }
  2106. // pad the end with zeros, but make sure to not forget the extra bytes
  2107. if (extraBytes === 1) {
  2108. tmp = uint8[len - 1]
  2109. output += lookup[tmp >> 2]
  2110. output += lookup[(tmp << 4) & 0x3F]
  2111. output += '=='
  2112. } else if (extraBytes === 2) {
  2113. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  2114. output += lookup[tmp >> 10]
  2115. output += lookup[(tmp >> 4) & 0x3F]
  2116. output += lookup[(tmp << 2) & 0x3F]
  2117. output += '='
  2118. }
  2119. parts.push(output)
  2120. return parts.join('')
  2121. }
  2122. },{}],29:[function(require,module,exports){
  2123. /*!
  2124. * Bowser - a browser detector
  2125. * https://github.com/ded/bowser
  2126. * MIT License | (c) Dustin Diaz 2015
  2127. */
  2128. !function (root, name, definition) {
  2129. if (typeof module != 'undefined' && module.exports) module.exports = definition()
  2130. else if (typeof define == 'function' && define.amd) define(name, definition)
  2131. else root[name] = definition()
  2132. }(this, 'bowser', function () {
  2133. /**
  2134. * See useragents.js for examples of navigator.userAgent
  2135. */
  2136. var t = true
  2137. function detect(ua) {
  2138. function getFirstMatch(regex) {
  2139. var match = ua.match(regex);
  2140. return (match && match.length > 1 && match[1]) || '';
  2141. }
  2142. function getSecondMatch(regex) {
  2143. var match = ua.match(regex);
  2144. return (match && match.length > 1 && match[2]) || '';
  2145. }
  2146. var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
  2147. , likeAndroid = /like android/i.test(ua)
  2148. , android = !likeAndroid && /android/i.test(ua)
  2149. , nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
  2150. , nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
  2151. , chromeos = /CrOS/.test(ua)
  2152. , silk = /silk/i.test(ua)
  2153. , sailfish = /sailfish/i.test(ua)
  2154. , tizen = /tizen/i.test(ua)
  2155. , webos = /(web|hpw)os/i.test(ua)
  2156. , windowsphone = /windows phone/i.test(ua)
  2157. , samsungBrowser = /SamsungBrowser/i.test(ua)
  2158. , windows = !windowsphone && /windows/i.test(ua)
  2159. , mac = !iosdevice && !silk && /macintosh/i.test(ua)
  2160. , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
  2161. , edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i)
  2162. , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
  2163. , tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua)
  2164. , mobile = !tablet && /[^-]mobi/i.test(ua)
  2165. , xbox = /xbox/i.test(ua)
  2166. , result
  2167. if (/opera/i.test(ua)) {
  2168. // an old Opera
  2169. result = {
  2170. name: 'Opera'
  2171. , opera: t
  2172. , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
  2173. }
  2174. } else if (/opr\/|opios/i.test(ua)) {
  2175. // a new Opera
  2176. result = {
  2177. name: 'Opera'
  2178. , opera: t
  2179. , version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
  2180. }
  2181. }
  2182. else if (/SamsungBrowser/i.test(ua)) {
  2183. result = {
  2184. name: 'Samsung Internet for Android'
  2185. , samsungBrowser: t
  2186. , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
  2187. }
  2188. }
  2189. else if (/coast/i.test(ua)) {
  2190. result = {
  2191. name: 'Opera Coast'
  2192. , coast: t
  2193. , version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
  2194. }
  2195. }
  2196. else if (/yabrowser/i.test(ua)) {
  2197. result = {
  2198. name: 'Yandex Browser'
  2199. , yandexbrowser: t
  2200. , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
  2201. }
  2202. }
  2203. else if (/ucbrowser/i.test(ua)) {
  2204. result = {
  2205. name: 'UC Browser'
  2206. , ucbrowser: t
  2207. , version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
  2208. }
  2209. }
  2210. else if (/mxios/i.test(ua)) {
  2211. result = {
  2212. name: 'Maxthon'
  2213. , maxthon: t
  2214. , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
  2215. }
  2216. }
  2217. else if (/epiphany/i.test(ua)) {
  2218. result = {
  2219. name: 'Epiphany'
  2220. , epiphany: t
  2221. , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
  2222. }
  2223. }
  2224. else if (/puffin/i.test(ua)) {
  2225. result = {
  2226. name: 'Puffin'
  2227. , puffin: t
  2228. , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
  2229. }
  2230. }
  2231. else if (/sleipnir/i.test(ua)) {
  2232. result = {
  2233. name: 'Sleipnir'
  2234. , sleipnir: t
  2235. , version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
  2236. }
  2237. }
  2238. else if (/k-meleon/i.test(ua)) {
  2239. result = {
  2240. name: 'K-Meleon'
  2241. , kMeleon: t
  2242. , version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
  2243. }
  2244. }
  2245. else if (windowsphone) {
  2246. result = {
  2247. name: 'Windows Phone'
  2248. , osname: 'Windows Phone'
  2249. , windowsphone: t
  2250. }
  2251. if (edgeVersion) {
  2252. result.msedge = t
  2253. result.version = edgeVersion
  2254. }
  2255. else {
  2256. result.msie = t
  2257. result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
  2258. }
  2259. }
  2260. else if (/msie|trident/i.test(ua)) {
  2261. result = {
  2262. name: 'Internet Explorer'
  2263. , msie: t
  2264. , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
  2265. }
  2266. } else if (chromeos) {
  2267. result = {
  2268. name: 'Chrome'
  2269. , osname: 'Chrome OS'
  2270. , chromeos: t
  2271. , chromeBook: t
  2272. , chrome: t
  2273. , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
  2274. }
  2275. } else if (/edg([ea]|ios)/i.test(ua)) {
  2276. result = {
  2277. name: 'Microsoft Edge'
  2278. , msedge: t
  2279. , version: edgeVersion
  2280. }
  2281. }
  2282. else if (/vivaldi/i.test(ua)) {
  2283. result = {
  2284. name: 'Vivaldi'
  2285. , vivaldi: t
  2286. , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
  2287. }
  2288. }
  2289. else if (sailfish) {
  2290. result = {
  2291. name: 'Sailfish'
  2292. , osname: 'Sailfish OS'
  2293. , sailfish: t
  2294. , version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
  2295. }
  2296. }
  2297. else if (/seamonkey\//i.test(ua)) {
  2298. result = {
  2299. name: 'SeaMonkey'
  2300. , seamonkey: t
  2301. , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
  2302. }
  2303. }
  2304. else if (/firefox|iceweasel|fxios/i.test(ua)) {
  2305. result = {
  2306. name: 'Firefox'
  2307. , firefox: t
  2308. , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
  2309. }
  2310. if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
  2311. result.firefoxos = t
  2312. result.osname = 'Firefox OS'
  2313. }
  2314. }
  2315. else if (silk) {
  2316. result = {
  2317. name: 'Amazon Silk'
  2318. , silk: t
  2319. , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
  2320. }
  2321. }
  2322. else if (/phantom/i.test(ua)) {
  2323. result = {
  2324. name: 'PhantomJS'
  2325. , phantom: t
  2326. , version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
  2327. }
  2328. }
  2329. else if (/slimerjs/i.test(ua)) {
  2330. result = {
  2331. name: 'SlimerJS'
  2332. , slimer: t
  2333. , version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
  2334. }
  2335. }
  2336. else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
  2337. result = {
  2338. name: 'BlackBerry'
  2339. , osname: 'BlackBerry OS'
  2340. , blackberry: t
  2341. , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
  2342. }
  2343. }
  2344. else if (webos) {
  2345. result = {
  2346. name: 'WebOS'
  2347. , osname: 'WebOS'
  2348. , webos: t
  2349. , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
  2350. };
  2351. /touchpad\//i.test(ua) && (result.touchpad = t)
  2352. }
  2353. else if (/bada/i.test(ua)) {
  2354. result = {
  2355. name: 'Bada'
  2356. , osname: 'Bada'
  2357. , bada: t
  2358. , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
  2359. };
  2360. }
  2361. else if (tizen) {
  2362. result = {
  2363. name: 'Tizen'
  2364. , osname: 'Tizen'
  2365. , tizen: t
  2366. , version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
  2367. };
  2368. }
  2369. else if (/qupzilla/i.test(ua)) {
  2370. result = {
  2371. name: 'QupZilla'
  2372. , qupzilla: t
  2373. , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
  2374. }
  2375. }
  2376. else if (/chromium/i.test(ua)) {
  2377. result = {
  2378. name: 'Chromium'
  2379. , chromium: t
  2380. , version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
  2381. }
  2382. }
  2383. else if (/chrome|crios|crmo/i.test(ua)) {
  2384. result = {
  2385. name: 'Chrome'
  2386. , chrome: t
  2387. , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
  2388. }
  2389. }
  2390. else if (android) {
  2391. result = {
  2392. name: 'Android'
  2393. , version: versionIdentifier
  2394. }
  2395. }
  2396. else if (/safari|applewebkit/i.test(ua)) {
  2397. result = {
  2398. name: 'Safari'
  2399. , safari: t
  2400. }
  2401. if (versionIdentifier) {
  2402. result.version = versionIdentifier
  2403. }
  2404. }
  2405. else if (iosdevice) {
  2406. result = {
  2407. name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
  2408. }
  2409. // WTF: version is not part of user agent in web apps
  2410. if (versionIdentifier) {
  2411. result.version = versionIdentifier
  2412. }
  2413. }
  2414. else if(/googlebot/i.test(ua)) {
  2415. result = {
  2416. name: 'Googlebot'
  2417. , googlebot: t
  2418. , version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
  2419. }
  2420. }
  2421. else {
  2422. result = {
  2423. name: getFirstMatch(/^(.*)\/(.*) /),
  2424. version: getSecondMatch(/^(.*)\/(.*) /)
  2425. };
  2426. }
  2427. // set webkit or gecko flag for browsers based on these engines
  2428. if (!result.msedge && /(apple)?webkit/i.test(ua)) {
  2429. if (/(apple)?webkit\/537\.36/i.test(ua)) {
  2430. result.name = result.name || "Blink"
  2431. result.blink = t
  2432. } else {
  2433. result.name = result.name || "Webkit"
  2434. result.webkit = t
  2435. }
  2436. if (!result.version && versionIdentifier) {
  2437. result.version = versionIdentifier
  2438. }
  2439. } else if (!result.opera && /gecko\//i.test(ua)) {
  2440. result.name = result.name || "Gecko"
  2441. result.gecko = t
  2442. result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
  2443. }
  2444. // set OS flags for platforms that have multiple browsers
  2445. if (!result.windowsphone && (android || result.silk)) {
  2446. result.android = t
  2447. result.osname = 'Android'
  2448. } else if (!result.windowsphone && iosdevice) {
  2449. result[iosdevice] = t
  2450. result.ios = t
  2451. result.osname = 'iOS'
  2452. } else if (mac) {
  2453. result.mac = t
  2454. result.osname = 'macOS'
  2455. } else if (xbox) {
  2456. result.xbox = t
  2457. result.osname = 'Xbox'
  2458. } else if (windows) {
  2459. result.windows = t
  2460. result.osname = 'Windows'
  2461. } else if (linux) {
  2462. result.linux = t
  2463. result.osname = 'Linux'
  2464. }
  2465. function getWindowsVersion (s) {
  2466. switch (s) {
  2467. case 'NT': return 'NT'
  2468. case 'XP': return 'XP'
  2469. case 'NT 5.0': return '2000'
  2470. case 'NT 5.1': return 'XP'
  2471. case 'NT 5.2': return '2003'
  2472. case 'NT 6.0': return 'Vista'
  2473. case 'NT 6.1': return '7'
  2474. case 'NT 6.2': return '8'
  2475. case 'NT 6.3': return '8.1'
  2476. case 'NT 10.0': return '10'
  2477. default: return undefined
  2478. }
  2479. }
  2480. // OS version extraction
  2481. var osVersion = '';
  2482. if (result.windows) {
  2483. osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
  2484. } else if (result.windowsphone) {
  2485. osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
  2486. } else if (result.mac) {
  2487. osVersion = getFirstMatch(/Mac OS X (\d+([_\.\s]\d+)*)/i);
  2488. osVersion = osVersion.replace(/[_\s]/g, '.');
  2489. } else if (iosdevice) {
  2490. osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
  2491. osVersion = osVersion.replace(/[_\s]/g, '.');
  2492. } else if (android) {
  2493. osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
  2494. } else if (result.webos) {
  2495. osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
  2496. } else if (result.blackberry) {
  2497. osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
  2498. } else if (result.bada) {
  2499. osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
  2500. } else if (result.tizen) {
  2501. osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
  2502. }
  2503. if (osVersion) {
  2504. result.osversion = osVersion;
  2505. }
  2506. // device type extraction
  2507. var osMajorVersion = !result.windows && osVersion.split('.')[0];
  2508. if (
  2509. tablet
  2510. || nexusTablet
  2511. || iosdevice == 'ipad'
  2512. || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
  2513. || result.silk
  2514. ) {
  2515. result.tablet = t
  2516. } else if (
  2517. mobile
  2518. || iosdevice == 'iphone'
  2519. || iosdevice == 'ipod'
  2520. || android
  2521. || nexusMobile
  2522. || result.blackberry
  2523. || result.webos
  2524. || result.bada
  2525. ) {
  2526. result.mobile = t
  2527. }
  2528. // Graded Browser Support
  2529. // http://developer.yahoo.com/yui/articles/gbs
  2530. if (result.msedge ||
  2531. (result.msie && result.version >= 10) ||
  2532. (result.yandexbrowser && result.version >= 15) ||
  2533. (result.vivaldi && result.version >= 1.0) ||
  2534. (result.chrome && result.version >= 20) ||
  2535. (result.samsungBrowser && result.version >= 4) ||
  2536. (result.firefox && result.version >= 20.0) ||
  2537. (result.safari && result.version >= 6) ||
  2538. (result.opera && result.version >= 10.0) ||
  2539. (result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
  2540. (result.blackberry && result.version >= 10.1)
  2541. || (result.chromium && result.version >= 20)
  2542. ) {
  2543. result.a = t;
  2544. }
  2545. else if ((result.msie && result.version < 10) ||
  2546. (result.chrome && result.version < 20) ||
  2547. (result.firefox && result.version < 20.0) ||
  2548. (result.safari && result.version < 6) ||
  2549. (result.opera && result.version < 10.0) ||
  2550. (result.ios && result.osversion && result.osversion.split(".")[0] < 6)
  2551. || (result.chromium && result.version < 20)
  2552. ) {
  2553. result.c = t
  2554. } else result.x = t
  2555. return result
  2556. }
  2557. var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
  2558. bowser.test = function (browserList) {
  2559. for (var i = 0; i < browserList.length; ++i) {
  2560. var browserItem = browserList[i];
  2561. if (typeof browserItem=== 'string') {
  2562. if (browserItem in bowser) {
  2563. return true;
  2564. }
  2565. }
  2566. }
  2567. return false;
  2568. }
  2569. /**
  2570. * Get version precisions count
  2571. *
  2572. * @example
  2573. * getVersionPrecision("1.10.3") // 3
  2574. *
  2575. * @param {string} version
  2576. * @return {number}
  2577. */
  2578. function getVersionPrecision(version) {
  2579. return version.split(".").length;
  2580. }
  2581. /**
  2582. * Array::map polyfill
  2583. *
  2584. * @param {Array} arr
  2585. * @param {Function} iterator
  2586. * @return {Array}
  2587. */
  2588. function map(arr, iterator) {
  2589. var result = [], i;
  2590. if (Array.prototype.map) {
  2591. return Array.prototype.map.call(arr, iterator);
  2592. }
  2593. for (i = 0; i < arr.length; i++) {
  2594. result.push(iterator(arr[i]));
  2595. }
  2596. return result;
  2597. }
  2598. /**
  2599. * Calculate browser version weight
  2600. *
  2601. * @example
  2602. * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
  2603. * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
  2604. * compareVersions(['1.10.2.1', '1.10.2.1']); // 0
  2605. * compareVersions(['1.10.2.1', '1.0800.2']); // -1
  2606. *
  2607. * @param {Array<String>} versions versions to compare
  2608. * @return {Number} comparison result
  2609. */
  2610. function compareVersions(versions) {
  2611. // 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
  2612. var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
  2613. var chunks = map(versions, function (version) {
  2614. var delta = precision - getVersionPrecision(version);
  2615. // 2) "9" -> "9.0" (for precision = 2)
  2616. version = version + new Array(delta + 1).join(".0");
  2617. // 3) "9.0" -> ["000000000"", "000000009"]
  2618. return map(version.split("."), function (chunk) {
  2619. return new Array(20 - chunk.length).join("0") + chunk;
  2620. }).reverse();
  2621. });
  2622. // iterate in reverse order by reversed chunks array
  2623. while (--precision >= 0) {
  2624. // 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
  2625. if (chunks[0][precision] > chunks[1][precision]) {
  2626. return 1;
  2627. }
  2628. else if (chunks[0][precision] === chunks[1][precision]) {
  2629. if (precision === 0) {
  2630. // all version chunks are same
  2631. return 0;
  2632. }
  2633. }
  2634. else {
  2635. return -1;
  2636. }
  2637. }
  2638. }
  2639. /**
  2640. * Check if browser is unsupported
  2641. *
  2642. * @example
  2643. * bowser.isUnsupportedBrowser({
  2644. * msie: "10",
  2645. * firefox: "23",
  2646. * chrome: "29",
  2647. * safari: "5.1",
  2648. * opera: "16",
  2649. * phantom: "534"
  2650. * });
  2651. *
  2652. * @param {Object} minVersions map of minimal version to browser
  2653. * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
  2654. * @param {String} [ua] user agent string
  2655. * @return {Boolean}
  2656. */
  2657. function isUnsupportedBrowser(minVersions, strictMode, ua) {
  2658. var _bowser = bowser;
  2659. // make strictMode param optional with ua param usage
  2660. if (typeof strictMode === 'string') {
  2661. ua = strictMode;
  2662. strictMode = void(0);
  2663. }
  2664. if (strictMode === void(0)) {
  2665. strictMode = false;
  2666. }
  2667. if (ua) {
  2668. _bowser = detect(ua);
  2669. }
  2670. var version = "" + _bowser.version;
  2671. for (var browser in minVersions) {
  2672. if (minVersions.hasOwnProperty(browser)) {
  2673. if (_bowser[browser]) {
  2674. if (typeof minVersions[browser] !== 'string') {
  2675. throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
  2676. }
  2677. // browser version and min supported version.
  2678. return compareVersions([version, minVersions[browser]]) < 0;
  2679. }
  2680. }
  2681. }
  2682. return strictMode; // not found
  2683. }
  2684. /**
  2685. * Check if browser is supported
  2686. *
  2687. * @param {Object} minVersions map of minimal version to browser
  2688. * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
  2689. * @param {String} [ua] user agent string
  2690. * @return {Boolean}
  2691. */
  2692. function check(minVersions, strictMode, ua) {
  2693. return !isUnsupportedBrowser(minVersions, strictMode, ua);
  2694. }
  2695. bowser.isUnsupportedBrowser = isUnsupportedBrowser;
  2696. bowser.compareVersions = compareVersions;
  2697. bowser.check = check;
  2698. /*
  2699. * Set our detect method to the main bowser object so we can
  2700. * reuse it to test other user agents.
  2701. * This is needed to implement future tests.
  2702. */
  2703. bowser._detect = detect;
  2704. return bowser
  2705. });
  2706. },{}],30:[function(require,module,exports){
  2707. },{}],31:[function(require,module,exports){
  2708. (function (global){
  2709. /*!
  2710. * The buffer module from node.js, for the browser.
  2711. *
  2712. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  2713. * @license MIT
  2714. */
  2715. /* eslint-disable no-proto */
  2716. 'use strict'
  2717. var base64 = require('base64-js')
  2718. var ieee754 = require('ieee754')
  2719. var isArray = require('isarray')
  2720. exports.Buffer = Buffer
  2721. exports.SlowBuffer = SlowBuffer
  2722. exports.INSPECT_MAX_BYTES = 50
  2723. /**
  2724. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2725. * === true Use Uint8Array implementation (fastest)
  2726. * === false Use Object implementation (most compatible, even IE6)
  2727. *
  2728. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2729. * Opera 11.6+, iOS 4.2+.
  2730. *
  2731. * Due to various browser bugs, sometimes the Object implementation will be used even
  2732. * when the browser supports typed arrays.
  2733. *
  2734. * Note:
  2735. *
  2736. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  2737. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  2738. *
  2739. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  2740. *
  2741. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  2742. * incorrect length in some situations.
  2743. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  2744. * get the Object implementation, which is slower but behaves correctly.
  2745. */
  2746. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  2747. ? global.TYPED_ARRAY_SUPPORT
  2748. : typedArraySupport()
  2749. /*
  2750. * Export kMaxLength after typed array support is determined.
  2751. */
  2752. exports.kMaxLength = kMaxLength()
  2753. function typedArraySupport () {
  2754. try {
  2755. var arr = new Uint8Array(1)
  2756. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  2757. return arr.foo() === 42 && // typed array instances can be augmented
  2758. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  2759. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  2760. } catch (e) {
  2761. return false
  2762. }
  2763. }
  2764. function kMaxLength () {
  2765. return Buffer.TYPED_ARRAY_SUPPORT
  2766. ? 0x7fffffff
  2767. : 0x3fffffff
  2768. }
  2769. function createBuffer (that, length) {
  2770. if (kMaxLength() < length) {
  2771. throw new RangeError('Invalid typed array length')
  2772. }
  2773. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2774. // Return an augmented `Uint8Array` instance, for best performance
  2775. that = new Uint8Array(length)
  2776. that.__proto__ = Buffer.prototype
  2777. } else {
  2778. // Fallback: Return an object instance of the Buffer class
  2779. if (that === null) {
  2780. that = new Buffer(length)
  2781. }
  2782. that.length = length
  2783. }
  2784. return that
  2785. }
  2786. /**
  2787. * The Buffer constructor returns instances of `Uint8Array` that have their
  2788. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  2789. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  2790. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  2791. * returns a single octet.
  2792. *
  2793. * The `Uint8Array` prototype remains unmodified.
  2794. */
  2795. function Buffer (arg, encodingOrOffset, length) {
  2796. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  2797. return new Buffer(arg, encodingOrOffset, length)
  2798. }
  2799. // Common case.
  2800. if (typeof arg === 'number') {
  2801. if (typeof encodingOrOffset === 'string') {
  2802. throw new Error(
  2803. 'If encoding is specified then the first argument must be a string'
  2804. )
  2805. }
  2806. return allocUnsafe(this, arg)
  2807. }
  2808. return from(this, arg, encodingOrOffset, length)
  2809. }
  2810. Buffer.poolSize = 8192 // not used by this implementation
  2811. // TODO: Legacy, not needed anymore. Remove in next major version.
  2812. Buffer._augment = function (arr) {
  2813. arr.__proto__ = Buffer.prototype
  2814. return arr
  2815. }
  2816. function from (that, value, encodingOrOffset, length) {
  2817. if (typeof value === 'number') {
  2818. throw new TypeError('"value" argument must not be a number')
  2819. }
  2820. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  2821. return fromArrayBuffer(that, value, encodingOrOffset, length)
  2822. }
  2823. if (typeof value === 'string') {
  2824. return fromString(that, value, encodingOrOffset)
  2825. }
  2826. return fromObject(that, value)
  2827. }
  2828. /**
  2829. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  2830. * if value is a number.
  2831. * Buffer.from(str[, encoding])
  2832. * Buffer.from(array)
  2833. * Buffer.from(buffer)
  2834. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  2835. **/
  2836. Buffer.from = function (value, encodingOrOffset, length) {
  2837. return from(null, value, encodingOrOffset, length)
  2838. }
  2839. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2840. Buffer.prototype.__proto__ = Uint8Array.prototype
  2841. Buffer.__proto__ = Uint8Array
  2842. if (typeof Symbol !== 'undefined' && Symbol.species &&
  2843. Buffer[Symbol.species] === Buffer) {
  2844. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  2845. Object.defineProperty(Buffer, Symbol.species, {
  2846. value: null,
  2847. configurable: true
  2848. })
  2849. }
  2850. }
  2851. function assertSize (size) {
  2852. if (typeof size !== 'number') {
  2853. throw new TypeError('"size" argument must be a number')
  2854. } else if (size < 0) {
  2855. throw new RangeError('"size" argument must not be negative')
  2856. }
  2857. }
  2858. function alloc (that, size, fill, encoding) {
  2859. assertSize(size)
  2860. if (size <= 0) {
  2861. return createBuffer(that, size)
  2862. }
  2863. if (fill !== undefined) {
  2864. // Only pay attention to encoding if it's a string. This
  2865. // prevents accidentally sending in a number that would
  2866. // be interpretted as a start offset.
  2867. return typeof encoding === 'string'
  2868. ? createBuffer(that, size).fill(fill, encoding)
  2869. : createBuffer(that, size).fill(fill)
  2870. }
  2871. return createBuffer(that, size)
  2872. }
  2873. /**
  2874. * Creates a new filled Buffer instance.
  2875. * alloc(size[, fill[, encoding]])
  2876. **/
  2877. Buffer.alloc = function (size, fill, encoding) {
  2878. return alloc(null, size, fill, encoding)
  2879. }
  2880. function allocUnsafe (that, size) {
  2881. assertSize(size)
  2882. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  2883. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  2884. for (var i = 0; i < size; ++i) {
  2885. that[i] = 0
  2886. }
  2887. }
  2888. return that
  2889. }
  2890. /**
  2891. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  2892. * */
  2893. Buffer.allocUnsafe = function (size) {
  2894. return allocUnsafe(null, size)
  2895. }
  2896. /**
  2897. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  2898. */
  2899. Buffer.allocUnsafeSlow = function (size) {
  2900. return allocUnsafe(null, size)
  2901. }
  2902. function fromString (that, string, encoding) {
  2903. if (typeof encoding !== 'string' || encoding === '') {
  2904. encoding = 'utf8'
  2905. }
  2906. if (!Buffer.isEncoding(encoding)) {
  2907. throw new TypeError('"encoding" must be a valid string encoding')
  2908. }
  2909. var length = byteLength(string, encoding) | 0
  2910. that = createBuffer(that, length)
  2911. var actual = that.write(string, encoding)
  2912. if (actual !== length) {
  2913. // Writing a hex string, for example, that contains invalid characters will
  2914. // cause everything after the first invalid character to be ignored. (e.g.
  2915. // 'abxxcd' will be treated as 'ab')
  2916. that = that.slice(0, actual)
  2917. }
  2918. return that
  2919. }
  2920. function fromArrayLike (that, array) {
  2921. var length = array.length < 0 ? 0 : checked(array.length) | 0
  2922. that = createBuffer(that, length)
  2923. for (var i = 0; i < length; i += 1) {
  2924. that[i] = array[i] & 255
  2925. }
  2926. return that
  2927. }
  2928. function fromArrayBuffer (that, array, byteOffset, length) {
  2929. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  2930. if (byteOffset < 0 || array.byteLength < byteOffset) {
  2931. throw new RangeError('\'offset\' is out of bounds')
  2932. }
  2933. if (array.byteLength < byteOffset + (length || 0)) {
  2934. throw new RangeError('\'length\' is out of bounds')
  2935. }
  2936. if (byteOffset === undefined && length === undefined) {
  2937. array = new Uint8Array(array)
  2938. } else if (length === undefined) {
  2939. array = new Uint8Array(array, byteOffset)
  2940. } else {
  2941. array = new Uint8Array(array, byteOffset, length)
  2942. }
  2943. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2944. // Return an augmented `Uint8Array` instance, for best performance
  2945. that = array
  2946. that.__proto__ = Buffer.prototype
  2947. } else {
  2948. // Fallback: Return an object instance of the Buffer class
  2949. that = fromArrayLike(that, array)
  2950. }
  2951. return that
  2952. }
  2953. function fromObject (that, obj) {
  2954. if (Buffer.isBuffer(obj)) {
  2955. var len = checked(obj.length) | 0
  2956. that = createBuffer(that, len)
  2957. if (that.length === 0) {
  2958. return that
  2959. }
  2960. obj.copy(that, 0, 0, len)
  2961. return that
  2962. }
  2963. if (obj) {
  2964. if ((typeof ArrayBuffer !== 'undefined' &&
  2965. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  2966. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  2967. return createBuffer(that, 0)
  2968. }
  2969. return fromArrayLike(that, obj)
  2970. }
  2971. if (obj.type === 'Buffer' && isArray(obj.data)) {
  2972. return fromArrayLike(that, obj.data)
  2973. }
  2974. }
  2975. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  2976. }
  2977. function checked (length) {
  2978. // Note: cannot use `length < kMaxLength()` here because that fails when
  2979. // length is NaN (which is otherwise coerced to zero.)
  2980. if (length >= kMaxLength()) {
  2981. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  2982. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  2983. }
  2984. return length | 0
  2985. }
  2986. function SlowBuffer (length) {
  2987. if (+length != length) { // eslint-disable-line eqeqeq
  2988. length = 0
  2989. }
  2990. return Buffer.alloc(+length)
  2991. }
  2992. Buffer.isBuffer = function isBuffer (b) {
  2993. return !!(b != null && b._isBuffer)
  2994. }
  2995. Buffer.compare = function compare (a, b) {
  2996. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  2997. throw new TypeError('Arguments must be Buffers')
  2998. }
  2999. if (a === b) return 0
  3000. var x = a.length
  3001. var y = b.length
  3002. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  3003. if (a[i] !== b[i]) {
  3004. x = a[i]
  3005. y = b[i]
  3006. break
  3007. }
  3008. }
  3009. if (x < y) return -1
  3010. if (y < x) return 1
  3011. return 0
  3012. }
  3013. Buffer.isEncoding = function isEncoding (encoding) {
  3014. switch (String(encoding).toLowerCase()) {
  3015. case 'hex':
  3016. case 'utf8':
  3017. case 'utf-8':
  3018. case 'ascii':
  3019. case 'latin1':
  3020. case 'binary':
  3021. case 'base64':
  3022. case 'ucs2':
  3023. case 'ucs-2':
  3024. case 'utf16le':
  3025. case 'utf-16le':
  3026. return true
  3027. default:
  3028. return false
  3029. }
  3030. }
  3031. Buffer.concat = function concat (list, length) {
  3032. if (!isArray(list)) {
  3033. throw new TypeError('"list" argument must be an Array of Buffers')
  3034. }
  3035. if (list.length === 0) {
  3036. return Buffer.alloc(0)
  3037. }
  3038. var i
  3039. if (length === undefined) {
  3040. length = 0
  3041. for (i = 0; i < list.length; ++i) {
  3042. length += list[i].length
  3043. }
  3044. }
  3045. var buffer = Buffer.allocUnsafe(length)
  3046. var pos = 0
  3047. for (i = 0; i < list.length; ++i) {
  3048. var buf = list[i]
  3049. if (!Buffer.isBuffer(buf)) {
  3050. throw new TypeError('"list" argument must be an Array of Buffers')
  3051. }
  3052. buf.copy(buffer, pos)
  3053. pos += buf.length
  3054. }
  3055. return buffer
  3056. }
  3057. function byteLength (string, encoding) {
  3058. if (Buffer.isBuffer(string)) {
  3059. return string.length
  3060. }
  3061. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  3062. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  3063. return string.byteLength
  3064. }
  3065. if (typeof string !== 'string') {
  3066. string = '' + string
  3067. }
  3068. var len = string.length
  3069. if (len === 0) return 0
  3070. // Use a for loop to avoid recursion
  3071. var loweredCase = false
  3072. for (;;) {
  3073. switch (encoding) {
  3074. case 'ascii':
  3075. case 'latin1':
  3076. case 'binary':
  3077. return len
  3078. case 'utf8':
  3079. case 'utf-8':
  3080. case undefined:
  3081. return utf8ToBytes(string).length
  3082. case 'ucs2':
  3083. case 'ucs-2':
  3084. case 'utf16le':
  3085. case 'utf-16le':
  3086. return len * 2
  3087. case 'hex':
  3088. return len >>> 1
  3089. case 'base64':
  3090. return base64ToBytes(string).length
  3091. default:
  3092. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  3093. encoding = ('' + encoding).toLowerCase()
  3094. loweredCase = true
  3095. }
  3096. }
  3097. }
  3098. Buffer.byteLength = byteLength
  3099. function slowToString (encoding, start, end) {
  3100. var loweredCase = false
  3101. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  3102. // property of a typed array.
  3103. // This behaves neither like String nor Uint8Array in that we set start/end
  3104. // to their upper/lower bounds if the value passed is out of range.
  3105. // undefined is handled specially as per ECMA-262 6th Edition,
  3106. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  3107. if (start === undefined || start < 0) {
  3108. start = 0
  3109. }
  3110. // Return early if start > this.length. Done here to prevent potential uint32
  3111. // coercion fail below.
  3112. if (start > this.length) {
  3113. return ''
  3114. }
  3115. if (end === undefined || end > this.length) {
  3116. end = this.length
  3117. }
  3118. if (end <= 0) {
  3119. return ''
  3120. }
  3121. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  3122. end >>>= 0
  3123. start >>>= 0
  3124. if (end <= start) {
  3125. return ''
  3126. }
  3127. if (!encoding) encoding = 'utf8'
  3128. while (true) {
  3129. switch (encoding) {
  3130. case 'hex':
  3131. return hexSlice(this, start, end)
  3132. case 'utf8':
  3133. case 'utf-8':
  3134. return utf8Slice(this, start, end)
  3135. case 'ascii':
  3136. return asciiSlice(this, start, end)
  3137. case 'latin1':
  3138. case 'binary':
  3139. return latin1Slice(this, start, end)
  3140. case 'base64':
  3141. return base64Slice(this, start, end)
  3142. case 'ucs2':
  3143. case 'ucs-2':
  3144. case 'utf16le':
  3145. case 'utf-16le':
  3146. return utf16leSlice(this, start, end)
  3147. default:
  3148. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3149. encoding = (encoding + '').toLowerCase()
  3150. loweredCase = true
  3151. }
  3152. }
  3153. }
  3154. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  3155. // Buffer instances.
  3156. Buffer.prototype._isBuffer = true
  3157. function swap (b, n, m) {
  3158. var i = b[n]
  3159. b[n] = b[m]
  3160. b[m] = i
  3161. }
  3162. Buffer.prototype.swap16 = function swap16 () {
  3163. var len = this.length
  3164. if (len % 2 !== 0) {
  3165. throw new RangeError('Buffer size must be a multiple of 16-bits')
  3166. }
  3167. for (var i = 0; i < len; i += 2) {
  3168. swap(this, i, i + 1)
  3169. }
  3170. return this
  3171. }
  3172. Buffer.prototype.swap32 = function swap32 () {
  3173. var len = this.length
  3174. if (len % 4 !== 0) {
  3175. throw new RangeError('Buffer size must be a multiple of 32-bits')
  3176. }
  3177. for (var i = 0; i < len; i += 4) {
  3178. swap(this, i, i + 3)
  3179. swap(this, i + 1, i + 2)
  3180. }
  3181. return this
  3182. }
  3183. Buffer.prototype.swap64 = function swap64 () {
  3184. var len = this.length
  3185. if (len % 8 !== 0) {
  3186. throw new RangeError('Buffer size must be a multiple of 64-bits')
  3187. }
  3188. for (var i = 0; i < len; i += 8) {
  3189. swap(this, i, i + 7)
  3190. swap(this, i + 1, i + 6)
  3191. swap(this, i + 2, i + 5)
  3192. swap(this, i + 3, i + 4)
  3193. }
  3194. return this
  3195. }
  3196. Buffer.prototype.toString = function toString () {
  3197. var length = this.length | 0
  3198. if (length === 0) return ''
  3199. if (arguments.length === 0) return utf8Slice(this, 0, length)
  3200. return slowToString.apply(this, arguments)
  3201. }
  3202. Buffer.prototype.equals = function equals (b) {
  3203. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  3204. if (this === b) return true
  3205. return Buffer.compare(this, b) === 0
  3206. }
  3207. Buffer.prototype.inspect = function inspect () {
  3208. var str = ''
  3209. var max = exports.INSPECT_MAX_BYTES
  3210. if (this.length > 0) {
  3211. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  3212. if (this.length > max) str += ' ... '
  3213. }
  3214. return '<Buffer ' + str + '>'
  3215. }
  3216. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  3217. if (!Buffer.isBuffer(target)) {
  3218. throw new TypeError('Argument must be a Buffer')
  3219. }
  3220. if (start === undefined) {
  3221. start = 0
  3222. }
  3223. if (end === undefined) {
  3224. end = target ? target.length : 0
  3225. }
  3226. if (thisStart === undefined) {
  3227. thisStart = 0
  3228. }
  3229. if (thisEnd === undefined) {
  3230. thisEnd = this.length
  3231. }
  3232. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  3233. throw new RangeError('out of range index')
  3234. }
  3235. if (thisStart >= thisEnd && start >= end) {
  3236. return 0
  3237. }
  3238. if (thisStart >= thisEnd) {
  3239. return -1
  3240. }
  3241. if (start >= end) {
  3242. return 1
  3243. }
  3244. start >>>= 0
  3245. end >>>= 0
  3246. thisStart >>>= 0
  3247. thisEnd >>>= 0
  3248. if (this === target) return 0
  3249. var x = thisEnd - thisStart
  3250. var y = end - start
  3251. var len = Math.min(x, y)
  3252. var thisCopy = this.slice(thisStart, thisEnd)
  3253. var targetCopy = target.slice(start, end)
  3254. for (var i = 0; i < len; ++i) {
  3255. if (thisCopy[i] !== targetCopy[i]) {
  3256. x = thisCopy[i]
  3257. y = targetCopy[i]
  3258. break
  3259. }
  3260. }
  3261. if (x < y) return -1
  3262. if (y < x) return 1
  3263. return 0
  3264. }
  3265. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  3266. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  3267. //
  3268. // Arguments:
  3269. // - buffer - a Buffer to search
  3270. // - val - a string, Buffer, or number
  3271. // - byteOffset - an index into `buffer`; will be clamped to an int32
  3272. // - encoding - an optional encoding, relevant is val is a string
  3273. // - dir - true for indexOf, false for lastIndexOf
  3274. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  3275. // Empty buffer means no match
  3276. if (buffer.length === 0) return -1
  3277. // Normalize byteOffset
  3278. if (typeof byteOffset === 'string') {
  3279. encoding = byteOffset
  3280. byteOffset = 0
  3281. } else if (byteOffset > 0x7fffffff) {
  3282. byteOffset = 0x7fffffff
  3283. } else if (byteOffset < -0x80000000) {
  3284. byteOffset = -0x80000000
  3285. }
  3286. byteOffset = +byteOffset // Coerce to Number.
  3287. if (isNaN(byteOffset)) {
  3288. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  3289. byteOffset = dir ? 0 : (buffer.length - 1)
  3290. }
  3291. // Normalize byteOffset: negative offsets start from the end of the buffer
  3292. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  3293. if (byteOffset >= buffer.length) {
  3294. if (dir) return -1
  3295. else byteOffset = buffer.length - 1
  3296. } else if (byteOffset < 0) {
  3297. if (dir) byteOffset = 0
  3298. else return -1
  3299. }
  3300. // Normalize val
  3301. if (typeof val === 'string') {
  3302. val = Buffer.from(val, encoding)
  3303. }
  3304. // Finally, search either indexOf (if dir is true) or lastIndexOf
  3305. if (Buffer.isBuffer(val)) {
  3306. // Special case: looking for empty string/buffer always fails
  3307. if (val.length === 0) {
  3308. return -1
  3309. }
  3310. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  3311. } else if (typeof val === 'number') {
  3312. val = val & 0xFF // Search for a byte value [0-255]
  3313. if (Buffer.TYPED_ARRAY_SUPPORT &&
  3314. typeof Uint8Array.prototype.indexOf === 'function') {
  3315. if (dir) {
  3316. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  3317. } else {
  3318. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  3319. }
  3320. }
  3321. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  3322. }
  3323. throw new TypeError('val must be string, number or Buffer')
  3324. }
  3325. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  3326. var indexSize = 1
  3327. var arrLength = arr.length
  3328. var valLength = val.length
  3329. if (encoding !== undefined) {
  3330. encoding = String(encoding).toLowerCase()
  3331. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  3332. encoding === 'utf16le' || encoding === 'utf-16le') {
  3333. if (arr.length < 2 || val.length < 2) {
  3334. return -1
  3335. }
  3336. indexSize = 2
  3337. arrLength /= 2
  3338. valLength /= 2
  3339. byteOffset /= 2
  3340. }
  3341. }
  3342. function read (buf, i) {
  3343. if (indexSize === 1) {
  3344. return buf[i]
  3345. } else {
  3346. return buf.readUInt16BE(i * indexSize)
  3347. }
  3348. }
  3349. var i
  3350. if (dir) {
  3351. var foundIndex = -1
  3352. for (i = byteOffset; i < arrLength; i++) {
  3353. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  3354. if (foundIndex === -1) foundIndex = i
  3355. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  3356. } else {
  3357. if (foundIndex !== -1) i -= i - foundIndex
  3358. foundIndex = -1
  3359. }
  3360. }
  3361. } else {
  3362. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  3363. for (i = byteOffset; i >= 0; i--) {
  3364. var found = true
  3365. for (var j = 0; j < valLength; j++) {
  3366. if (read(arr, i + j) !== read(val, j)) {
  3367. found = false
  3368. break
  3369. }
  3370. }
  3371. if (found) return i
  3372. }
  3373. }
  3374. return -1
  3375. }
  3376. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  3377. return this.indexOf(val, byteOffset, encoding) !== -1
  3378. }
  3379. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  3380. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  3381. }
  3382. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  3383. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  3384. }
  3385. function hexWrite (buf, string, offset, length) {
  3386. offset = Number(offset) || 0
  3387. var remaining = buf.length - offset
  3388. if (!length) {
  3389. length = remaining
  3390. } else {
  3391. length = Number(length)
  3392. if (length > remaining) {
  3393. length = remaining
  3394. }
  3395. }
  3396. // must be an even number of digits
  3397. var strLen = string.length
  3398. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  3399. if (length > strLen / 2) {
  3400. length = strLen / 2
  3401. }
  3402. for (var i = 0; i < length; ++i) {
  3403. var parsed = parseInt(string.substr(i * 2, 2), 16)
  3404. if (isNaN(parsed)) return i
  3405. buf[offset + i] = parsed
  3406. }
  3407. return i
  3408. }
  3409. function utf8Write (buf, string, offset, length) {
  3410. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  3411. }
  3412. function asciiWrite (buf, string, offset, length) {
  3413. return blitBuffer(asciiToBytes(string), buf, offset, length)
  3414. }
  3415. function latin1Write (buf, string, offset, length) {
  3416. return asciiWrite(buf, string, offset, length)
  3417. }
  3418. function base64Write (buf, string, offset, length) {
  3419. return blitBuffer(base64ToBytes(string), buf, offset, length)
  3420. }
  3421. function ucs2Write (buf, string, offset, length) {
  3422. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  3423. }
  3424. Buffer.prototype.write = function write (string, offset, length, encoding) {
  3425. // Buffer#write(string)
  3426. if (offset === undefined) {
  3427. encoding = 'utf8'
  3428. length = this.length
  3429. offset = 0
  3430. // Buffer#write(string, encoding)
  3431. } else if (length === undefined && typeof offset === 'string') {
  3432. encoding = offset
  3433. length = this.length
  3434. offset = 0
  3435. // Buffer#write(string, offset[, length][, encoding])
  3436. } else if (isFinite(offset)) {
  3437. offset = offset | 0
  3438. if (isFinite(length)) {
  3439. length = length | 0
  3440. if (encoding === undefined) encoding = 'utf8'
  3441. } else {
  3442. encoding = length
  3443. length = undefined
  3444. }
  3445. // legacy write(string, encoding, offset, length) - remove in v0.13
  3446. } else {
  3447. throw new Error(
  3448. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  3449. )
  3450. }
  3451. var remaining = this.length - offset
  3452. if (length === undefined || length > remaining) length = remaining
  3453. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  3454. throw new RangeError('Attempt to write outside buffer bounds')
  3455. }
  3456. if (!encoding) encoding = 'utf8'
  3457. var loweredCase = false
  3458. for (;;) {
  3459. switch (encoding) {
  3460. case 'hex':
  3461. return hexWrite(this, string, offset, length)
  3462. case 'utf8':
  3463. case 'utf-8':
  3464. return utf8Write(this, string, offset, length)
  3465. case 'ascii':
  3466. return asciiWrite(this, string, offset, length)
  3467. case 'latin1':
  3468. case 'binary':
  3469. return latin1Write(this, string, offset, length)
  3470. case 'base64':
  3471. // Warning: maxLength not taken into account in base64Write
  3472. return base64Write(this, string, offset, length)
  3473. case 'ucs2':
  3474. case 'ucs-2':
  3475. case 'utf16le':
  3476. case 'utf-16le':
  3477. return ucs2Write(this, string, offset, length)
  3478. default:
  3479. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3480. encoding = ('' + encoding).toLowerCase()
  3481. loweredCase = true
  3482. }
  3483. }
  3484. }
  3485. Buffer.prototype.toJSON = function toJSON () {
  3486. return {
  3487. type: 'Buffer',
  3488. data: Array.prototype.slice.call(this._arr || this, 0)
  3489. }
  3490. }
  3491. function base64Slice (buf, start, end) {
  3492. if (start === 0 && end === buf.length) {
  3493. return base64.fromByteArray(buf)
  3494. } else {
  3495. return base64.fromByteArray(buf.slice(start, end))
  3496. }
  3497. }
  3498. function utf8Slice (buf, start, end) {
  3499. end = Math.min(buf.length, end)
  3500. var res = []
  3501. var i = start
  3502. while (i < end) {
  3503. var firstByte = buf[i]
  3504. var codePoint = null
  3505. var bytesPerSequence = (firstByte > 0xEF) ? 4
  3506. : (firstByte > 0xDF) ? 3
  3507. : (firstByte > 0xBF) ? 2
  3508. : 1
  3509. if (i + bytesPerSequence <= end) {
  3510. var secondByte, thirdByte, fourthByte, tempCodePoint
  3511. switch (bytesPerSequence) {
  3512. case 1:
  3513. if (firstByte < 0x80) {
  3514. codePoint = firstByte
  3515. }
  3516. break
  3517. case 2:
  3518. secondByte = buf[i + 1]
  3519. if ((secondByte & 0xC0) === 0x80) {
  3520. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  3521. if (tempCodePoint > 0x7F) {
  3522. codePoint = tempCodePoint
  3523. }
  3524. }
  3525. break
  3526. case 3:
  3527. secondByte = buf[i + 1]
  3528. thirdByte = buf[i + 2]
  3529. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  3530. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  3531. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  3532. codePoint = tempCodePoint
  3533. }
  3534. }
  3535. break
  3536. case 4:
  3537. secondByte = buf[i + 1]
  3538. thirdByte = buf[i + 2]
  3539. fourthByte = buf[i + 3]
  3540. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  3541. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  3542. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  3543. codePoint = tempCodePoint
  3544. }
  3545. }
  3546. }
  3547. }
  3548. if (codePoint === null) {
  3549. // we did not generate a valid codePoint so insert a
  3550. // replacement char (U+FFFD) and advance only 1 byte
  3551. codePoint = 0xFFFD
  3552. bytesPerSequence = 1
  3553. } else if (codePoint > 0xFFFF) {
  3554. // encode to utf16 (surrogate pair dance)
  3555. codePoint -= 0x10000
  3556. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  3557. codePoint = 0xDC00 | codePoint & 0x3FF
  3558. }
  3559. res.push(codePoint)
  3560. i += bytesPerSequence
  3561. }
  3562. return decodeCodePointsArray(res)
  3563. }
  3564. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  3565. // the lowest limit is Chrome, with 0x10000 args.
  3566. // We go 1 magnitude less, for safety
  3567. var MAX_ARGUMENTS_LENGTH = 0x1000
  3568. function decodeCodePointsArray (codePoints) {
  3569. var len = codePoints.length
  3570. if (len <= MAX_ARGUMENTS_LENGTH) {
  3571. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  3572. }
  3573. // Decode in chunks to avoid "call stack size exceeded".
  3574. var res = ''
  3575. var i = 0
  3576. while (i < len) {
  3577. res += String.fromCharCode.apply(
  3578. String,
  3579. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  3580. )
  3581. }
  3582. return res
  3583. }
  3584. function asciiSlice (buf, start, end) {
  3585. var ret = ''
  3586. end = Math.min(buf.length, end)
  3587. for (var i = start; i < end; ++i) {
  3588. ret += String.fromCharCode(buf[i] & 0x7F)
  3589. }
  3590. return ret
  3591. }
  3592. function latin1Slice (buf, start, end) {
  3593. var ret = ''
  3594. end = Math.min(buf.length, end)
  3595. for (var i = start; i < end; ++i) {
  3596. ret += String.fromCharCode(buf[i])
  3597. }
  3598. return ret
  3599. }
  3600. function hexSlice (buf, start, end) {
  3601. var len = buf.length
  3602. if (!start || start < 0) start = 0
  3603. if (!end || end < 0 || end > len) end = len
  3604. var out = ''
  3605. for (var i = start; i < end; ++i) {
  3606. out += toHex(buf[i])
  3607. }
  3608. return out
  3609. }
  3610. function utf16leSlice (buf, start, end) {
  3611. var bytes = buf.slice(start, end)
  3612. var res = ''
  3613. for (var i = 0; i < bytes.length; i += 2) {
  3614. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  3615. }
  3616. return res
  3617. }
  3618. Buffer.prototype.slice = function slice (start, end) {
  3619. var len = this.length
  3620. start = ~~start
  3621. end = end === undefined ? len : ~~end
  3622. if (start < 0) {
  3623. start += len
  3624. if (start < 0) start = 0
  3625. } else if (start > len) {
  3626. start = len
  3627. }
  3628. if (end < 0) {
  3629. end += len
  3630. if (end < 0) end = 0
  3631. } else if (end > len) {
  3632. end = len
  3633. }
  3634. if (end < start) end = start
  3635. var newBuf
  3636. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3637. newBuf = this.subarray(start, end)
  3638. newBuf.__proto__ = Buffer.prototype
  3639. } else {
  3640. var sliceLen = end - start
  3641. newBuf = new Buffer(sliceLen, undefined)
  3642. for (var i = 0; i < sliceLen; ++i) {
  3643. newBuf[i] = this[i + start]
  3644. }
  3645. }
  3646. return newBuf
  3647. }
  3648. /*
  3649. * Need to make sure that buffer isn't trying to write out of bounds.
  3650. */
  3651. function checkOffset (offset, ext, length) {
  3652. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  3653. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  3654. }
  3655. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  3656. offset = offset | 0
  3657. byteLength = byteLength | 0
  3658. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3659. var val = this[offset]
  3660. var mul = 1
  3661. var i = 0
  3662. while (++i < byteLength && (mul *= 0x100)) {
  3663. val += this[offset + i] * mul
  3664. }
  3665. return val
  3666. }
  3667. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  3668. offset = offset | 0
  3669. byteLength = byteLength | 0
  3670. if (!noAssert) {
  3671. checkOffset(offset, byteLength, this.length)
  3672. }
  3673. var val = this[offset + --byteLength]
  3674. var mul = 1
  3675. while (byteLength > 0 && (mul *= 0x100)) {
  3676. val += this[offset + --byteLength] * mul
  3677. }
  3678. return val
  3679. }
  3680. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  3681. if (!noAssert) checkOffset(offset, 1, this.length)
  3682. return this[offset]
  3683. }
  3684. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  3685. if (!noAssert) checkOffset(offset, 2, this.length)
  3686. return this[offset] | (this[offset + 1] << 8)
  3687. }
  3688. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  3689. if (!noAssert) checkOffset(offset, 2, this.length)
  3690. return (this[offset] << 8) | this[offset + 1]
  3691. }
  3692. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  3693. if (!noAssert) checkOffset(offset, 4, this.length)
  3694. return ((this[offset]) |
  3695. (this[offset + 1] << 8) |
  3696. (this[offset + 2] << 16)) +
  3697. (this[offset + 3] * 0x1000000)
  3698. }
  3699. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  3700. if (!noAssert) checkOffset(offset, 4, this.length)
  3701. return (this[offset] * 0x1000000) +
  3702. ((this[offset + 1] << 16) |
  3703. (this[offset + 2] << 8) |
  3704. this[offset + 3])
  3705. }
  3706. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  3707. offset = offset | 0
  3708. byteLength = byteLength | 0
  3709. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3710. var val = this[offset]
  3711. var mul = 1
  3712. var i = 0
  3713. while (++i < byteLength && (mul *= 0x100)) {
  3714. val += this[offset + i] * mul
  3715. }
  3716. mul *= 0x80
  3717. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3718. return val
  3719. }
  3720. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  3721. offset = offset | 0
  3722. byteLength = byteLength | 0
  3723. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3724. var i = byteLength
  3725. var mul = 1
  3726. var val = this[offset + --i]
  3727. while (i > 0 && (mul *= 0x100)) {
  3728. val += this[offset + --i] * mul
  3729. }
  3730. mul *= 0x80
  3731. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3732. return val
  3733. }
  3734. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  3735. if (!noAssert) checkOffset(offset, 1, this.length)
  3736. if (!(this[offset] & 0x80)) return (this[offset])
  3737. return ((0xff - this[offset] + 1) * -1)
  3738. }
  3739. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  3740. if (!noAssert) checkOffset(offset, 2, this.length)
  3741. var val = this[offset] | (this[offset + 1] << 8)
  3742. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3743. }
  3744. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  3745. if (!noAssert) checkOffset(offset, 2, this.length)
  3746. var val = this[offset + 1] | (this[offset] << 8)
  3747. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3748. }
  3749. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  3750. if (!noAssert) checkOffset(offset, 4, this.length)
  3751. return (this[offset]) |
  3752. (this[offset + 1] << 8) |
  3753. (this[offset + 2] << 16) |
  3754. (this[offset + 3] << 24)
  3755. }
  3756. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  3757. if (!noAssert) checkOffset(offset, 4, this.length)
  3758. return (this[offset] << 24) |
  3759. (this[offset + 1] << 16) |
  3760. (this[offset + 2] << 8) |
  3761. (this[offset + 3])
  3762. }
  3763. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  3764. if (!noAssert) checkOffset(offset, 4, this.length)
  3765. return ieee754.read(this, offset, true, 23, 4)
  3766. }
  3767. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  3768. if (!noAssert) checkOffset(offset, 4, this.length)
  3769. return ieee754.read(this, offset, false, 23, 4)
  3770. }
  3771. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  3772. if (!noAssert) checkOffset(offset, 8, this.length)
  3773. return ieee754.read(this, offset, true, 52, 8)
  3774. }
  3775. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  3776. if (!noAssert) checkOffset(offset, 8, this.length)
  3777. return ieee754.read(this, offset, false, 52, 8)
  3778. }
  3779. function checkInt (buf, value, offset, ext, max, min) {
  3780. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  3781. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  3782. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  3783. }
  3784. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  3785. value = +value
  3786. offset = offset | 0
  3787. byteLength = byteLength | 0
  3788. if (!noAssert) {
  3789. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  3790. checkInt(this, value, offset, byteLength, maxBytes, 0)
  3791. }
  3792. var mul = 1
  3793. var i = 0
  3794. this[offset] = value & 0xFF
  3795. while (++i < byteLength && (mul *= 0x100)) {
  3796. this[offset + i] = (value / mul) & 0xFF
  3797. }
  3798. return offset + byteLength
  3799. }
  3800. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  3801. value = +value
  3802. offset = offset | 0
  3803. byteLength = byteLength | 0
  3804. if (!noAssert) {
  3805. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  3806. checkInt(this, value, offset, byteLength, maxBytes, 0)
  3807. }
  3808. var i = byteLength - 1
  3809. var mul = 1
  3810. this[offset + i] = value & 0xFF
  3811. while (--i >= 0 && (mul *= 0x100)) {
  3812. this[offset + i] = (value / mul) & 0xFF
  3813. }
  3814. return offset + byteLength
  3815. }
  3816. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  3817. value = +value
  3818. offset = offset | 0
  3819. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  3820. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  3821. this[offset] = (value & 0xff)
  3822. return offset + 1
  3823. }
  3824. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  3825. if (value < 0) value = 0xffff + value + 1
  3826. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  3827. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  3828. (littleEndian ? i : 1 - i) * 8
  3829. }
  3830. }
  3831. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  3832. value = +value
  3833. offset = offset | 0
  3834. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  3835. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3836. this[offset] = (value & 0xff)
  3837. this[offset + 1] = (value >>> 8)
  3838. } else {
  3839. objectWriteUInt16(this, value, offset, true)
  3840. }
  3841. return offset + 2
  3842. }
  3843. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  3844. value = +value
  3845. offset = offset | 0
  3846. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  3847. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3848. this[offset] = (value >>> 8)
  3849. this[offset + 1] = (value & 0xff)
  3850. } else {
  3851. objectWriteUInt16(this, value, offset, false)
  3852. }
  3853. return offset + 2
  3854. }
  3855. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  3856. if (value < 0) value = 0xffffffff + value + 1
  3857. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  3858. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  3859. }
  3860. }
  3861. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  3862. value = +value
  3863. offset = offset | 0
  3864. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  3865. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3866. this[offset + 3] = (value >>> 24)
  3867. this[offset + 2] = (value >>> 16)
  3868. this[offset + 1] = (value >>> 8)
  3869. this[offset] = (value & 0xff)
  3870. } else {
  3871. objectWriteUInt32(this, value, offset, true)
  3872. }
  3873. return offset + 4
  3874. }
  3875. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  3876. value = +value
  3877. offset = offset | 0
  3878. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  3879. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3880. this[offset] = (value >>> 24)
  3881. this[offset + 1] = (value >>> 16)
  3882. this[offset + 2] = (value >>> 8)
  3883. this[offset + 3] = (value & 0xff)
  3884. } else {
  3885. objectWriteUInt32(this, value, offset, false)
  3886. }
  3887. return offset + 4
  3888. }
  3889. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  3890. value = +value
  3891. offset = offset | 0
  3892. if (!noAssert) {
  3893. var limit = Math.pow(2, 8 * byteLength - 1)
  3894. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  3895. }
  3896. var i = 0
  3897. var mul = 1
  3898. var sub = 0
  3899. this[offset] = value & 0xFF
  3900. while (++i < byteLength && (mul *= 0x100)) {
  3901. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  3902. sub = 1
  3903. }
  3904. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  3905. }
  3906. return offset + byteLength
  3907. }
  3908. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  3909. value = +value
  3910. offset = offset | 0
  3911. if (!noAssert) {
  3912. var limit = Math.pow(2, 8 * byteLength - 1)
  3913. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  3914. }
  3915. var i = byteLength - 1
  3916. var mul = 1
  3917. var sub = 0
  3918. this[offset + i] = value & 0xFF
  3919. while (--i >= 0 && (mul *= 0x100)) {
  3920. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  3921. sub = 1
  3922. }
  3923. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  3924. }
  3925. return offset + byteLength
  3926. }
  3927. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  3928. value = +value
  3929. offset = offset | 0
  3930. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  3931. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  3932. if (value < 0) value = 0xff + value + 1
  3933. this[offset] = (value & 0xff)
  3934. return offset + 1
  3935. }
  3936. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  3937. value = +value
  3938. offset = offset | 0
  3939. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  3940. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3941. this[offset] = (value & 0xff)
  3942. this[offset + 1] = (value >>> 8)
  3943. } else {
  3944. objectWriteUInt16(this, value, offset, true)
  3945. }
  3946. return offset + 2
  3947. }
  3948. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  3949. value = +value
  3950. offset = offset | 0
  3951. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  3952. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3953. this[offset] = (value >>> 8)
  3954. this[offset + 1] = (value & 0xff)
  3955. } else {
  3956. objectWriteUInt16(this, value, offset, false)
  3957. }
  3958. return offset + 2
  3959. }
  3960. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  3961. value = +value
  3962. offset = offset | 0
  3963. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  3964. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3965. this[offset] = (value & 0xff)
  3966. this[offset + 1] = (value >>> 8)
  3967. this[offset + 2] = (value >>> 16)
  3968. this[offset + 3] = (value >>> 24)
  3969. } else {
  3970. objectWriteUInt32(this, value, offset, true)
  3971. }
  3972. return offset + 4
  3973. }
  3974. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  3975. value = +value
  3976. offset = offset | 0
  3977. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  3978. if (value < 0) value = 0xffffffff + value + 1
  3979. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3980. this[offset] = (value >>> 24)
  3981. this[offset + 1] = (value >>> 16)
  3982. this[offset + 2] = (value >>> 8)
  3983. this[offset + 3] = (value & 0xff)
  3984. } else {
  3985. objectWriteUInt32(this, value, offset, false)
  3986. }
  3987. return offset + 4
  3988. }
  3989. function checkIEEE754 (buf, value, offset, ext, max, min) {
  3990. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  3991. if (offset < 0) throw new RangeError('Index out of range')
  3992. }
  3993. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  3994. if (!noAssert) {
  3995. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  3996. }
  3997. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  3998. return offset + 4
  3999. }
  4000. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  4001. return writeFloat(this, value, offset, true, noAssert)
  4002. }
  4003. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  4004. return writeFloat(this, value, offset, false, noAssert)
  4005. }
  4006. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  4007. if (!noAssert) {
  4008. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  4009. }
  4010. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  4011. return offset + 8
  4012. }
  4013. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  4014. return writeDouble(this, value, offset, true, noAssert)
  4015. }
  4016. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  4017. return writeDouble(this, value, offset, false, noAssert)
  4018. }
  4019. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  4020. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  4021. if (!start) start = 0
  4022. if (!end && end !== 0) end = this.length
  4023. if (targetStart >= target.length) targetStart = target.length
  4024. if (!targetStart) targetStart = 0
  4025. if (end > 0 && end < start) end = start
  4026. // Copy 0 bytes; we're done
  4027. if (end === start) return 0
  4028. if (target.length === 0 || this.length === 0) return 0
  4029. // Fatal error conditions
  4030. if (targetStart < 0) {
  4031. throw new RangeError('targetStart out of bounds')
  4032. }
  4033. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  4034. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  4035. // Are we oob?
  4036. if (end > this.length) end = this.length
  4037. if (target.length - targetStart < end - start) {
  4038. end = target.length - targetStart + start
  4039. }
  4040. var len = end - start
  4041. var i
  4042. if (this === target && start < targetStart && targetStart < end) {
  4043. // descending copy from end
  4044. for (i = len - 1; i >= 0; --i) {
  4045. target[i + targetStart] = this[i + start]
  4046. }
  4047. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  4048. // ascending copy from start
  4049. for (i = 0; i < len; ++i) {
  4050. target[i + targetStart] = this[i + start]
  4051. }
  4052. } else {
  4053. Uint8Array.prototype.set.call(
  4054. target,
  4055. this.subarray(start, start + len),
  4056. targetStart
  4057. )
  4058. }
  4059. return len
  4060. }
  4061. // Usage:
  4062. // buffer.fill(number[, offset[, end]])
  4063. // buffer.fill(buffer[, offset[, end]])
  4064. // buffer.fill(string[, offset[, end]][, encoding])
  4065. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  4066. // Handle string cases:
  4067. if (typeof val === 'string') {
  4068. if (typeof start === 'string') {
  4069. encoding = start
  4070. start = 0
  4071. end = this.length
  4072. } else if (typeof end === 'string') {
  4073. encoding = end
  4074. end = this.length
  4075. }
  4076. if (val.length === 1) {
  4077. var code = val.charCodeAt(0)
  4078. if (code < 256) {
  4079. val = code
  4080. }
  4081. }
  4082. if (encoding !== undefined && typeof encoding !== 'string') {
  4083. throw new TypeError('encoding must be a string')
  4084. }
  4085. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  4086. throw new TypeError('Unknown encoding: ' + encoding)
  4087. }
  4088. } else if (typeof val === 'number') {
  4089. val = val & 255
  4090. }
  4091. // Invalid ranges are not set to a default, so can range check early.
  4092. if (start < 0 || this.length < start || this.length < end) {
  4093. throw new RangeError('Out of range index')
  4094. }
  4095. if (end <= start) {
  4096. return this
  4097. }
  4098. start = start >>> 0
  4099. end = end === undefined ? this.length : end >>> 0
  4100. if (!val) val = 0
  4101. var i
  4102. if (typeof val === 'number') {
  4103. for (i = start; i < end; ++i) {
  4104. this[i] = val
  4105. }
  4106. } else {
  4107. var bytes = Buffer.isBuffer(val)
  4108. ? val
  4109. : utf8ToBytes(new Buffer(val, encoding).toString())
  4110. var len = bytes.length
  4111. for (i = 0; i < end - start; ++i) {
  4112. this[i + start] = bytes[i % len]
  4113. }
  4114. }
  4115. return this
  4116. }
  4117. // HELPER FUNCTIONS
  4118. // ================
  4119. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  4120. function base64clean (str) {
  4121. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  4122. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  4123. // Node converts strings with length < 2 to ''
  4124. if (str.length < 2) return ''
  4125. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  4126. while (str.length % 4 !== 0) {
  4127. str = str + '='
  4128. }
  4129. return str
  4130. }
  4131. function stringtrim (str) {
  4132. if (str.trim) return str.trim()
  4133. return str.replace(/^\s+|\s+$/g, '')
  4134. }
  4135. function toHex (n) {
  4136. if (n < 16) return '0' + n.toString(16)
  4137. return n.toString(16)
  4138. }
  4139. function utf8ToBytes (string, units) {
  4140. units = units || Infinity
  4141. var codePoint
  4142. var length = string.length
  4143. var leadSurrogate = null
  4144. var bytes = []
  4145. for (var i = 0; i < length; ++i) {
  4146. codePoint = string.charCodeAt(i)
  4147. // is surrogate component
  4148. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  4149. // last char was a lead
  4150. if (!leadSurrogate) {
  4151. // no lead yet
  4152. if (codePoint > 0xDBFF) {
  4153. // unexpected trail
  4154. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4155. continue
  4156. } else if (i + 1 === length) {
  4157. // unpaired lead
  4158. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4159. continue
  4160. }
  4161. // valid lead
  4162. leadSurrogate = codePoint
  4163. continue
  4164. }
  4165. // 2 leads in a row
  4166. if (codePoint < 0xDC00) {
  4167. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4168. leadSurrogate = codePoint
  4169. continue
  4170. }
  4171. // valid surrogate pair
  4172. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  4173. } else if (leadSurrogate) {
  4174. // valid bmp char, but last char was a lead
  4175. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4176. }
  4177. leadSurrogate = null
  4178. // encode utf8
  4179. if (codePoint < 0x80) {
  4180. if ((units -= 1) < 0) break
  4181. bytes.push(codePoint)
  4182. } else if (codePoint < 0x800) {
  4183. if ((units -= 2) < 0) break
  4184. bytes.push(
  4185. codePoint >> 0x6 | 0xC0,
  4186. codePoint & 0x3F | 0x80
  4187. )
  4188. } else if (codePoint < 0x10000) {
  4189. if ((units -= 3) < 0) break
  4190. bytes.push(
  4191. codePoint >> 0xC | 0xE0,
  4192. codePoint >> 0x6 & 0x3F | 0x80,
  4193. codePoint & 0x3F | 0x80
  4194. )
  4195. } else if (codePoint < 0x110000) {
  4196. if ((units -= 4) < 0) break
  4197. bytes.push(
  4198. codePoint >> 0x12 | 0xF0,
  4199. codePoint >> 0xC & 0x3F | 0x80,
  4200. codePoint >> 0x6 & 0x3F | 0x80,
  4201. codePoint & 0x3F | 0x80
  4202. )
  4203. } else {
  4204. throw new Error('Invalid code point')
  4205. }
  4206. }
  4207. return bytes
  4208. }
  4209. function asciiToBytes (str) {
  4210. var byteArray = []
  4211. for (var i = 0; i < str.length; ++i) {
  4212. // Node's code seems to be doing this and not & 0x7F..
  4213. byteArray.push(str.charCodeAt(i) & 0xFF)
  4214. }
  4215. return byteArray
  4216. }
  4217. function utf16leToBytes (str, units) {
  4218. var c, hi, lo
  4219. var byteArray = []
  4220. for (var i = 0; i < str.length; ++i) {
  4221. if ((units -= 2) < 0) break
  4222. c = str.charCodeAt(i)
  4223. hi = c >> 8
  4224. lo = c % 256
  4225. byteArray.push(lo)
  4226. byteArray.push(hi)
  4227. }
  4228. return byteArray
  4229. }
  4230. function base64ToBytes (str) {
  4231. return base64.toByteArray(base64clean(str))
  4232. }
  4233. function blitBuffer (src, dst, offset, length) {
  4234. for (var i = 0; i < length; ++i) {
  4235. if ((i + offset >= dst.length) || (i >= src.length)) break
  4236. dst[i + offset] = src[i]
  4237. }
  4238. return i
  4239. }
  4240. function isnan (val) {
  4241. return val !== val // eslint-disable-line no-self-compare
  4242. }
  4243. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  4244. },{"base64-js":28,"ieee754":148,"isarray":32}],32:[function(require,module,exports){
  4245. var toString = {}.toString;
  4246. module.exports = Array.isArray || function (arr) {
  4247. return toString.call(arr) == '[object Array]';
  4248. };
  4249. },{}],33:[function(require,module,exports){
  4250. module.exports = {
  4251. "100": "Continue",
  4252. "101": "Switching Protocols",
  4253. "102": "Processing",
  4254. "200": "OK",
  4255. "201": "Created",
  4256. "202": "Accepted",
  4257. "203": "Non-Authoritative Information",
  4258. "204": "No Content",
  4259. "205": "Reset Content",
  4260. "206": "Partial Content",
  4261. "207": "Multi-Status",
  4262. "208": "Already Reported",
  4263. "226": "IM Used",
  4264. "300": "Multiple Choices",
  4265. "301": "Moved Permanently",
  4266. "302": "Found",
  4267. "303": "See Other",
  4268. "304": "Not Modified",
  4269. "305": "Use Proxy",
  4270. "307": "Temporary Redirect",
  4271. "308": "Permanent Redirect",
  4272. "400": "Bad Request",
  4273. "401": "Unauthorized",
  4274. "402": "Payment Required",
  4275. "403": "Forbidden",
  4276. "404": "Not Found",
  4277. "405": "Method Not Allowed",
  4278. "406": "Not Acceptable",
  4279. "407": "Proxy Authentication Required",
  4280. "408": "Request Timeout",
  4281. "409": "Conflict",
  4282. "410": "Gone",
  4283. "411": "Length Required",
  4284. "412": "Precondition Failed",
  4285. "413": "Payload Too Large",
  4286. "414": "URI Too Long",
  4287. "415": "Unsupported Media Type",
  4288. "416": "Range Not Satisfiable",
  4289. "417": "Expectation Failed",
  4290. "418": "I'm a teapot",
  4291. "421": "Misdirected Request",
  4292. "422": "Unprocessable Entity",
  4293. "423": "Locked",
  4294. "424": "Failed Dependency",
  4295. "425": "Unordered Collection",
  4296. "426": "Upgrade Required",
  4297. "428": "Precondition Required",
  4298. "429": "Too Many Requests",
  4299. "431": "Request Header Fields Too Large",
  4300. "451": "Unavailable For Legal Reasons",
  4301. "500": "Internal Server Error",
  4302. "501": "Not Implemented",
  4303. "502": "Bad Gateway",
  4304. "503": "Service Unavailable",
  4305. "504": "Gateway Timeout",
  4306. "505": "HTTP Version Not Supported",
  4307. "506": "Variant Also Negotiates",
  4308. "507": "Insufficient Storage",
  4309. "508": "Loop Detected",
  4310. "509": "Bandwidth Limit Exceeded",
  4311. "510": "Not Extended",
  4312. "511": "Network Authentication Required"
  4313. }
  4314. },{}],34:[function(require,module,exports){
  4315. /*!
  4316. * co-gather - index.js
  4317. * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
  4318. * MIT Licensed
  4319. */
  4320. 'use strict';
  4321. /**
  4322. * Module dependencies.
  4323. */
  4324. var _regenerator = require('babel-runtime/regenerator');
  4325. var _regenerator2 = _interopRequireDefault(_regenerator);
  4326. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4327. var thread = require('co-thread');
  4328. module.exports = /*#__PURE__*/_regenerator2.default.mark(function gather(thunks, n) {
  4329. var _marked, ret, index, next;
  4330. return _regenerator2.default.wrap(function gather$(_context2) {
  4331. while (1) {
  4332. switch (_context2.prev = _context2.next) {
  4333. case 0:
  4334. next = function next() {
  4335. var i;
  4336. return _regenerator2.default.wrap(function next$(_context) {
  4337. while (1) {
  4338. switch (_context.prev = _context.next) {
  4339. case 0:
  4340. i = index++;
  4341. ret[i] = { isError: false };
  4342. _context.prev = 2;
  4343. _context.next = 5;
  4344. return thunks[i];
  4345. case 5:
  4346. ret[i].value = _context.sent;
  4347. _context.next = 12;
  4348. break;
  4349. case 8:
  4350. _context.prev = 8;
  4351. _context.t0 = _context['catch'](2);
  4352. ret[i].error = _context.t0;
  4353. ret[i].isError = true;
  4354. case 12:
  4355. if (!(index < thunks.length)) {
  4356. _context.next = 15;
  4357. break;
  4358. }
  4359. _context.next = 15;
  4360. return next;
  4361. case 15:
  4362. case 'end':
  4363. return _context.stop();
  4364. }
  4365. }
  4366. }, _marked, this, [[2, 8]]);
  4367. };
  4368. _marked = /*#__PURE__*/_regenerator2.default.mark(next);
  4369. n = Math.min(n || 5, thunks.length);
  4370. ret = [];
  4371. index = 0;
  4372. _context2.next = 7;
  4373. return thread(next, n);
  4374. case 7:
  4375. return _context2.abrupt('return', ret);
  4376. case 8:
  4377. case 'end':
  4378. return _context2.stop();
  4379. }
  4380. }
  4381. }, gather, this);
  4382. });
  4383. },{"babel-runtime/regenerator":27,"co-thread":35}],35:[function(require,module,exports){
  4384. /**
  4385. * Expose `thread`.
  4386. */
  4387. module.exports = thread;
  4388. /**
  4389. * Run `fn` `n` times in parallel.
  4390. *
  4391. * @param {Function} fn
  4392. * @param {Number} n
  4393. * @return {Array}
  4394. * @api public
  4395. */
  4396. function thread(fn, n) {
  4397. var gens = [];
  4398. while (n--) gens.push(fn);
  4399. return gens;
  4400. }
  4401. },{}],36:[function(require,module,exports){
  4402. /**
  4403. * slice() reference.
  4404. */
  4405. var slice = Array.prototype.slice;
  4406. /**
  4407. * Expose `co`.
  4408. */
  4409. module.exports = co['default'] = co.co = co;
  4410. /**
  4411. * Wrap the given generator `fn` into a
  4412. * function that returns a promise.
  4413. * This is a separate function so that
  4414. * every `co()` call doesn't create a new,
  4415. * unnecessary closure.
  4416. *
  4417. * @param {GeneratorFunction} fn
  4418. * @return {Function}
  4419. * @api public
  4420. */
  4421. co.wrap = function (fn) {
  4422. createPromise.__generatorFunction__ = fn;
  4423. return createPromise;
  4424. function createPromise() {
  4425. return co.call(this, fn.apply(this, arguments));
  4426. }
  4427. };
  4428. /**
  4429. * Execute the generator function or a generator
  4430. * and return a promise.
  4431. *
  4432. * @param {Function} fn
  4433. * @return {Promise}
  4434. * @api public
  4435. */
  4436. function co(gen) {
  4437. var ctx = this;
  4438. var args = slice.call(arguments, 1)
  4439. // we wrap everything in a promise to avoid promise chaining,
  4440. // which leads to memory leak errors.
  4441. // see https://github.com/tj/co/issues/180
  4442. return new Promise(function(resolve, reject) {
  4443. if (typeof gen === 'function') gen = gen.apply(ctx, args);
  4444. if (!gen || typeof gen.next !== 'function') return resolve(gen);
  4445. onFulfilled();
  4446. /**
  4447. * @param {Mixed} res
  4448. * @return {Promise}
  4449. * @api private
  4450. */
  4451. function onFulfilled(res) {
  4452. var ret;
  4453. try {
  4454. ret = gen.next(res);
  4455. } catch (e) {
  4456. return reject(e);
  4457. }
  4458. next(ret);
  4459. }
  4460. /**
  4461. * @param {Error} err
  4462. * @return {Promise}
  4463. * @api private
  4464. */
  4465. function onRejected(err) {
  4466. var ret;
  4467. try {
  4468. ret = gen.throw(err);
  4469. } catch (e) {
  4470. return reject(e);
  4471. }
  4472. next(ret);
  4473. }
  4474. /**
  4475. * Get the next value in the generator,
  4476. * return a promise.
  4477. *
  4478. * @param {Object} ret
  4479. * @return {Promise}
  4480. * @api private
  4481. */
  4482. function next(ret) {
  4483. if (ret.done) return resolve(ret.value);
  4484. var value = toPromise.call(ctx, ret.value);
  4485. if (value && isPromise(value)) return value.then(onFulfilled, onRejected);
  4486. return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, '
  4487. + 'but the following object was passed: "' + String(ret.value) + '"'));
  4488. }
  4489. });
  4490. }
  4491. /**
  4492. * Convert a `yield`ed value into a promise.
  4493. *
  4494. * @param {Mixed} obj
  4495. * @return {Promise}
  4496. * @api private
  4497. */
  4498. function toPromise(obj) {
  4499. if (!obj) return obj;
  4500. if (isPromise(obj)) return obj;
  4501. if (isGeneratorFunction(obj) || isGenerator(obj)) return co.call(this, obj);
  4502. if ('function' == typeof obj) return thunkToPromise.call(this, obj);
  4503. if (Array.isArray(obj)) return arrayToPromise.call(this, obj);
  4504. if (isObject(obj)) return objectToPromise.call(this, obj);
  4505. return obj;
  4506. }
  4507. /**
  4508. * Convert a thunk to a promise.
  4509. *
  4510. * @param {Function}
  4511. * @return {Promise}
  4512. * @api private
  4513. */
  4514. function thunkToPromise(fn) {
  4515. var ctx = this;
  4516. return new Promise(function (resolve, reject) {
  4517. fn.call(ctx, function (err, res) {
  4518. if (err) return reject(err);
  4519. if (arguments.length > 2) res = slice.call(arguments, 1);
  4520. resolve(res);
  4521. });
  4522. });
  4523. }
  4524. /**
  4525. * Convert an array of "yieldables" to a promise.
  4526. * Uses `Promise.all()` internally.
  4527. *
  4528. * @param {Array} obj
  4529. * @return {Promise}
  4530. * @api private
  4531. */
  4532. function arrayToPromise(obj) {
  4533. return Promise.all(obj.map(toPromise, this));
  4534. }
  4535. /**
  4536. * Convert an object of "yieldables" to a promise.
  4537. * Uses `Promise.all()` internally.
  4538. *
  4539. * @param {Object} obj
  4540. * @return {Promise}
  4541. * @api private
  4542. */
  4543. function objectToPromise(obj){
  4544. var results = new obj.constructor();
  4545. var keys = Object.keys(obj);
  4546. var promises = [];
  4547. for (var i = 0; i < keys.length; i++) {
  4548. var key = keys[i];
  4549. var promise = toPromise.call(this, obj[key]);
  4550. if (promise && isPromise(promise)) defer(promise, key);
  4551. else results[key] = obj[key];
  4552. }
  4553. return Promise.all(promises).then(function () {
  4554. return results;
  4555. });
  4556. function defer(promise, key) {
  4557. // predefine the key in the result
  4558. results[key] = undefined;
  4559. promises.push(promise.then(function (res) {
  4560. results[key] = res;
  4561. }));
  4562. }
  4563. }
  4564. /**
  4565. * Check if `obj` is a promise.
  4566. *
  4567. * @param {Object} obj
  4568. * @return {Boolean}
  4569. * @api private
  4570. */
  4571. function isPromise(obj) {
  4572. return 'function' == typeof obj.then;
  4573. }
  4574. /**
  4575. * Check if `obj` is a generator.
  4576. *
  4577. * @param {Mixed} obj
  4578. * @return {Boolean}
  4579. * @api private
  4580. */
  4581. function isGenerator(obj) {
  4582. return 'function' == typeof obj.next && 'function' == typeof obj.throw;
  4583. }
  4584. /**
  4585. * Check if `obj` is a generator function.
  4586. *
  4587. * @param {Mixed} obj
  4588. * @return {Boolean}
  4589. * @api private
  4590. */
  4591. function isGeneratorFunction(obj) {
  4592. var constructor = obj.constructor;
  4593. if (!constructor) return false;
  4594. if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true;
  4595. return isGenerator(constructor.prototype);
  4596. }
  4597. /**
  4598. * Check for plain object.
  4599. *
  4600. * @param {Mixed} val
  4601. * @return {Boolean}
  4602. * @api private
  4603. */
  4604. function isObject(val) {
  4605. return Object == val.constructor;
  4606. }
  4607. },{}],37:[function(require,module,exports){
  4608. module.exports={
  4609. "O_RDONLY": 0,
  4610. "O_WRONLY": 1,
  4611. "O_RDWR": 2,
  4612. "S_IFMT": 61440,
  4613. "S_IFREG": 32768,
  4614. "S_IFDIR": 16384,
  4615. "S_IFCHR": 8192,
  4616. "S_IFBLK": 24576,
  4617. "S_IFIFO": 4096,
  4618. "S_IFLNK": 40960,
  4619. "S_IFSOCK": 49152,
  4620. "O_CREAT": 512,
  4621. "O_EXCL": 2048,
  4622. "O_NOCTTY": 131072,
  4623. "O_TRUNC": 1024,
  4624. "O_APPEND": 8,
  4625. "O_DIRECTORY": 1048576,
  4626. "O_NOFOLLOW": 256,
  4627. "O_SYNC": 128,
  4628. "O_SYMLINK": 2097152,
  4629. "O_NONBLOCK": 4,
  4630. "S_IRWXU": 448,
  4631. "S_IRUSR": 256,
  4632. "S_IWUSR": 128,
  4633. "S_IXUSR": 64,
  4634. "S_IRWXG": 56,
  4635. "S_IRGRP": 32,
  4636. "S_IWGRP": 16,
  4637. "S_IXGRP": 8,
  4638. "S_IRWXO": 7,
  4639. "S_IROTH": 4,
  4640. "S_IWOTH": 2,
  4641. "S_IXOTH": 1,
  4642. "E2BIG": 7,
  4643. "EACCES": 13,
  4644. "EADDRINUSE": 48,
  4645. "EADDRNOTAVAIL": 49,
  4646. "EAFNOSUPPORT": 47,
  4647. "EAGAIN": 35,
  4648. "EALREADY": 37,
  4649. "EBADF": 9,
  4650. "EBADMSG": 94,
  4651. "EBUSY": 16,
  4652. "ECANCELED": 89,
  4653. "ECHILD": 10,
  4654. "ECONNABORTED": 53,
  4655. "ECONNREFUSED": 61,
  4656. "ECONNRESET": 54,
  4657. "EDEADLK": 11,
  4658. "EDESTADDRREQ": 39,
  4659. "EDOM": 33,
  4660. "EDQUOT": 69,
  4661. "EEXIST": 17,
  4662. "EFAULT": 14,
  4663. "EFBIG": 27,
  4664. "EHOSTUNREACH": 65,
  4665. "EIDRM": 90,
  4666. "EILSEQ": 92,
  4667. "EINPROGRESS": 36,
  4668. "EINTR": 4,
  4669. "EINVAL": 22,
  4670. "EIO": 5,
  4671. "EISCONN": 56,
  4672. "EISDIR": 21,
  4673. "ELOOP": 62,
  4674. "EMFILE": 24,
  4675. "EMLINK": 31,
  4676. "EMSGSIZE": 40,
  4677. "EMULTIHOP": 95,
  4678. "ENAMETOOLONG": 63,
  4679. "ENETDOWN": 50,
  4680. "ENETRESET": 52,
  4681. "ENETUNREACH": 51,
  4682. "ENFILE": 23,
  4683. "ENOBUFS": 55,
  4684. "ENODATA": 96,
  4685. "ENODEV": 19,
  4686. "ENOENT": 2,
  4687. "ENOEXEC": 8,
  4688. "ENOLCK": 77,
  4689. "ENOLINK": 97,
  4690. "ENOMEM": 12,
  4691. "ENOMSG": 91,
  4692. "ENOPROTOOPT": 42,
  4693. "ENOSPC": 28,
  4694. "ENOSR": 98,
  4695. "ENOSTR": 99,
  4696. "ENOSYS": 78,
  4697. "ENOTCONN": 57,
  4698. "ENOTDIR": 20,
  4699. "ENOTEMPTY": 66,
  4700. "ENOTSOCK": 38,
  4701. "ENOTSUP": 45,
  4702. "ENOTTY": 25,
  4703. "ENXIO": 6,
  4704. "EOPNOTSUPP": 102,
  4705. "EOVERFLOW": 84,
  4706. "EPERM": 1,
  4707. "EPIPE": 32,
  4708. "EPROTO": 100,
  4709. "EPROTONOSUPPORT": 43,
  4710. "EPROTOTYPE": 41,
  4711. "ERANGE": 34,
  4712. "EROFS": 30,
  4713. "ESPIPE": 29,
  4714. "ESRCH": 3,
  4715. "ESTALE": 70,
  4716. "ETIME": 101,
  4717. "ETIMEDOUT": 60,
  4718. "ETXTBSY": 26,
  4719. "EWOULDBLOCK": 35,
  4720. "EXDEV": 18,
  4721. "SIGHUP": 1,
  4722. "SIGINT": 2,
  4723. "SIGQUIT": 3,
  4724. "SIGILL": 4,
  4725. "SIGTRAP": 5,
  4726. "SIGABRT": 6,
  4727. "SIGIOT": 6,
  4728. "SIGBUS": 10,
  4729. "SIGFPE": 8,
  4730. "SIGKILL": 9,
  4731. "SIGUSR1": 30,
  4732. "SIGSEGV": 11,
  4733. "SIGUSR2": 31,
  4734. "SIGPIPE": 13,
  4735. "SIGALRM": 14,
  4736. "SIGTERM": 15,
  4737. "SIGCHLD": 20,
  4738. "SIGCONT": 19,
  4739. "SIGSTOP": 17,
  4740. "SIGTSTP": 18,
  4741. "SIGTTIN": 21,
  4742. "SIGTTOU": 22,
  4743. "SIGURG": 16,
  4744. "SIGXCPU": 24,
  4745. "SIGXFSZ": 25,
  4746. "SIGVTALRM": 26,
  4747. "SIGPROF": 27,
  4748. "SIGWINCH": 28,
  4749. "SIGIO": 23,
  4750. "SIGSYS": 12,
  4751. "SSL_OP_ALL": 2147486719,
  4752. "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
  4753. "SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
  4754. "SSL_OP_CISCO_ANYCONNECT": 32768,
  4755. "SSL_OP_COOKIE_EXCHANGE": 8192,
  4756. "SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
  4757. "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
  4758. "SSL_OP_EPHEMERAL_RSA": 0,
  4759. "SSL_OP_LEGACY_SERVER_CONNECT": 4,
  4760. "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
  4761. "SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
  4762. "SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
  4763. "SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
  4764. "SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
  4765. "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
  4766. "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
  4767. "SSL_OP_NO_COMPRESSION": 131072,
  4768. "SSL_OP_NO_QUERY_MTU": 4096,
  4769. "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
  4770. "SSL_OP_NO_SSLv2": 16777216,
  4771. "SSL_OP_NO_SSLv3": 33554432,
  4772. "SSL_OP_NO_TICKET": 16384,
  4773. "SSL_OP_NO_TLSv1": 67108864,
  4774. "SSL_OP_NO_TLSv1_1": 268435456,
  4775. "SSL_OP_NO_TLSv1_2": 134217728,
  4776. "SSL_OP_PKCS1_CHECK_1": 0,
  4777. "SSL_OP_PKCS1_CHECK_2": 0,
  4778. "SSL_OP_SINGLE_DH_USE": 1048576,
  4779. "SSL_OP_SINGLE_ECDH_USE": 524288,
  4780. "SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
  4781. "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
  4782. "SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
  4783. "SSL_OP_TLS_D5_BUG": 256,
  4784. "SSL_OP_TLS_ROLLBACK_BUG": 8388608,
  4785. "ENGINE_METHOD_DSA": 2,
  4786. "ENGINE_METHOD_DH": 4,
  4787. "ENGINE_METHOD_RAND": 8,
  4788. "ENGINE_METHOD_ECDH": 16,
  4789. "ENGINE_METHOD_ECDSA": 32,
  4790. "ENGINE_METHOD_CIPHERS": 64,
  4791. "ENGINE_METHOD_DIGESTS": 128,
  4792. "ENGINE_METHOD_STORE": 256,
  4793. "ENGINE_METHOD_PKEY_METHS": 512,
  4794. "ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
  4795. "ENGINE_METHOD_ALL": 65535,
  4796. "ENGINE_METHOD_NONE": 0,
  4797. "DH_CHECK_P_NOT_SAFE_PRIME": 2,
  4798. "DH_CHECK_P_NOT_PRIME": 1,
  4799. "DH_UNABLE_TO_CHECK_GENERATOR": 4,
  4800. "DH_NOT_SUITABLE_GENERATOR": 8,
  4801. "NPN_ENABLED": 1,
  4802. "RSA_PKCS1_PADDING": 1,
  4803. "RSA_SSLV23_PADDING": 2,
  4804. "RSA_NO_PADDING": 3,
  4805. "RSA_PKCS1_OAEP_PADDING": 4,
  4806. "RSA_X931_PADDING": 5,
  4807. "RSA_PKCS1_PSS_PADDING": 6,
  4808. "POINT_CONVERSION_COMPRESSED": 2,
  4809. "POINT_CONVERSION_UNCOMPRESSED": 4,
  4810. "POINT_CONVERSION_HYBRID": 6,
  4811. "F_OK": 0,
  4812. "R_OK": 4,
  4813. "W_OK": 2,
  4814. "X_OK": 1,
  4815. "UV_UDP_REUSEADDR": 4
  4816. }
  4817. },{}],38:[function(require,module,exports){
  4818. /*!
  4819. * copy-to - index.js
  4820. * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
  4821. * MIT Licensed
  4822. */
  4823. 'use strict';
  4824. /**
  4825. * slice() reference.
  4826. */
  4827. var slice = Array.prototype.slice;
  4828. /**
  4829. * Expose copy
  4830. *
  4831. * ```
  4832. * copy({foo: 'nar', hello: 'copy'}).to({hello: 'world'});
  4833. * copy({foo: 'nar', hello: 'copy'}).toCover({hello: 'world'});
  4834. * ```
  4835. *
  4836. * @param {Object} src
  4837. * @return {Copy}
  4838. */
  4839. module.exports = Copy;
  4840. /**
  4841. * Copy
  4842. * @param {Object} src
  4843. * @param {Boolean} withAccess
  4844. */
  4845. function Copy(src, withAccess) {
  4846. if (!(this instanceof Copy)) return new Copy(src, withAccess);
  4847. this.src = src;
  4848. this._withAccess = withAccess;
  4849. }
  4850. /**
  4851. * copy properties include getter and setter
  4852. * @param {[type]} val [description]
  4853. * @return {[type]} [description]
  4854. */
  4855. Copy.prototype.withAccess = function (w) {
  4856. this._withAccess = w !== false;
  4857. return this;
  4858. };
  4859. /**
  4860. * pick keys in src
  4861. *
  4862. * @api: public
  4863. */
  4864. Copy.prototype.pick = function(keys) {
  4865. if (!Array.isArray(keys)) {
  4866. keys = slice.call(arguments);
  4867. }
  4868. if (keys.length) {
  4869. this.keys = keys;
  4870. }
  4871. return this;
  4872. };
  4873. /**
  4874. * copy src to target,
  4875. * do not cover any property target has
  4876. * @param {Object} to
  4877. *
  4878. * @api: public
  4879. */
  4880. Copy.prototype.to = function(to) {
  4881. to = to || {};
  4882. if (!this.src) return to;
  4883. var keys = this.keys || Object.keys(this.src);
  4884. if (!this._withAccess) {
  4885. for (var i = 0; i < keys.length; i++) {
  4886. key = keys[i];
  4887. if (to[key] !== undefined) continue;
  4888. to[key] = this.src[key];
  4889. }
  4890. return to;
  4891. }
  4892. for (var i = 0; i < keys.length; i++) {
  4893. var key = keys[i];
  4894. if (!notDefined(to, key)) continue;
  4895. var getter = this.src.__lookupGetter__(key);
  4896. var setter = this.src.__lookupSetter__(key);
  4897. if (getter) to.__defineGetter__(key, getter);
  4898. if (setter) to.__defineSetter__(key, setter);
  4899. if (!getter && !setter) {
  4900. to[key] = this.src[key];
  4901. }
  4902. }
  4903. return to;
  4904. };
  4905. /**
  4906. * copy src to target,
  4907. * override any property target has
  4908. * @param {Object} to
  4909. *
  4910. * @api: public
  4911. */
  4912. Copy.prototype.toCover = function(to) {
  4913. var keys = this.keys || Object.keys(this.src);
  4914. for (var i = 0; i < keys.length; i++) {
  4915. var key = keys[i];
  4916. delete to[key];
  4917. var getter = this.src.__lookupGetter__(key);
  4918. var setter = this.src.__lookupSetter__(key);
  4919. if (getter) to.__defineGetter__(key, getter);
  4920. if (setter) to.__defineSetter__(key, setter);
  4921. if (!getter && !setter) {
  4922. to[key] = this.src[key];
  4923. }
  4924. }
  4925. };
  4926. Copy.prototype.override = Copy.prototype.toCover;
  4927. /**
  4928. * append another object to src
  4929. * @param {Obj} obj
  4930. * @return {Copy}
  4931. */
  4932. Copy.prototype.and = function (obj) {
  4933. var src = {};
  4934. this.to(src);
  4935. this.src = obj;
  4936. this.to(src);
  4937. this.src = src;
  4938. return this;
  4939. };
  4940. /**
  4941. * check obj[key] if not defiend
  4942. * @param {Object} obj
  4943. * @param {String} key
  4944. * @return {Boolean}
  4945. */
  4946. function notDefined(obj, key) {
  4947. return obj[key] === undefined
  4948. && obj.__lookupGetter__(key) === undefined
  4949. && obj.__lookupSetter__(key) === undefined;
  4950. }
  4951. },{}],39:[function(require,module,exports){
  4952. require('../../modules/es6.string.iterator');
  4953. require('../../modules/es6.array.from');
  4954. module.exports = require('../../modules/_core').Array.from;
  4955. },{"../../modules/_core":58,"../../modules/es6.array.from":117,"../../modules/es6.string.iterator":128}],40:[function(require,module,exports){
  4956. var core = require('../../modules/_core');
  4957. var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
  4958. module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
  4959. return $JSON.stringify.apply($JSON, arguments);
  4960. };
  4961. },{"../../modules/_core":58}],41:[function(require,module,exports){
  4962. require('../../modules/es6.object.assign');
  4963. module.exports = require('../../modules/_core').Object.assign;
  4964. },{"../../modules/_core":58,"../../modules/es6.object.assign":120}],42:[function(require,module,exports){
  4965. require('../../modules/es6.object.create');
  4966. var $Object = require('../../modules/_core').Object;
  4967. module.exports = function create(P, D) {
  4968. return $Object.create(P, D);
  4969. };
  4970. },{"../../modules/_core":58,"../../modules/es6.object.create":121}],43:[function(require,module,exports){
  4971. require('../../modules/es6.object.define-property');
  4972. var $Object = require('../../modules/_core').Object;
  4973. module.exports = function defineProperty(it, key, desc) {
  4974. return $Object.defineProperty(it, key, desc);
  4975. };
  4976. },{"../../modules/_core":58,"../../modules/es6.object.define-property":122}],44:[function(require,module,exports){
  4977. require('../../modules/es6.object.get-own-property-names');
  4978. var $Object = require('../../modules/_core').Object;
  4979. module.exports = function getOwnPropertyNames(it) {
  4980. return $Object.getOwnPropertyNames(it);
  4981. };
  4982. },{"../../modules/_core":58,"../../modules/es6.object.get-own-property-names":123}],45:[function(require,module,exports){
  4983. require('../../modules/es6.object.get-prototype-of');
  4984. module.exports = require('../../modules/_core').Object.getPrototypeOf;
  4985. },{"../../modules/_core":58,"../../modules/es6.object.get-prototype-of":124}],46:[function(require,module,exports){
  4986. require('../../modules/es6.object.keys');
  4987. module.exports = require('../../modules/_core').Object.keys;
  4988. },{"../../modules/_core":58,"../../modules/es6.object.keys":125}],47:[function(require,module,exports){
  4989. require('../modules/web.immediate');
  4990. module.exports = require('../modules/_core').setImmediate;
  4991. },{"../modules/_core":58,"../modules/web.immediate":133}],48:[function(require,module,exports){
  4992. require('../../modules/es6.string.from-code-point');
  4993. module.exports = require('../../modules/_core').String.fromCodePoint;
  4994. },{"../../modules/_core":58,"../../modules/es6.string.from-code-point":127}],49:[function(require,module,exports){
  4995. require('../../modules/es6.function.has-instance');
  4996. module.exports = require('../../modules/_wks-ext').f('hasInstance');
  4997. },{"../../modules/_wks-ext":114,"../../modules/es6.function.has-instance":119}],50:[function(require,module,exports){
  4998. require('../../modules/es6.symbol');
  4999. require('../../modules/es6.object.to-string');
  5000. require('../../modules/es7.symbol.async-iterator');
  5001. require('../../modules/es7.symbol.observable');
  5002. module.exports = require('../../modules/_core').Symbol;
  5003. },{"../../modules/_core":58,"../../modules/es6.object.to-string":126,"../../modules/es6.symbol":129,"../../modules/es7.symbol.async-iterator":130,"../../modules/es7.symbol.observable":131}],51:[function(require,module,exports){
  5004. require('../../modules/es6.string.iterator');
  5005. require('../../modules/web.dom.iterable');
  5006. module.exports = require('../../modules/_wks-ext').f('iterator');
  5007. },{"../../modules/_wks-ext":114,"../../modules/es6.string.iterator":128,"../../modules/web.dom.iterable":132}],52:[function(require,module,exports){
  5008. module.exports = function (it) {
  5009. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  5010. return it;
  5011. };
  5012. },{}],53:[function(require,module,exports){
  5013. module.exports = function () { /* empty */ };
  5014. },{}],54:[function(require,module,exports){
  5015. var isObject = require('./_is-object');
  5016. module.exports = function (it) {
  5017. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  5018. return it;
  5019. };
  5020. },{"./_is-object":77}],55:[function(require,module,exports){
  5021. // false -> Array#indexOf
  5022. // true -> Array#includes
  5023. var toIObject = require('./_to-iobject');
  5024. var toLength = require('./_to-length');
  5025. var toAbsoluteIndex = require('./_to-absolute-index');
  5026. module.exports = function (IS_INCLUDES) {
  5027. return function ($this, el, fromIndex) {
  5028. var O = toIObject($this);
  5029. var length = toLength(O.length);
  5030. var index = toAbsoluteIndex(fromIndex, length);
  5031. var value;
  5032. // Array#includes uses SameValueZero equality algorithm
  5033. // eslint-disable-next-line no-self-compare
  5034. if (IS_INCLUDES && el != el) while (length > index) {
  5035. value = O[index++];
  5036. // eslint-disable-next-line no-self-compare
  5037. if (value != value) return true;
  5038. // Array#indexOf ignores holes, Array#includes - not
  5039. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  5040. if (O[index] === el) return IS_INCLUDES || index || 0;
  5041. } return !IS_INCLUDES && -1;
  5042. };
  5043. };
  5044. },{"./_to-absolute-index":106,"./_to-iobject":108,"./_to-length":109}],56:[function(require,module,exports){
  5045. // getting tag from 19.1.3.6 Object.prototype.toString()
  5046. var cof = require('./_cof');
  5047. var TAG = require('./_wks')('toStringTag');
  5048. // ES3 wrong here
  5049. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  5050. // fallback for IE11 Script Access Denied error
  5051. var tryGet = function (it, key) {
  5052. try {
  5053. return it[key];
  5054. } catch (e) { /* empty */ }
  5055. };
  5056. module.exports = function (it) {
  5057. var O, T, B;
  5058. return it === undefined ? 'Undefined' : it === null ? 'Null'
  5059. // @@toStringTag case
  5060. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  5061. // builtinTag case
  5062. : ARG ? cof(O)
  5063. // ES3 arguments fallback
  5064. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  5065. };
  5066. },{"./_cof":57,"./_wks":115}],57:[function(require,module,exports){
  5067. var toString = {}.toString;
  5068. module.exports = function (it) {
  5069. return toString.call(it).slice(8, -1);
  5070. };
  5071. },{}],58:[function(require,module,exports){
  5072. var core = module.exports = { version: '2.5.1' };
  5073. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  5074. },{}],59:[function(require,module,exports){
  5075. 'use strict';
  5076. var $defineProperty = require('./_object-dp');
  5077. var createDesc = require('./_property-desc');
  5078. module.exports = function (object, index, value) {
  5079. if (index in object) $defineProperty.f(object, index, createDesc(0, value));
  5080. else object[index] = value;
  5081. };
  5082. },{"./_object-dp":88,"./_property-desc":99}],60:[function(require,module,exports){
  5083. // optional / simple context binding
  5084. var aFunction = require('./_a-function');
  5085. module.exports = function (fn, that, length) {
  5086. aFunction(fn);
  5087. if (that === undefined) return fn;
  5088. switch (length) {
  5089. case 1: return function (a) {
  5090. return fn.call(that, a);
  5091. };
  5092. case 2: return function (a, b) {
  5093. return fn.call(that, a, b);
  5094. };
  5095. case 3: return function (a, b, c) {
  5096. return fn.call(that, a, b, c);
  5097. };
  5098. }
  5099. return function (/* ...args */) {
  5100. return fn.apply(that, arguments);
  5101. };
  5102. };
  5103. },{"./_a-function":52}],61:[function(require,module,exports){
  5104. // 7.2.1 RequireObjectCoercible(argument)
  5105. module.exports = function (it) {
  5106. if (it == undefined) throw TypeError("Can't call method on " + it);
  5107. return it;
  5108. };
  5109. },{}],62:[function(require,module,exports){
  5110. // Thank's IE8 for his funny defineProperty
  5111. module.exports = !require('./_fails')(function () {
  5112. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  5113. });
  5114. },{"./_fails":67}],63:[function(require,module,exports){
  5115. var isObject = require('./_is-object');
  5116. var document = require('./_global').document;
  5117. // typeof document.createElement is 'object' in old IE
  5118. var is = isObject(document) && isObject(document.createElement);
  5119. module.exports = function (it) {
  5120. return is ? document.createElement(it) : {};
  5121. };
  5122. },{"./_global":68,"./_is-object":77}],64:[function(require,module,exports){
  5123. // IE 8- don't enum bug keys
  5124. module.exports = (
  5125. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  5126. ).split(',');
  5127. },{}],65:[function(require,module,exports){
  5128. // all enumerable object keys, includes symbols
  5129. var getKeys = require('./_object-keys');
  5130. var gOPS = require('./_object-gops');
  5131. var pIE = require('./_object-pie');
  5132. module.exports = function (it) {
  5133. var result = getKeys(it);
  5134. var getSymbols = gOPS.f;
  5135. if (getSymbols) {
  5136. var symbols = getSymbols(it);
  5137. var isEnum = pIE.f;
  5138. var i = 0;
  5139. var key;
  5140. while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
  5141. } return result;
  5142. };
  5143. },{"./_object-gops":93,"./_object-keys":96,"./_object-pie":97}],66:[function(require,module,exports){
  5144. var global = require('./_global');
  5145. var core = require('./_core');
  5146. var ctx = require('./_ctx');
  5147. var hide = require('./_hide');
  5148. var PROTOTYPE = 'prototype';
  5149. var $export = function (type, name, source) {
  5150. var IS_FORCED = type & $export.F;
  5151. var IS_GLOBAL = type & $export.G;
  5152. var IS_STATIC = type & $export.S;
  5153. var IS_PROTO = type & $export.P;
  5154. var IS_BIND = type & $export.B;
  5155. var IS_WRAP = type & $export.W;
  5156. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  5157. var expProto = exports[PROTOTYPE];
  5158. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
  5159. var key, own, out;
  5160. if (IS_GLOBAL) source = name;
  5161. for (key in source) {
  5162. // contains in native
  5163. own = !IS_FORCED && target && target[key] !== undefined;
  5164. if (own && key in exports) continue;
  5165. // export native or passed
  5166. out = own ? target[key] : source[key];
  5167. // prevent global pollution for namespaces
  5168. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  5169. // bind timers to global for call from export context
  5170. : IS_BIND && own ? ctx(out, global)
  5171. // wrap global constructors for prevent change them in library
  5172. : IS_WRAP && target[key] == out ? (function (C) {
  5173. var F = function (a, b, c) {
  5174. if (this instanceof C) {
  5175. switch (arguments.length) {
  5176. case 0: return new C();
  5177. case 1: return new C(a);
  5178. case 2: return new C(a, b);
  5179. } return new C(a, b, c);
  5180. } return C.apply(this, arguments);
  5181. };
  5182. F[PROTOTYPE] = C[PROTOTYPE];
  5183. return F;
  5184. // make static versions for prototype methods
  5185. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  5186. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  5187. if (IS_PROTO) {
  5188. (exports.virtual || (exports.virtual = {}))[key] = out;
  5189. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  5190. if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
  5191. }
  5192. }
  5193. };
  5194. // type bitmap
  5195. $export.F = 1; // forced
  5196. $export.G = 2; // global
  5197. $export.S = 4; // static
  5198. $export.P = 8; // proto
  5199. $export.B = 16; // bind
  5200. $export.W = 32; // wrap
  5201. $export.U = 64; // safe
  5202. $export.R = 128; // real proto method for `library`
  5203. module.exports = $export;
  5204. },{"./_core":58,"./_ctx":60,"./_global":68,"./_hide":70}],67:[function(require,module,exports){
  5205. module.exports = function (exec) {
  5206. try {
  5207. return !!exec();
  5208. } catch (e) {
  5209. return true;
  5210. }
  5211. };
  5212. },{}],68:[function(require,module,exports){
  5213. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  5214. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  5215. ? window : typeof self != 'undefined' && self.Math == Math ? self
  5216. // eslint-disable-next-line no-new-func
  5217. : Function('return this')();
  5218. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  5219. },{}],69:[function(require,module,exports){
  5220. var hasOwnProperty = {}.hasOwnProperty;
  5221. module.exports = function (it, key) {
  5222. return hasOwnProperty.call(it, key);
  5223. };
  5224. },{}],70:[function(require,module,exports){
  5225. var dP = require('./_object-dp');
  5226. var createDesc = require('./_property-desc');
  5227. module.exports = require('./_descriptors') ? function (object, key, value) {
  5228. return dP.f(object, key, createDesc(1, value));
  5229. } : function (object, key, value) {
  5230. object[key] = value;
  5231. return object;
  5232. };
  5233. },{"./_descriptors":62,"./_object-dp":88,"./_property-desc":99}],71:[function(require,module,exports){
  5234. var document = require('./_global').document;
  5235. module.exports = document && document.documentElement;
  5236. },{"./_global":68}],72:[function(require,module,exports){
  5237. module.exports = !require('./_descriptors') && !require('./_fails')(function () {
  5238. return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
  5239. });
  5240. },{"./_descriptors":62,"./_dom-create":63,"./_fails":67}],73:[function(require,module,exports){
  5241. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  5242. module.exports = function (fn, args, that) {
  5243. var un = that === undefined;
  5244. switch (args.length) {
  5245. case 0: return un ? fn()
  5246. : fn.call(that);
  5247. case 1: return un ? fn(args[0])
  5248. : fn.call(that, args[0]);
  5249. case 2: return un ? fn(args[0], args[1])
  5250. : fn.call(that, args[0], args[1]);
  5251. case 3: return un ? fn(args[0], args[1], args[2])
  5252. : fn.call(that, args[0], args[1], args[2]);
  5253. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  5254. : fn.call(that, args[0], args[1], args[2], args[3]);
  5255. } return fn.apply(that, args);
  5256. };
  5257. },{}],74:[function(require,module,exports){
  5258. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  5259. var cof = require('./_cof');
  5260. // eslint-disable-next-line no-prototype-builtins
  5261. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  5262. return cof(it) == 'String' ? it.split('') : Object(it);
  5263. };
  5264. },{"./_cof":57}],75:[function(require,module,exports){
  5265. // check on default Array iterator
  5266. var Iterators = require('./_iterators');
  5267. var ITERATOR = require('./_wks')('iterator');
  5268. var ArrayProto = Array.prototype;
  5269. module.exports = function (it) {
  5270. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  5271. };
  5272. },{"./_iterators":83,"./_wks":115}],76:[function(require,module,exports){
  5273. // 7.2.2 IsArray(argument)
  5274. var cof = require('./_cof');
  5275. module.exports = Array.isArray || function isArray(arg) {
  5276. return cof(arg) == 'Array';
  5277. };
  5278. },{"./_cof":57}],77:[function(require,module,exports){
  5279. module.exports = function (it) {
  5280. return typeof it === 'object' ? it !== null : typeof it === 'function';
  5281. };
  5282. },{}],78:[function(require,module,exports){
  5283. // call something on iterator step with safe closing on error
  5284. var anObject = require('./_an-object');
  5285. module.exports = function (iterator, fn, value, entries) {
  5286. try {
  5287. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  5288. // 7.4.6 IteratorClose(iterator, completion)
  5289. } catch (e) {
  5290. var ret = iterator['return'];
  5291. if (ret !== undefined) anObject(ret.call(iterator));
  5292. throw e;
  5293. }
  5294. };
  5295. },{"./_an-object":54}],79:[function(require,module,exports){
  5296. 'use strict';
  5297. var create = require('./_object-create');
  5298. var descriptor = require('./_property-desc');
  5299. var setToStringTag = require('./_set-to-string-tag');
  5300. var IteratorPrototype = {};
  5301. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  5302. require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
  5303. module.exports = function (Constructor, NAME, next) {
  5304. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  5305. setToStringTag(Constructor, NAME + ' Iterator');
  5306. };
  5307. },{"./_hide":70,"./_object-create":87,"./_property-desc":99,"./_set-to-string-tag":101,"./_wks":115}],80:[function(require,module,exports){
  5308. 'use strict';
  5309. var LIBRARY = require('./_library');
  5310. var $export = require('./_export');
  5311. var redefine = require('./_redefine');
  5312. var hide = require('./_hide');
  5313. var has = require('./_has');
  5314. var Iterators = require('./_iterators');
  5315. var $iterCreate = require('./_iter-create');
  5316. var setToStringTag = require('./_set-to-string-tag');
  5317. var getPrototypeOf = require('./_object-gpo');
  5318. var ITERATOR = require('./_wks')('iterator');
  5319. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  5320. var FF_ITERATOR = '@@iterator';
  5321. var KEYS = 'keys';
  5322. var VALUES = 'values';
  5323. var returnThis = function () { return this; };
  5324. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  5325. $iterCreate(Constructor, NAME, next);
  5326. var getMethod = function (kind) {
  5327. if (!BUGGY && kind in proto) return proto[kind];
  5328. switch (kind) {
  5329. case KEYS: return function keys() { return new Constructor(this, kind); };
  5330. case VALUES: return function values() { return new Constructor(this, kind); };
  5331. } return function entries() { return new Constructor(this, kind); };
  5332. };
  5333. var TAG = NAME + ' Iterator';
  5334. var DEF_VALUES = DEFAULT == VALUES;
  5335. var VALUES_BUG = false;
  5336. var proto = Base.prototype;
  5337. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  5338. var $default = $native || getMethod(DEFAULT);
  5339. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  5340. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  5341. var methods, key, IteratorPrototype;
  5342. // Fix native
  5343. if ($anyNative) {
  5344. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  5345. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  5346. // Set @@toStringTag to native iterators
  5347. setToStringTag(IteratorPrototype, TAG, true);
  5348. // fix for some old engines
  5349. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  5350. }
  5351. }
  5352. // fix Array#{values, @@iterator}.name in V8 / FF
  5353. if (DEF_VALUES && $native && $native.name !== VALUES) {
  5354. VALUES_BUG = true;
  5355. $default = function values() { return $native.call(this); };
  5356. }
  5357. // Define iterator
  5358. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  5359. hide(proto, ITERATOR, $default);
  5360. }
  5361. // Plug for library
  5362. Iterators[NAME] = $default;
  5363. Iterators[TAG] = returnThis;
  5364. if (DEFAULT) {
  5365. methods = {
  5366. values: DEF_VALUES ? $default : getMethod(VALUES),
  5367. keys: IS_SET ? $default : getMethod(KEYS),
  5368. entries: $entries
  5369. };
  5370. if (FORCED) for (key in methods) {
  5371. if (!(key in proto)) redefine(proto, key, methods[key]);
  5372. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  5373. }
  5374. return methods;
  5375. };
  5376. },{"./_export":66,"./_has":69,"./_hide":70,"./_iter-create":79,"./_iterators":83,"./_library":84,"./_object-gpo":94,"./_redefine":100,"./_set-to-string-tag":101,"./_wks":115}],81:[function(require,module,exports){
  5377. var ITERATOR = require('./_wks')('iterator');
  5378. var SAFE_CLOSING = false;
  5379. try {
  5380. var riter = [7][ITERATOR]();
  5381. riter['return'] = function () { SAFE_CLOSING = true; };
  5382. // eslint-disable-next-line no-throw-literal
  5383. Array.from(riter, function () { throw 2; });
  5384. } catch (e) { /* empty */ }
  5385. module.exports = function (exec, skipClosing) {
  5386. if (!skipClosing && !SAFE_CLOSING) return false;
  5387. var safe = false;
  5388. try {
  5389. var arr = [7];
  5390. var iter = arr[ITERATOR]();
  5391. iter.next = function () { return { done: safe = true }; };
  5392. arr[ITERATOR] = function () { return iter; };
  5393. exec(arr);
  5394. } catch (e) { /* empty */ }
  5395. return safe;
  5396. };
  5397. },{"./_wks":115}],82:[function(require,module,exports){
  5398. module.exports = function (done, value) {
  5399. return { value: value, done: !!done };
  5400. };
  5401. },{}],83:[function(require,module,exports){
  5402. module.exports = {};
  5403. },{}],84:[function(require,module,exports){
  5404. module.exports = true;
  5405. },{}],85:[function(require,module,exports){
  5406. var META = require('./_uid')('meta');
  5407. var isObject = require('./_is-object');
  5408. var has = require('./_has');
  5409. var setDesc = require('./_object-dp').f;
  5410. var id = 0;
  5411. var isExtensible = Object.isExtensible || function () {
  5412. return true;
  5413. };
  5414. var FREEZE = !require('./_fails')(function () {
  5415. return isExtensible(Object.preventExtensions({}));
  5416. });
  5417. var setMeta = function (it) {
  5418. setDesc(it, META, { value: {
  5419. i: 'O' + ++id, // object ID
  5420. w: {} // weak collections IDs
  5421. } });
  5422. };
  5423. var fastKey = function (it, create) {
  5424. // return primitive with prefix
  5425. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  5426. if (!has(it, META)) {
  5427. // can't set metadata to uncaught frozen object
  5428. if (!isExtensible(it)) return 'F';
  5429. // not necessary to add metadata
  5430. if (!create) return 'E';
  5431. // add missing metadata
  5432. setMeta(it);
  5433. // return object ID
  5434. } return it[META].i;
  5435. };
  5436. var getWeak = function (it, create) {
  5437. if (!has(it, META)) {
  5438. // can't set metadata to uncaught frozen object
  5439. if (!isExtensible(it)) return true;
  5440. // not necessary to add metadata
  5441. if (!create) return false;
  5442. // add missing metadata
  5443. setMeta(it);
  5444. // return hash weak collections IDs
  5445. } return it[META].w;
  5446. };
  5447. // add metadata on freeze-family methods calling
  5448. var onFreeze = function (it) {
  5449. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  5450. return it;
  5451. };
  5452. var meta = module.exports = {
  5453. KEY: META,
  5454. NEED: false,
  5455. fastKey: fastKey,
  5456. getWeak: getWeak,
  5457. onFreeze: onFreeze
  5458. };
  5459. },{"./_fails":67,"./_has":69,"./_is-object":77,"./_object-dp":88,"./_uid":112}],86:[function(require,module,exports){
  5460. 'use strict';
  5461. // 19.1.2.1 Object.assign(target, source, ...)
  5462. var getKeys = require('./_object-keys');
  5463. var gOPS = require('./_object-gops');
  5464. var pIE = require('./_object-pie');
  5465. var toObject = require('./_to-object');
  5466. var IObject = require('./_iobject');
  5467. var $assign = Object.assign;
  5468. // should work with symbols and should have deterministic property order (V8 bug)
  5469. module.exports = !$assign || require('./_fails')(function () {
  5470. var A = {};
  5471. var B = {};
  5472. // eslint-disable-next-line no-undef
  5473. var S = Symbol();
  5474. var K = 'abcdefghijklmnopqrst';
  5475. A[S] = 7;
  5476. K.split('').forEach(function (k) { B[k] = k; });
  5477. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  5478. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  5479. var T = toObject(target);
  5480. var aLen = arguments.length;
  5481. var index = 1;
  5482. var getSymbols = gOPS.f;
  5483. var isEnum = pIE.f;
  5484. while (aLen > index) {
  5485. var S = IObject(arguments[index++]);
  5486. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  5487. var length = keys.length;
  5488. var j = 0;
  5489. var key;
  5490. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  5491. } return T;
  5492. } : $assign;
  5493. },{"./_fails":67,"./_iobject":74,"./_object-gops":93,"./_object-keys":96,"./_object-pie":97,"./_to-object":110}],87:[function(require,module,exports){
  5494. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  5495. var anObject = require('./_an-object');
  5496. var dPs = require('./_object-dps');
  5497. var enumBugKeys = require('./_enum-bug-keys');
  5498. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  5499. var Empty = function () { /* empty */ };
  5500. var PROTOTYPE = 'prototype';
  5501. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  5502. var createDict = function () {
  5503. // Thrash, waste and sodomy: IE GC bug
  5504. var iframe = require('./_dom-create')('iframe');
  5505. var i = enumBugKeys.length;
  5506. var lt = '<';
  5507. var gt = '>';
  5508. var iframeDocument;
  5509. iframe.style.display = 'none';
  5510. require('./_html').appendChild(iframe);
  5511. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  5512. // createDict = iframe.contentWindow.Object;
  5513. // html.removeChild(iframe);
  5514. iframeDocument = iframe.contentWindow.document;
  5515. iframeDocument.open();
  5516. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  5517. iframeDocument.close();
  5518. createDict = iframeDocument.F;
  5519. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  5520. return createDict();
  5521. };
  5522. module.exports = Object.create || function create(O, Properties) {
  5523. var result;
  5524. if (O !== null) {
  5525. Empty[PROTOTYPE] = anObject(O);
  5526. result = new Empty();
  5527. Empty[PROTOTYPE] = null;
  5528. // add "__proto__" for Object.getPrototypeOf polyfill
  5529. result[IE_PROTO] = O;
  5530. } else result = createDict();
  5531. return Properties === undefined ? result : dPs(result, Properties);
  5532. };
  5533. },{"./_an-object":54,"./_dom-create":63,"./_enum-bug-keys":64,"./_html":71,"./_object-dps":89,"./_shared-key":102}],88:[function(require,module,exports){
  5534. var anObject = require('./_an-object');
  5535. var IE8_DOM_DEFINE = require('./_ie8-dom-define');
  5536. var toPrimitive = require('./_to-primitive');
  5537. var dP = Object.defineProperty;
  5538. exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  5539. anObject(O);
  5540. P = toPrimitive(P, true);
  5541. anObject(Attributes);
  5542. if (IE8_DOM_DEFINE) try {
  5543. return dP(O, P, Attributes);
  5544. } catch (e) { /* empty */ }
  5545. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  5546. if ('value' in Attributes) O[P] = Attributes.value;
  5547. return O;
  5548. };
  5549. },{"./_an-object":54,"./_descriptors":62,"./_ie8-dom-define":72,"./_to-primitive":111}],89:[function(require,module,exports){
  5550. var dP = require('./_object-dp');
  5551. var anObject = require('./_an-object');
  5552. var getKeys = require('./_object-keys');
  5553. module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
  5554. anObject(O);
  5555. var keys = getKeys(Properties);
  5556. var length = keys.length;
  5557. var i = 0;
  5558. var P;
  5559. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  5560. return O;
  5561. };
  5562. },{"./_an-object":54,"./_descriptors":62,"./_object-dp":88,"./_object-keys":96}],90:[function(require,module,exports){
  5563. var pIE = require('./_object-pie');
  5564. var createDesc = require('./_property-desc');
  5565. var toIObject = require('./_to-iobject');
  5566. var toPrimitive = require('./_to-primitive');
  5567. var has = require('./_has');
  5568. var IE8_DOM_DEFINE = require('./_ie8-dom-define');
  5569. var gOPD = Object.getOwnPropertyDescriptor;
  5570. exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
  5571. O = toIObject(O);
  5572. P = toPrimitive(P, true);
  5573. if (IE8_DOM_DEFINE) try {
  5574. return gOPD(O, P);
  5575. } catch (e) { /* empty */ }
  5576. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  5577. };
  5578. },{"./_descriptors":62,"./_has":69,"./_ie8-dom-define":72,"./_object-pie":97,"./_property-desc":99,"./_to-iobject":108,"./_to-primitive":111}],91:[function(require,module,exports){
  5579. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  5580. var toIObject = require('./_to-iobject');
  5581. var gOPN = require('./_object-gopn').f;
  5582. var toString = {}.toString;
  5583. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  5584. ? Object.getOwnPropertyNames(window) : [];
  5585. var getWindowNames = function (it) {
  5586. try {
  5587. return gOPN(it);
  5588. } catch (e) {
  5589. return windowNames.slice();
  5590. }
  5591. };
  5592. module.exports.f = function getOwnPropertyNames(it) {
  5593. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  5594. };
  5595. },{"./_object-gopn":92,"./_to-iobject":108}],92:[function(require,module,exports){
  5596. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  5597. var $keys = require('./_object-keys-internal');
  5598. var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
  5599. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  5600. return $keys(O, hiddenKeys);
  5601. };
  5602. },{"./_enum-bug-keys":64,"./_object-keys-internal":95}],93:[function(require,module,exports){
  5603. exports.f = Object.getOwnPropertySymbols;
  5604. },{}],94:[function(require,module,exports){
  5605. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  5606. var has = require('./_has');
  5607. var toObject = require('./_to-object');
  5608. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  5609. var ObjectProto = Object.prototype;
  5610. module.exports = Object.getPrototypeOf || function (O) {
  5611. O = toObject(O);
  5612. if (has(O, IE_PROTO)) return O[IE_PROTO];
  5613. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  5614. return O.constructor.prototype;
  5615. } return O instanceof Object ? ObjectProto : null;
  5616. };
  5617. },{"./_has":69,"./_shared-key":102,"./_to-object":110}],95:[function(require,module,exports){
  5618. var has = require('./_has');
  5619. var toIObject = require('./_to-iobject');
  5620. var arrayIndexOf = require('./_array-includes')(false);
  5621. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  5622. module.exports = function (object, names) {
  5623. var O = toIObject(object);
  5624. var i = 0;
  5625. var result = [];
  5626. var key;
  5627. for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
  5628. // Don't enum bug & hidden keys
  5629. while (names.length > i) if (has(O, key = names[i++])) {
  5630. ~arrayIndexOf(result, key) || result.push(key);
  5631. }
  5632. return result;
  5633. };
  5634. },{"./_array-includes":55,"./_has":69,"./_shared-key":102,"./_to-iobject":108}],96:[function(require,module,exports){
  5635. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  5636. var $keys = require('./_object-keys-internal');
  5637. var enumBugKeys = require('./_enum-bug-keys');
  5638. module.exports = Object.keys || function keys(O) {
  5639. return $keys(O, enumBugKeys);
  5640. };
  5641. },{"./_enum-bug-keys":64,"./_object-keys-internal":95}],97:[function(require,module,exports){
  5642. exports.f = {}.propertyIsEnumerable;
  5643. },{}],98:[function(require,module,exports){
  5644. // most Object methods by ES6 should accept primitives
  5645. var $export = require('./_export');
  5646. var core = require('./_core');
  5647. var fails = require('./_fails');
  5648. module.exports = function (KEY, exec) {
  5649. var fn = (core.Object || {})[KEY] || Object[KEY];
  5650. var exp = {};
  5651. exp[KEY] = exec(fn);
  5652. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  5653. };
  5654. },{"./_core":58,"./_export":66,"./_fails":67}],99:[function(require,module,exports){
  5655. module.exports = function (bitmap, value) {
  5656. return {
  5657. enumerable: !(bitmap & 1),
  5658. configurable: !(bitmap & 2),
  5659. writable: !(bitmap & 4),
  5660. value: value
  5661. };
  5662. };
  5663. },{}],100:[function(require,module,exports){
  5664. module.exports = require('./_hide');
  5665. },{"./_hide":70}],101:[function(require,module,exports){
  5666. var def = require('./_object-dp').f;
  5667. var has = require('./_has');
  5668. var TAG = require('./_wks')('toStringTag');
  5669. module.exports = function (it, tag, stat) {
  5670. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  5671. };
  5672. },{"./_has":69,"./_object-dp":88,"./_wks":115}],102:[function(require,module,exports){
  5673. var shared = require('./_shared')('keys');
  5674. var uid = require('./_uid');
  5675. module.exports = function (key) {
  5676. return shared[key] || (shared[key] = uid(key));
  5677. };
  5678. },{"./_shared":103,"./_uid":112}],103:[function(require,module,exports){
  5679. var global = require('./_global');
  5680. var SHARED = '__core-js_shared__';
  5681. var store = global[SHARED] || (global[SHARED] = {});
  5682. module.exports = function (key) {
  5683. return store[key] || (store[key] = {});
  5684. };
  5685. },{"./_global":68}],104:[function(require,module,exports){
  5686. var toInteger = require('./_to-integer');
  5687. var defined = require('./_defined');
  5688. // true -> String#at
  5689. // false -> String#codePointAt
  5690. module.exports = function (TO_STRING) {
  5691. return function (that, pos) {
  5692. var s = String(defined(that));
  5693. var i = toInteger(pos);
  5694. var l = s.length;
  5695. var a, b;
  5696. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  5697. a = s.charCodeAt(i);
  5698. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  5699. ? TO_STRING ? s.charAt(i) : a
  5700. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  5701. };
  5702. };
  5703. },{"./_defined":61,"./_to-integer":107}],105:[function(require,module,exports){
  5704. var ctx = require('./_ctx');
  5705. var invoke = require('./_invoke');
  5706. var html = require('./_html');
  5707. var cel = require('./_dom-create');
  5708. var global = require('./_global');
  5709. var process = global.process;
  5710. var setTask = global.setImmediate;
  5711. var clearTask = global.clearImmediate;
  5712. var MessageChannel = global.MessageChannel;
  5713. var Dispatch = global.Dispatch;
  5714. var counter = 0;
  5715. var queue = {};
  5716. var ONREADYSTATECHANGE = 'onreadystatechange';
  5717. var defer, channel, port;
  5718. var run = function () {
  5719. var id = +this;
  5720. // eslint-disable-next-line no-prototype-builtins
  5721. if (queue.hasOwnProperty(id)) {
  5722. var fn = queue[id];
  5723. delete queue[id];
  5724. fn();
  5725. }
  5726. };
  5727. var listener = function (event) {
  5728. run.call(event.data);
  5729. };
  5730. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  5731. if (!setTask || !clearTask) {
  5732. setTask = function setImmediate(fn) {
  5733. var args = [];
  5734. var i = 1;
  5735. while (arguments.length > i) args.push(arguments[i++]);
  5736. queue[++counter] = function () {
  5737. // eslint-disable-next-line no-new-func
  5738. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  5739. };
  5740. defer(counter);
  5741. return counter;
  5742. };
  5743. clearTask = function clearImmediate(id) {
  5744. delete queue[id];
  5745. };
  5746. // Node.js 0.8-
  5747. if (require('./_cof')(process) == 'process') {
  5748. defer = function (id) {
  5749. process.nextTick(ctx(run, id, 1));
  5750. };
  5751. // Sphere (JS game engine) Dispatch API
  5752. } else if (Dispatch && Dispatch.now) {
  5753. defer = function (id) {
  5754. Dispatch.now(ctx(run, id, 1));
  5755. };
  5756. // Browsers with MessageChannel, includes WebWorkers
  5757. } else if (MessageChannel) {
  5758. channel = new MessageChannel();
  5759. port = channel.port2;
  5760. channel.port1.onmessage = listener;
  5761. defer = ctx(port.postMessage, port, 1);
  5762. // Browsers with postMessage, skip WebWorkers
  5763. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  5764. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  5765. defer = function (id) {
  5766. global.postMessage(id + '', '*');
  5767. };
  5768. global.addEventListener('message', listener, false);
  5769. // IE8-
  5770. } else if (ONREADYSTATECHANGE in cel('script')) {
  5771. defer = function (id) {
  5772. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  5773. html.removeChild(this);
  5774. run.call(id);
  5775. };
  5776. };
  5777. // Rest old browsers
  5778. } else {
  5779. defer = function (id) {
  5780. setTimeout(ctx(run, id, 1), 0);
  5781. };
  5782. }
  5783. }
  5784. module.exports = {
  5785. set: setTask,
  5786. clear: clearTask
  5787. };
  5788. },{"./_cof":57,"./_ctx":60,"./_dom-create":63,"./_global":68,"./_html":71,"./_invoke":73}],106:[function(require,module,exports){
  5789. var toInteger = require('./_to-integer');
  5790. var max = Math.max;
  5791. var min = Math.min;
  5792. module.exports = function (index, length) {
  5793. index = toInteger(index);
  5794. return index < 0 ? max(index + length, 0) : min(index, length);
  5795. };
  5796. },{"./_to-integer":107}],107:[function(require,module,exports){
  5797. // 7.1.4 ToInteger
  5798. var ceil = Math.ceil;
  5799. var floor = Math.floor;
  5800. module.exports = function (it) {
  5801. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  5802. };
  5803. },{}],108:[function(require,module,exports){
  5804. // to indexed object, toObject with fallback for non-array-like ES3 strings
  5805. var IObject = require('./_iobject');
  5806. var defined = require('./_defined');
  5807. module.exports = function (it) {
  5808. return IObject(defined(it));
  5809. };
  5810. },{"./_defined":61,"./_iobject":74}],109:[function(require,module,exports){
  5811. // 7.1.15 ToLength
  5812. var toInteger = require('./_to-integer');
  5813. var min = Math.min;
  5814. module.exports = function (it) {
  5815. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  5816. };
  5817. },{"./_to-integer":107}],110:[function(require,module,exports){
  5818. // 7.1.13 ToObject(argument)
  5819. var defined = require('./_defined');
  5820. module.exports = function (it) {
  5821. return Object(defined(it));
  5822. };
  5823. },{"./_defined":61}],111:[function(require,module,exports){
  5824. // 7.1.1 ToPrimitive(input [, PreferredType])
  5825. var isObject = require('./_is-object');
  5826. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  5827. // and the second argument - flag - preferred type is a string
  5828. module.exports = function (it, S) {
  5829. if (!isObject(it)) return it;
  5830. var fn, val;
  5831. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  5832. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  5833. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  5834. throw TypeError("Can't convert object to primitive value");
  5835. };
  5836. },{"./_is-object":77}],112:[function(require,module,exports){
  5837. var id = 0;
  5838. var px = Math.random();
  5839. module.exports = function (key) {
  5840. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  5841. };
  5842. },{}],113:[function(require,module,exports){
  5843. var global = require('./_global');
  5844. var core = require('./_core');
  5845. var LIBRARY = require('./_library');
  5846. var wksExt = require('./_wks-ext');
  5847. var defineProperty = require('./_object-dp').f;
  5848. module.exports = function (name) {
  5849. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  5850. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
  5851. };
  5852. },{"./_core":58,"./_global":68,"./_library":84,"./_object-dp":88,"./_wks-ext":114}],114:[function(require,module,exports){
  5853. exports.f = require('./_wks');
  5854. },{"./_wks":115}],115:[function(require,module,exports){
  5855. var store = require('./_shared')('wks');
  5856. var uid = require('./_uid');
  5857. var Symbol = require('./_global').Symbol;
  5858. var USE_SYMBOL = typeof Symbol == 'function';
  5859. var $exports = module.exports = function (name) {
  5860. return store[name] || (store[name] =
  5861. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  5862. };
  5863. $exports.store = store;
  5864. },{"./_global":68,"./_shared":103,"./_uid":112}],116:[function(require,module,exports){
  5865. var classof = require('./_classof');
  5866. var ITERATOR = require('./_wks')('iterator');
  5867. var Iterators = require('./_iterators');
  5868. module.exports = require('./_core').getIteratorMethod = function (it) {
  5869. if (it != undefined) return it[ITERATOR]
  5870. || it['@@iterator']
  5871. || Iterators[classof(it)];
  5872. };
  5873. },{"./_classof":56,"./_core":58,"./_iterators":83,"./_wks":115}],117:[function(require,module,exports){
  5874. 'use strict';
  5875. var ctx = require('./_ctx');
  5876. var $export = require('./_export');
  5877. var toObject = require('./_to-object');
  5878. var call = require('./_iter-call');
  5879. var isArrayIter = require('./_is-array-iter');
  5880. var toLength = require('./_to-length');
  5881. var createProperty = require('./_create-property');
  5882. var getIterFn = require('./core.get-iterator-method');
  5883. $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
  5884. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  5885. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  5886. var O = toObject(arrayLike);
  5887. var C = typeof this == 'function' ? this : Array;
  5888. var aLen = arguments.length;
  5889. var mapfn = aLen > 1 ? arguments[1] : undefined;
  5890. var mapping = mapfn !== undefined;
  5891. var index = 0;
  5892. var iterFn = getIterFn(O);
  5893. var length, result, step, iterator;
  5894. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  5895. // if object isn't iterable or it's array with default iterator - use simple case
  5896. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  5897. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  5898. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  5899. }
  5900. } else {
  5901. length = toLength(O.length);
  5902. for (result = new C(length); length > index; index++) {
  5903. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  5904. }
  5905. }
  5906. result.length = index;
  5907. return result;
  5908. }
  5909. });
  5910. },{"./_create-property":59,"./_ctx":60,"./_export":66,"./_is-array-iter":75,"./_iter-call":78,"./_iter-detect":81,"./_to-length":109,"./_to-object":110,"./core.get-iterator-method":116}],118:[function(require,module,exports){
  5911. 'use strict';
  5912. var addToUnscopables = require('./_add-to-unscopables');
  5913. var step = require('./_iter-step');
  5914. var Iterators = require('./_iterators');
  5915. var toIObject = require('./_to-iobject');
  5916. // 22.1.3.4 Array.prototype.entries()
  5917. // 22.1.3.13 Array.prototype.keys()
  5918. // 22.1.3.29 Array.prototype.values()
  5919. // 22.1.3.30 Array.prototype[@@iterator]()
  5920. module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
  5921. this._t = toIObject(iterated); // target
  5922. this._i = 0; // next index
  5923. this._k = kind; // kind
  5924. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  5925. }, function () {
  5926. var O = this._t;
  5927. var kind = this._k;
  5928. var index = this._i++;
  5929. if (!O || index >= O.length) {
  5930. this._t = undefined;
  5931. return step(1);
  5932. }
  5933. if (kind == 'keys') return step(0, index);
  5934. if (kind == 'values') return step(0, O[index]);
  5935. return step(0, [index, O[index]]);
  5936. }, 'values');
  5937. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  5938. Iterators.Arguments = Iterators.Array;
  5939. addToUnscopables('keys');
  5940. addToUnscopables('values');
  5941. addToUnscopables('entries');
  5942. },{"./_add-to-unscopables":53,"./_iter-define":80,"./_iter-step":82,"./_iterators":83,"./_to-iobject":108}],119:[function(require,module,exports){
  5943. 'use strict';
  5944. var isObject = require('./_is-object');
  5945. var getPrototypeOf = require('./_object-gpo');
  5946. var HAS_INSTANCE = require('./_wks')('hasInstance');
  5947. var FunctionProto = Function.prototype;
  5948. // 19.2.3.6 Function.prototype[@@hasInstance](V)
  5949. if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {
  5950. if (typeof this != 'function' || !isObject(O)) return false;
  5951. if (!isObject(this.prototype)) return O instanceof this;
  5952. // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
  5953. while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
  5954. return false;
  5955. } });
  5956. },{"./_is-object":77,"./_object-dp":88,"./_object-gpo":94,"./_wks":115}],120:[function(require,module,exports){
  5957. // 19.1.3.1 Object.assign(target, source)
  5958. var $export = require('./_export');
  5959. $export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
  5960. },{"./_export":66,"./_object-assign":86}],121:[function(require,module,exports){
  5961. var $export = require('./_export');
  5962. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  5963. $export($export.S, 'Object', { create: require('./_object-create') });
  5964. },{"./_export":66,"./_object-create":87}],122:[function(require,module,exports){
  5965. var $export = require('./_export');
  5966. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  5967. $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
  5968. },{"./_descriptors":62,"./_export":66,"./_object-dp":88}],123:[function(require,module,exports){
  5969. // 19.1.2.7 Object.getOwnPropertyNames(O)
  5970. require('./_object-sap')('getOwnPropertyNames', function () {
  5971. return require('./_object-gopn-ext').f;
  5972. });
  5973. },{"./_object-gopn-ext":91,"./_object-sap":98}],124:[function(require,module,exports){
  5974. // 19.1.2.9 Object.getPrototypeOf(O)
  5975. var toObject = require('./_to-object');
  5976. var $getPrototypeOf = require('./_object-gpo');
  5977. require('./_object-sap')('getPrototypeOf', function () {
  5978. return function getPrototypeOf(it) {
  5979. return $getPrototypeOf(toObject(it));
  5980. };
  5981. });
  5982. },{"./_object-gpo":94,"./_object-sap":98,"./_to-object":110}],125:[function(require,module,exports){
  5983. // 19.1.2.14 Object.keys(O)
  5984. var toObject = require('./_to-object');
  5985. var $keys = require('./_object-keys');
  5986. require('./_object-sap')('keys', function () {
  5987. return function keys(it) {
  5988. return $keys(toObject(it));
  5989. };
  5990. });
  5991. },{"./_object-keys":96,"./_object-sap":98,"./_to-object":110}],126:[function(require,module,exports){
  5992. arguments[4][30][0].apply(exports,arguments)
  5993. },{"dup":30}],127:[function(require,module,exports){
  5994. var $export = require('./_export');
  5995. var toAbsoluteIndex = require('./_to-absolute-index');
  5996. var fromCharCode = String.fromCharCode;
  5997. var $fromCodePoint = String.fromCodePoint;
  5998. // length should be 1, old FF problem
  5999. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  6000. // 21.1.2.2 String.fromCodePoint(...codePoints)
  6001. fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
  6002. var res = [];
  6003. var aLen = arguments.length;
  6004. var i = 0;
  6005. var code;
  6006. while (aLen > i) {
  6007. code = +arguments[i++];
  6008. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  6009. res.push(code < 0x10000
  6010. ? fromCharCode(code)
  6011. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  6012. );
  6013. } return res.join('');
  6014. }
  6015. });
  6016. },{"./_export":66,"./_to-absolute-index":106}],128:[function(require,module,exports){
  6017. 'use strict';
  6018. var $at = require('./_string-at')(true);
  6019. // 21.1.3.27 String.prototype[@@iterator]()
  6020. require('./_iter-define')(String, 'String', function (iterated) {
  6021. this._t = String(iterated); // target
  6022. this._i = 0; // next index
  6023. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  6024. }, function () {
  6025. var O = this._t;
  6026. var index = this._i;
  6027. var point;
  6028. if (index >= O.length) return { value: undefined, done: true };
  6029. point = $at(O, index);
  6030. this._i += point.length;
  6031. return { value: point, done: false };
  6032. });
  6033. },{"./_iter-define":80,"./_string-at":104}],129:[function(require,module,exports){
  6034. 'use strict';
  6035. // ECMAScript 6 symbols shim
  6036. var global = require('./_global');
  6037. var has = require('./_has');
  6038. var DESCRIPTORS = require('./_descriptors');
  6039. var $export = require('./_export');
  6040. var redefine = require('./_redefine');
  6041. var META = require('./_meta').KEY;
  6042. var $fails = require('./_fails');
  6043. var shared = require('./_shared');
  6044. var setToStringTag = require('./_set-to-string-tag');
  6045. var uid = require('./_uid');
  6046. var wks = require('./_wks');
  6047. var wksExt = require('./_wks-ext');
  6048. var wksDefine = require('./_wks-define');
  6049. var enumKeys = require('./_enum-keys');
  6050. var isArray = require('./_is-array');
  6051. var anObject = require('./_an-object');
  6052. var toIObject = require('./_to-iobject');
  6053. var toPrimitive = require('./_to-primitive');
  6054. var createDesc = require('./_property-desc');
  6055. var _create = require('./_object-create');
  6056. var gOPNExt = require('./_object-gopn-ext');
  6057. var $GOPD = require('./_object-gopd');
  6058. var $DP = require('./_object-dp');
  6059. var $keys = require('./_object-keys');
  6060. var gOPD = $GOPD.f;
  6061. var dP = $DP.f;
  6062. var gOPN = gOPNExt.f;
  6063. var $Symbol = global.Symbol;
  6064. var $JSON = global.JSON;
  6065. var _stringify = $JSON && $JSON.stringify;
  6066. var PROTOTYPE = 'prototype';
  6067. var HIDDEN = wks('_hidden');
  6068. var TO_PRIMITIVE = wks('toPrimitive');
  6069. var isEnum = {}.propertyIsEnumerable;
  6070. var SymbolRegistry = shared('symbol-registry');
  6071. var AllSymbols = shared('symbols');
  6072. var OPSymbols = shared('op-symbols');
  6073. var ObjectProto = Object[PROTOTYPE];
  6074. var USE_NATIVE = typeof $Symbol == 'function';
  6075. var QObject = global.QObject;
  6076. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  6077. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  6078. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  6079. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  6080. return _create(dP({}, 'a', {
  6081. get: function () { return dP(this, 'a', { value: 7 }).a; }
  6082. })).a != 7;
  6083. }) ? function (it, key, D) {
  6084. var protoDesc = gOPD(ObjectProto, key);
  6085. if (protoDesc) delete ObjectProto[key];
  6086. dP(it, key, D);
  6087. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  6088. } : dP;
  6089. var wrap = function (tag) {
  6090. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  6091. sym._k = tag;
  6092. return sym;
  6093. };
  6094. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
  6095. return typeof it == 'symbol';
  6096. } : function (it) {
  6097. return it instanceof $Symbol;
  6098. };
  6099. var $defineProperty = function defineProperty(it, key, D) {
  6100. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  6101. anObject(it);
  6102. key = toPrimitive(key, true);
  6103. anObject(D);
  6104. if (has(AllSymbols, key)) {
  6105. if (!D.enumerable) {
  6106. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  6107. it[HIDDEN][key] = true;
  6108. } else {
  6109. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  6110. D = _create(D, { enumerable: createDesc(0, false) });
  6111. } return setSymbolDesc(it, key, D);
  6112. } return dP(it, key, D);
  6113. };
  6114. var $defineProperties = function defineProperties(it, P) {
  6115. anObject(it);
  6116. var keys = enumKeys(P = toIObject(P));
  6117. var i = 0;
  6118. var l = keys.length;
  6119. var key;
  6120. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  6121. return it;
  6122. };
  6123. var $create = function create(it, P) {
  6124. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  6125. };
  6126. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  6127. var E = isEnum.call(this, key = toPrimitive(key, true));
  6128. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  6129. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  6130. };
  6131. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  6132. it = toIObject(it);
  6133. key = toPrimitive(key, true);
  6134. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  6135. var D = gOPD(it, key);
  6136. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  6137. return D;
  6138. };
  6139. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  6140. var names = gOPN(toIObject(it));
  6141. var result = [];
  6142. var i = 0;
  6143. var key;
  6144. while (names.length > i) {
  6145. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  6146. } return result;
  6147. };
  6148. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  6149. var IS_OP = it === ObjectProto;
  6150. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  6151. var result = [];
  6152. var i = 0;
  6153. var key;
  6154. while (names.length > i) {
  6155. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  6156. } return result;
  6157. };
  6158. // 19.4.1.1 Symbol([description])
  6159. if (!USE_NATIVE) {
  6160. $Symbol = function Symbol() {
  6161. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  6162. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  6163. var $set = function (value) {
  6164. if (this === ObjectProto) $set.call(OPSymbols, value);
  6165. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  6166. setSymbolDesc(this, tag, createDesc(1, value));
  6167. };
  6168. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
  6169. return wrap(tag);
  6170. };
  6171. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  6172. return this._k;
  6173. });
  6174. $GOPD.f = $getOwnPropertyDescriptor;
  6175. $DP.f = $defineProperty;
  6176. require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
  6177. require('./_object-pie').f = $propertyIsEnumerable;
  6178. require('./_object-gops').f = $getOwnPropertySymbols;
  6179. if (DESCRIPTORS && !require('./_library')) {
  6180. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  6181. }
  6182. wksExt.f = function (name) {
  6183. return wrap(wks(name));
  6184. };
  6185. }
  6186. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
  6187. for (var es6Symbols = (
  6188. // 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
  6189. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  6190. ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
  6191. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
  6192. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  6193. // 19.4.2.1 Symbol.for(key)
  6194. 'for': function (key) {
  6195. return has(SymbolRegistry, key += '')
  6196. ? SymbolRegistry[key]
  6197. : SymbolRegistry[key] = $Symbol(key);
  6198. },
  6199. // 19.4.2.5 Symbol.keyFor(sym)
  6200. keyFor: function keyFor(sym) {
  6201. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  6202. for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
  6203. },
  6204. useSetter: function () { setter = true; },
  6205. useSimple: function () { setter = false; }
  6206. });
  6207. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  6208. // 19.1.2.2 Object.create(O [, Properties])
  6209. create: $create,
  6210. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  6211. defineProperty: $defineProperty,
  6212. // 19.1.2.3 Object.defineProperties(O, Properties)
  6213. defineProperties: $defineProperties,
  6214. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  6215. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  6216. // 19.1.2.7 Object.getOwnPropertyNames(O)
  6217. getOwnPropertyNames: $getOwnPropertyNames,
  6218. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  6219. getOwnPropertySymbols: $getOwnPropertySymbols
  6220. });
  6221. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  6222. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  6223. var S = $Symbol();
  6224. // MS Edge converts symbol values to JSON as {}
  6225. // WebKit converts symbol values to JSON as null
  6226. // V8 throws on boxed symbols
  6227. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  6228. })), 'JSON', {
  6229. stringify: function stringify(it) {
  6230. if (it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  6231. var args = [it];
  6232. var i = 1;
  6233. var replacer, $replacer;
  6234. while (arguments.length > i) args.push(arguments[i++]);
  6235. replacer = args[1];
  6236. if (typeof replacer == 'function') $replacer = replacer;
  6237. if ($replacer || !isArray(replacer)) replacer = function (key, value) {
  6238. if ($replacer) value = $replacer.call(this, key, value);
  6239. if (!isSymbol(value)) return value;
  6240. };
  6241. args[1] = replacer;
  6242. return _stringify.apply($JSON, args);
  6243. }
  6244. });
  6245. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  6246. $Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  6247. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  6248. setToStringTag($Symbol, 'Symbol');
  6249. // 20.2.1.9 Math[@@toStringTag]
  6250. setToStringTag(Math, 'Math', true);
  6251. // 24.3.3 JSON[@@toStringTag]
  6252. setToStringTag(global.JSON, 'JSON', true);
  6253. },{"./_an-object":54,"./_descriptors":62,"./_enum-keys":65,"./_export":66,"./_fails":67,"./_global":68,"./_has":69,"./_hide":70,"./_is-array":76,"./_library":84,"./_meta":85,"./_object-create":87,"./_object-dp":88,"./_object-gopd":90,"./_object-gopn":92,"./_object-gopn-ext":91,"./_object-gops":93,"./_object-keys":96,"./_object-pie":97,"./_property-desc":99,"./_redefine":100,"./_set-to-string-tag":101,"./_shared":103,"./_to-iobject":108,"./_to-primitive":111,"./_uid":112,"./_wks":115,"./_wks-define":113,"./_wks-ext":114}],130:[function(require,module,exports){
  6254. require('./_wks-define')('asyncIterator');
  6255. },{"./_wks-define":113}],131:[function(require,module,exports){
  6256. require('./_wks-define')('observable');
  6257. },{"./_wks-define":113}],132:[function(require,module,exports){
  6258. require('./es6.array.iterator');
  6259. var global = require('./_global');
  6260. var hide = require('./_hide');
  6261. var Iterators = require('./_iterators');
  6262. var TO_STRING_TAG = require('./_wks')('toStringTag');
  6263. var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
  6264. 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
  6265. 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
  6266. 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
  6267. 'TextTrackList,TouchList').split(',');
  6268. for (var i = 0; i < DOMIterables.length; i++) {
  6269. var NAME = DOMIterables[i];
  6270. var Collection = global[NAME];
  6271. var proto = Collection && Collection.prototype;
  6272. if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  6273. Iterators[NAME] = Iterators.Array;
  6274. }
  6275. },{"./_global":68,"./_hide":70,"./_iterators":83,"./_wks":115,"./es6.array.iterator":118}],133:[function(require,module,exports){
  6276. var $export = require('./_export');
  6277. var $task = require('./_task');
  6278. $export($export.G + $export.B, {
  6279. setImmediate: $task.set,
  6280. clearImmediate: $task.clear
  6281. });
  6282. },{"./_export":66,"./_task":105}],134:[function(require,module,exports){
  6283. (function (Buffer){
  6284. 'use strict';
  6285. var _typeof2 = require('babel-runtime/helpers/typeof');
  6286. var _typeof3 = _interopRequireDefault(_typeof2);
  6287. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6288. // Copyright Joyent, Inc. and other Node contributors.
  6289. //
  6290. // Permission is hereby granted, free of charge, to any person obtaining a
  6291. // copy of this software and associated documentation files (the
  6292. // "Software"), to deal in the Software without restriction, including
  6293. // without limitation the rights to use, copy, modify, merge, publish,
  6294. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6295. // persons to whom the Software is furnished to do so, subject to the
  6296. // following conditions:
  6297. //
  6298. // The above copyright notice and this permission notice shall be included
  6299. // in all copies or substantial portions of the Software.
  6300. //
  6301. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6302. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6303. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6304. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6305. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6306. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6307. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6308. // NOTE: These type checking functions intentionally don't use `instanceof`
  6309. // because it is fragile and can be easily faked with `Object.create()`.
  6310. function isArray(arg) {
  6311. if (Array.isArray) {
  6312. return Array.isArray(arg);
  6313. }
  6314. return objectToString(arg) === '[object Array]';
  6315. }
  6316. exports.isArray = isArray;
  6317. function isBoolean(arg) {
  6318. return typeof arg === 'boolean';
  6319. }
  6320. exports.isBoolean = isBoolean;
  6321. function isNull(arg) {
  6322. return arg === null;
  6323. }
  6324. exports.isNull = isNull;
  6325. function isNullOrUndefined(arg) {
  6326. return arg == null;
  6327. }
  6328. exports.isNullOrUndefined = isNullOrUndefined;
  6329. function isNumber(arg) {
  6330. return typeof arg === 'number';
  6331. }
  6332. exports.isNumber = isNumber;
  6333. function isString(arg) {
  6334. return typeof arg === 'string';
  6335. }
  6336. exports.isString = isString;
  6337. function isSymbol(arg) {
  6338. return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol';
  6339. }
  6340. exports.isSymbol = isSymbol;
  6341. function isUndefined(arg) {
  6342. return arg === void 0;
  6343. }
  6344. exports.isUndefined = isUndefined;
  6345. function isRegExp(re) {
  6346. return objectToString(re) === '[object RegExp]';
  6347. }
  6348. exports.isRegExp = isRegExp;
  6349. function isObject(arg) {
  6350. return (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'object' && arg !== null;
  6351. }
  6352. exports.isObject = isObject;
  6353. function isDate(d) {
  6354. return objectToString(d) === '[object Date]';
  6355. }
  6356. exports.isDate = isDate;
  6357. function isError(e) {
  6358. return objectToString(e) === '[object Error]' || e instanceof Error;
  6359. }
  6360. exports.isError = isError;
  6361. function isFunction(arg) {
  6362. return typeof arg === 'function';
  6363. }
  6364. exports.isFunction = isFunction;
  6365. function isPrimitive(arg) {
  6366. return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || (typeof arg === 'undefined' ? 'undefined' : (0, _typeof3.default)(arg)) === 'symbol' || // ES6 symbol
  6367. typeof arg === 'undefined';
  6368. }
  6369. exports.isPrimitive = isPrimitive;
  6370. exports.isBuffer = Buffer.isBuffer;
  6371. function objectToString(o) {
  6372. return Object.prototype.toString.call(o);
  6373. }
  6374. }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
  6375. },{"../../is-buffer/index.js":150,"babel-runtime/helpers/typeof":26}],135:[function(require,module,exports){
  6376. var Buffer = require('buffer').Buffer;
  6377. var intSize = 4;
  6378. var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
  6379. var chrsz = 8;
  6380. function toArray(buf, bigEndian) {
  6381. if ((buf.length % intSize) !== 0) {
  6382. var len = buf.length + (intSize - (buf.length % intSize));
  6383. buf = Buffer.concat([buf, zeroBuffer], len);
  6384. }
  6385. var arr = [];
  6386. var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
  6387. for (var i = 0; i < buf.length; i += intSize) {
  6388. arr.push(fn.call(buf, i));
  6389. }
  6390. return arr;
  6391. }
  6392. function toBuffer(arr, size, bigEndian) {
  6393. var buf = new Buffer(size);
  6394. var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
  6395. for (var i = 0; i < arr.length; i++) {
  6396. fn.call(buf, arr[i], i * 4, true);
  6397. }
  6398. return buf;
  6399. }
  6400. function hash(buf, fn, hashSize, bigEndian) {
  6401. if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
  6402. var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
  6403. return toBuffer(arr, hashSize, bigEndian);
  6404. }
  6405. module.exports = { hash: hash };
  6406. },{"buffer":31}],136:[function(require,module,exports){
  6407. var Buffer = require('buffer').Buffer
  6408. var sha = require('./sha')
  6409. var sha256 = require('./sha256')
  6410. var rng = require('./rng')
  6411. var md5 = require('./md5')
  6412. var algorithms = {
  6413. sha1: sha,
  6414. sha256: sha256,
  6415. md5: md5
  6416. }
  6417. var blocksize = 64
  6418. var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
  6419. function hmac(fn, key, data) {
  6420. if(!Buffer.isBuffer(key)) key = new Buffer(key)
  6421. if(!Buffer.isBuffer(data)) data = new Buffer(data)
  6422. if(key.length > blocksize) {
  6423. key = fn(key)
  6424. } else if(key.length < blocksize) {
  6425. key = Buffer.concat([key, zeroBuffer], blocksize)
  6426. }
  6427. var ipad = new Buffer(blocksize), opad = new Buffer(blocksize)
  6428. for(var i = 0; i < blocksize; i++) {
  6429. ipad[i] = key[i] ^ 0x36
  6430. opad[i] = key[i] ^ 0x5C
  6431. }
  6432. var hash = fn(Buffer.concat([ipad, data]))
  6433. return fn(Buffer.concat([opad, hash]))
  6434. }
  6435. function hash(alg, key) {
  6436. alg = alg || 'sha1'
  6437. var fn = algorithms[alg]
  6438. var bufs = []
  6439. var length = 0
  6440. if(!fn) error('algorithm:', alg, 'is not yet supported')
  6441. return {
  6442. update: function (data) {
  6443. if(!Buffer.isBuffer(data)) data = new Buffer(data)
  6444. bufs.push(data)
  6445. length += data.length
  6446. return this
  6447. },
  6448. digest: function (enc) {
  6449. var buf = Buffer.concat(bufs)
  6450. var r = key ? hmac(fn, key, buf) : fn(buf)
  6451. bufs = null
  6452. return enc ? r.toString(enc) : r
  6453. }
  6454. }
  6455. }
  6456. function error () {
  6457. var m = [].slice.call(arguments).join(' ')
  6458. throw new Error([
  6459. m,
  6460. 'we accept pull requests',
  6461. 'http://github.com/dominictarr/crypto-browserify'
  6462. ].join('\n'))
  6463. }
  6464. exports.createHash = function (alg) { return hash(alg) }
  6465. exports.createHmac = function (alg, key) { return hash(alg, key) }
  6466. exports.randomBytes = function(size, callback) {
  6467. if (callback && callback.call) {
  6468. try {
  6469. callback.call(this, undefined, new Buffer(rng(size)))
  6470. } catch (err) { callback(err) }
  6471. } else {
  6472. return new Buffer(rng(size))
  6473. }
  6474. }
  6475. function each(a, f) {
  6476. for(var i in a)
  6477. f(a[i], i)
  6478. }
  6479. // the least I can do is make error messages for the rest of the node.js/crypto api.
  6480. each(['createCredentials'
  6481. , 'createCipher'
  6482. , 'createCipheriv'
  6483. , 'createDecipher'
  6484. , 'createDecipheriv'
  6485. , 'createSign'
  6486. , 'createVerify'
  6487. , 'createDiffieHellman'
  6488. , 'pbkdf2'], function (name) {
  6489. exports[name] = function () {
  6490. error('sorry,', name, 'is not implemented yet')
  6491. }
  6492. })
  6493. },{"./md5":137,"./rng":138,"./sha":139,"./sha256":140,"buffer":31}],137:[function(require,module,exports){
  6494. /*
  6495. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  6496. * Digest Algorithm, as defined in RFC 1321.
  6497. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  6498. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  6499. * Distributed under the BSD License
  6500. * See http://pajhome.org.uk/crypt/md5 for more info.
  6501. */
  6502. var helpers = require('./helpers');
  6503. /*
  6504. * Perform a simple self-test to see if the VM is working
  6505. */
  6506. function md5_vm_test()
  6507. {
  6508. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  6509. }
  6510. /*
  6511. * Calculate the MD5 of an array of little-endian words, and a bit length
  6512. */
  6513. function core_md5(x, len)
  6514. {
  6515. /* append padding */
  6516. x[len >> 5] |= 0x80 << ((len) % 32);
  6517. x[(((len + 64) >>> 9) << 4) + 14] = len;
  6518. var a = 1732584193;
  6519. var b = -271733879;
  6520. var c = -1732584194;
  6521. var d = 271733878;
  6522. for(var i = 0; i < x.length; i += 16)
  6523. {
  6524. var olda = a;
  6525. var oldb = b;
  6526. var oldc = c;
  6527. var oldd = d;
  6528. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  6529. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  6530. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  6531. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  6532. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  6533. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  6534. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  6535. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  6536. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  6537. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  6538. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  6539. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  6540. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  6541. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  6542. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  6543. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  6544. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  6545. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  6546. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  6547. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  6548. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  6549. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  6550. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  6551. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  6552. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  6553. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  6554. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  6555. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  6556. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  6557. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  6558. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  6559. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  6560. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  6561. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  6562. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  6563. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  6564. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  6565. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  6566. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  6567. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  6568. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  6569. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  6570. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  6571. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  6572. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  6573. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  6574. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  6575. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  6576. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  6577. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  6578. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  6579. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  6580. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  6581. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  6582. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  6583. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  6584. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  6585. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  6586. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  6587. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  6588. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  6589. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  6590. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  6591. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  6592. a = safe_add(a, olda);
  6593. b = safe_add(b, oldb);
  6594. c = safe_add(c, oldc);
  6595. d = safe_add(d, oldd);
  6596. }
  6597. return Array(a, b, c, d);
  6598. }
  6599. /*
  6600. * These functions implement the four basic operations the algorithm uses.
  6601. */
  6602. function md5_cmn(q, a, b, x, s, t)
  6603. {
  6604. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  6605. }
  6606. function md5_ff(a, b, c, d, x, s, t)
  6607. {
  6608. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  6609. }
  6610. function md5_gg(a, b, c, d, x, s, t)
  6611. {
  6612. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  6613. }
  6614. function md5_hh(a, b, c, d, x, s, t)
  6615. {
  6616. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  6617. }
  6618. function md5_ii(a, b, c, d, x, s, t)
  6619. {
  6620. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  6621. }
  6622. /*
  6623. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  6624. * to work around bugs in some JS interpreters.
  6625. */
  6626. function safe_add(x, y)
  6627. {
  6628. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  6629. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  6630. return (msw << 16) | (lsw & 0xFFFF);
  6631. }
  6632. /*
  6633. * Bitwise rotate a 32-bit number to the left.
  6634. */
  6635. function bit_rol(num, cnt)
  6636. {
  6637. return (num << cnt) | (num >>> (32 - cnt));
  6638. }
  6639. module.exports = function md5(buf) {
  6640. return helpers.hash(buf, core_md5, 16);
  6641. };
  6642. },{"./helpers":135}],138:[function(require,module,exports){
  6643. // Original code adapted from Robert Kieffer.
  6644. // details at https://github.com/broofa/node-uuid
  6645. (function() {
  6646. var _global = this;
  6647. var mathRNG, whatwgRNG;
  6648. // NOTE: Math.random() does not guarantee "cryptographic quality"
  6649. mathRNG = function(size) {
  6650. var bytes = new Array(size);
  6651. var r;
  6652. for (var i = 0, r; i < size; i++) {
  6653. if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
  6654. bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
  6655. }
  6656. return bytes;
  6657. }
  6658. if (_global.crypto && crypto.getRandomValues) {
  6659. whatwgRNG = function(size) {
  6660. var bytes = new Uint8Array(size);
  6661. crypto.getRandomValues(bytes);
  6662. return bytes;
  6663. }
  6664. }
  6665. module.exports = whatwgRNG || mathRNG;
  6666. }())
  6667. },{}],139:[function(require,module,exports){
  6668. /*
  6669. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  6670. * in FIPS PUB 180-1
  6671. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  6672. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  6673. * Distributed under the BSD License
  6674. * See http://pajhome.org.uk/crypt/md5 for details.
  6675. */
  6676. var helpers = require('./helpers');
  6677. /*
  6678. * Calculate the SHA-1 of an array of big-endian words, and a bit length
  6679. */
  6680. function core_sha1(x, len)
  6681. {
  6682. /* append padding */
  6683. x[len >> 5] |= 0x80 << (24 - len % 32);
  6684. x[((len + 64 >> 9) << 4) + 15] = len;
  6685. var w = Array(80);
  6686. var a = 1732584193;
  6687. var b = -271733879;
  6688. var c = -1732584194;
  6689. var d = 271733878;
  6690. var e = -1009589776;
  6691. for(var i = 0; i < x.length; i += 16)
  6692. {
  6693. var olda = a;
  6694. var oldb = b;
  6695. var oldc = c;
  6696. var oldd = d;
  6697. var olde = e;
  6698. for(var j = 0; j < 80; j++)
  6699. {
  6700. if(j < 16) w[j] = x[i + j];
  6701. else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
  6702. var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
  6703. safe_add(safe_add(e, w[j]), sha1_kt(j)));
  6704. e = d;
  6705. d = c;
  6706. c = rol(b, 30);
  6707. b = a;
  6708. a = t;
  6709. }
  6710. a = safe_add(a, olda);
  6711. b = safe_add(b, oldb);
  6712. c = safe_add(c, oldc);
  6713. d = safe_add(d, oldd);
  6714. e = safe_add(e, olde);
  6715. }
  6716. return Array(a, b, c, d, e);
  6717. }
  6718. /*
  6719. * Perform the appropriate triplet combination function for the current
  6720. * iteration
  6721. */
  6722. function sha1_ft(t, b, c, d)
  6723. {
  6724. if(t < 20) return (b & c) | ((~b) & d);
  6725. if(t < 40) return b ^ c ^ d;
  6726. if(t < 60) return (b & c) | (b & d) | (c & d);
  6727. return b ^ c ^ d;
  6728. }
  6729. /*
  6730. * Determine the appropriate additive constant for the current iteration
  6731. */
  6732. function sha1_kt(t)
  6733. {
  6734. return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
  6735. (t < 60) ? -1894007588 : -899497514;
  6736. }
  6737. /*
  6738. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  6739. * to work around bugs in some JS interpreters.
  6740. */
  6741. function safe_add(x, y)
  6742. {
  6743. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  6744. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  6745. return (msw << 16) | (lsw & 0xFFFF);
  6746. }
  6747. /*
  6748. * Bitwise rotate a 32-bit number to the left.
  6749. */
  6750. function rol(num, cnt)
  6751. {
  6752. return (num << cnt) | (num >>> (32 - cnt));
  6753. }
  6754. module.exports = function sha1(buf) {
  6755. return helpers.hash(buf, core_sha1, 20, true);
  6756. };
  6757. },{"./helpers":135}],140:[function(require,module,exports){
  6758. /**
  6759. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  6760. * in FIPS 180-2
  6761. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  6762. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  6763. *
  6764. */
  6765. var helpers = require('./helpers');
  6766. var safe_add = function(x, y) {
  6767. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  6768. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  6769. return (msw << 16) | (lsw & 0xFFFF);
  6770. };
  6771. var S = function(X, n) {
  6772. return (X >>> n) | (X << (32 - n));
  6773. };
  6774. var R = function(X, n) {
  6775. return (X >>> n);
  6776. };
  6777. var Ch = function(x, y, z) {
  6778. return ((x & y) ^ ((~x) & z));
  6779. };
  6780. var Maj = function(x, y, z) {
  6781. return ((x & y) ^ (x & z) ^ (y & z));
  6782. };
  6783. var Sigma0256 = function(x) {
  6784. return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
  6785. };
  6786. var Sigma1256 = function(x) {
  6787. return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
  6788. };
  6789. var Gamma0256 = function(x) {
  6790. return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
  6791. };
  6792. var Gamma1256 = function(x) {
  6793. return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
  6794. };
  6795. var core_sha256 = function(m, l) {
  6796. var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,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);
  6797. var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
  6798. var W = new Array(64);
  6799. var a, b, c, d, e, f, g, h, i, j;
  6800. var T1, T2;
  6801. /* append padding */
  6802. m[l >> 5] |= 0x80 << (24 - l % 32);
  6803. m[((l + 64 >> 9) << 4) + 15] = l;
  6804. for (var i = 0; i < m.length; i += 16) {
  6805. a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7];
  6806. for (var j = 0; j < 64; j++) {
  6807. if (j < 16) {
  6808. W[j] = m[j + i];
  6809. } else {
  6810. W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
  6811. }
  6812. T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
  6813. T2 = safe_add(Sigma0256(a), Maj(a, b, c));
  6814. h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2);
  6815. }
  6816. HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]);
  6817. HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]);
  6818. }
  6819. return HASH;
  6820. };
  6821. module.exports = function sha256(buf) {
  6822. return helpers.hash(buf, core_sha256, 32, true);
  6823. };
  6824. },{"./helpers":135}],141:[function(require,module,exports){
  6825. 'use strict';
  6826. var _typeof2 = require('babel-runtime/helpers/typeof');
  6827. var _typeof3 = _interopRequireDefault(_typeof2);
  6828. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6829. /*
  6830. * Date Format 1.2.3
  6831. * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
  6832. * MIT license
  6833. *
  6834. * Includes enhancements by Scott Trenda <scott.trenda.net>
  6835. * and Kris Kowal <cixar.com/~kris.kowal/>
  6836. *
  6837. * Accepts a date, a mask, or a date and a mask.
  6838. * Returns a formatted version of the given date.
  6839. * The date defaults to the current date/time.
  6840. * The mask defaults to dateFormat.masks.default.
  6841. */
  6842. (function (global) {
  6843. 'use strict';
  6844. var dateFormat = function () {
  6845. var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
  6846. var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
  6847. var timezoneClip = /[^-+\dA-Z]/g;
  6848. // Regexes and supporting functions are cached through closure
  6849. return function (date, mask, utc, gmt) {
  6850. // You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
  6851. if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
  6852. mask = date;
  6853. date = undefined;
  6854. }
  6855. date = date || new Date();
  6856. if (!(date instanceof Date)) {
  6857. date = new Date(date);
  6858. }
  6859. if (isNaN(date)) {
  6860. throw TypeError('Invalid date');
  6861. }
  6862. mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
  6863. // Allow setting the utc/gmt argument via the mask
  6864. var maskSlice = mask.slice(0, 4);
  6865. if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
  6866. mask = mask.slice(4);
  6867. utc = true;
  6868. if (maskSlice === 'GMT:') {
  6869. gmt = true;
  6870. }
  6871. }
  6872. var _ = utc ? 'getUTC' : 'get';
  6873. var d = date[_ + 'Date']();
  6874. var D = date[_ + 'Day']();
  6875. var m = date[_ + 'Month']();
  6876. var y = date[_ + 'FullYear']();
  6877. var H = date[_ + 'Hours']();
  6878. var M = date[_ + 'Minutes']();
  6879. var s = date[_ + 'Seconds']();
  6880. var L = date[_ + 'Milliseconds']();
  6881. var o = utc ? 0 : date.getTimezoneOffset();
  6882. var W = getWeek(date);
  6883. var N = getDayOfWeek(date);
  6884. var flags = {
  6885. d: d,
  6886. dd: pad(d),
  6887. ddd: dateFormat.i18n.dayNames[D],
  6888. dddd: dateFormat.i18n.dayNames[D + 7],
  6889. m: m + 1,
  6890. mm: pad(m + 1),
  6891. mmm: dateFormat.i18n.monthNames[m],
  6892. mmmm: dateFormat.i18n.monthNames[m + 12],
  6893. yy: String(y).slice(2),
  6894. yyyy: y,
  6895. h: H % 12 || 12,
  6896. hh: pad(H % 12 || 12),
  6897. H: H,
  6898. HH: pad(H),
  6899. M: M,
  6900. MM: pad(M),
  6901. s: s,
  6902. ss: pad(s),
  6903. l: pad(L, 3),
  6904. L: pad(Math.round(L / 10)),
  6905. t: H < 12 ? 'a' : 'p',
  6906. tt: H < 12 ? 'am' : 'pm',
  6907. T: H < 12 ? 'A' : 'P',
  6908. TT: H < 12 ? 'AM' : 'PM',
  6909. Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
  6910. o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
  6911. S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
  6912. W: W,
  6913. N: N
  6914. };
  6915. return mask.replace(token, function (match) {
  6916. if (match in flags) {
  6917. return flags[match];
  6918. }
  6919. return match.slice(1, match.length - 1);
  6920. });
  6921. };
  6922. }();
  6923. dateFormat.masks = {
  6924. 'default': 'ddd mmm dd yyyy HH:MM:ss',
  6925. 'shortDate': 'm/d/yy',
  6926. 'mediumDate': 'mmm d, yyyy',
  6927. 'longDate': 'mmmm d, yyyy',
  6928. 'fullDate': 'dddd, mmmm d, yyyy',
  6929. 'shortTime': 'h:MM TT',
  6930. 'mediumTime': 'h:MM:ss TT',
  6931. 'longTime': 'h:MM:ss TT Z',
  6932. 'isoDate': 'yyyy-mm-dd',
  6933. 'isoTime': 'HH:MM:ss',
  6934. 'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
  6935. 'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
  6936. 'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
  6937. };
  6938. // Internationalization strings
  6939. dateFormat.i18n = {
  6940. dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  6941. monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  6942. };
  6943. function pad(val, len) {
  6944. val = String(val);
  6945. len = len || 2;
  6946. while (val.length < len) {
  6947. val = '0' + val;
  6948. }
  6949. return val;
  6950. }
  6951. /**
  6952. * Get the ISO 8601 week number
  6953. * Based on comments from
  6954. * http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
  6955. *
  6956. * @param {Object} `date`
  6957. * @return {Number}
  6958. */
  6959. function getWeek(date) {
  6960. // Remove time components of date
  6961. var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  6962. // Change date to Thursday same week
  6963. targetThursday.setDate(targetThursday.getDate() - (targetThursday.getDay() + 6) % 7 + 3);
  6964. // Take January 4th as it is always in week 1 (see ISO 8601)
  6965. var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
  6966. // Change date to Thursday same week
  6967. firstThursday.setDate(firstThursday.getDate() - (firstThursday.getDay() + 6) % 7 + 3);
  6968. // Check if daylight-saving-time-switch occurred and correct for it
  6969. var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
  6970. targetThursday.setHours(targetThursday.getHours() - ds);
  6971. // Number of weeks between target Thursday and first Thursday
  6972. var weekDiff = (targetThursday - firstThursday) / (86400000 * 7);
  6973. return 1 + Math.floor(weekDiff);
  6974. }
  6975. /**
  6976. * Get ISO-8601 numeric representation of the day of the week
  6977. * 1 (for Monday) through 7 (for Sunday)
  6978. *
  6979. * @param {Object} `date`
  6980. * @return {Number}
  6981. */
  6982. function getDayOfWeek(date) {
  6983. var dow = date.getDay();
  6984. if (dow === 0) {
  6985. dow = 7;
  6986. }
  6987. return dow;
  6988. }
  6989. /**
  6990. * kind-of shortcut
  6991. * @param {*} val
  6992. * @return {String}
  6993. */
  6994. function kindOf(val) {
  6995. if (val === null) {
  6996. return 'null';
  6997. }
  6998. if (val === undefined) {
  6999. return 'undefined';
  7000. }
  7001. if ((typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) !== 'object') {
  7002. return typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val);
  7003. }
  7004. if (Array.isArray(val)) {
  7005. return 'array';
  7006. }
  7007. return {}.toString.call(val).slice(8, -1).toLowerCase();
  7008. };
  7009. if (typeof define === 'function' && define.amd) {
  7010. define(function () {
  7011. return dateFormat;
  7012. });
  7013. } else if ((typeof exports === 'undefined' ? 'undefined' : (0, _typeof3.default)(exports)) === 'object') {
  7014. module.exports = dateFormat;
  7015. } else {
  7016. global.dateFormat = dateFormat;
  7017. }
  7018. })(undefined);
  7019. },{"babel-runtime/helpers/typeof":26}],142:[function(require,module,exports){
  7020. (function (process){
  7021. /**
  7022. * This is the web browser implementation of `debug()`.
  7023. *
  7024. * Expose `debug()` as the module.
  7025. */
  7026. exports = module.exports = require('./debug');
  7027. exports.log = log;
  7028. exports.formatArgs = formatArgs;
  7029. exports.save = save;
  7030. exports.load = load;
  7031. exports.useColors = useColors;
  7032. exports.storage = 'undefined' != typeof chrome
  7033. && 'undefined' != typeof chrome.storage
  7034. ? chrome.storage.local
  7035. : localstorage();
  7036. /**
  7037. * Colors.
  7038. */
  7039. exports.colors = [
  7040. 'lightseagreen',
  7041. 'forestgreen',
  7042. 'goldenrod',
  7043. 'dodgerblue',
  7044. 'darkorchid',
  7045. 'crimson'
  7046. ];
  7047. /**
  7048. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  7049. * and the Firebug extension (any Firefox version) are known
  7050. * to support "%c" CSS customizations.
  7051. *
  7052. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  7053. */
  7054. function useColors() {
  7055. // NB: In an Electron preload script, document will be defined but not fully
  7056. // initialized. Since we know we're in Chrome, we'll just detect this case
  7057. // explicitly
  7058. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  7059. return true;
  7060. }
  7061. // is webkit? http://stackoverflow.com/a/16459606/376773
  7062. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  7063. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  7064. // is firebug? http://stackoverflow.com/a/398120/376773
  7065. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  7066. // is firefox >= v31?
  7067. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  7068. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  7069. // double check webkit in userAgent just in case we are in a worker
  7070. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  7071. }
  7072. /**
  7073. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  7074. */
  7075. exports.formatters.j = function(v) {
  7076. try {
  7077. return JSON.stringify(v);
  7078. } catch (err) {
  7079. return '[UnexpectedJSONParseError]: ' + err.message;
  7080. }
  7081. };
  7082. /**
  7083. * Colorize log arguments if enabled.
  7084. *
  7085. * @api public
  7086. */
  7087. function formatArgs(args) {
  7088. var useColors = this.useColors;
  7089. args[0] = (useColors ? '%c' : '')
  7090. + this.namespace
  7091. + (useColors ? ' %c' : ' ')
  7092. + args[0]
  7093. + (useColors ? '%c ' : ' ')
  7094. + '+' + exports.humanize(this.diff);
  7095. if (!useColors) return;
  7096. var c = 'color: ' + this.color;
  7097. args.splice(1, 0, c, 'color: inherit')
  7098. // the final "%c" is somewhat tricky, because there could be other
  7099. // arguments passed either before or after the %c, so we need to
  7100. // figure out the correct index to insert the CSS into
  7101. var index = 0;
  7102. var lastC = 0;
  7103. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  7104. if ('%%' === match) return;
  7105. index++;
  7106. if ('%c' === match) {
  7107. // we only are interested in the *last* %c
  7108. // (the user may have provided their own)
  7109. lastC = index;
  7110. }
  7111. });
  7112. args.splice(lastC, 0, c);
  7113. }
  7114. /**
  7115. * Invokes `console.log()` when available.
  7116. * No-op when `console.log` is not a "function".
  7117. *
  7118. * @api public
  7119. */
  7120. function log() {
  7121. // this hackery is required for IE8/9, where
  7122. // the `console.log` function doesn't have 'apply'
  7123. return 'object' === typeof console
  7124. && console.log
  7125. && Function.prototype.apply.call(console.log, console, arguments);
  7126. }
  7127. /**
  7128. * Save `namespaces`.
  7129. *
  7130. * @param {String} namespaces
  7131. * @api private
  7132. */
  7133. function save(namespaces) {
  7134. try {
  7135. if (null == namespaces) {
  7136. exports.storage.removeItem('debug');
  7137. } else {
  7138. exports.storage.debug = namespaces;
  7139. }
  7140. } catch(e) {}
  7141. }
  7142. /**
  7143. * Load `namespaces`.
  7144. *
  7145. * @return {String} returns the previously persisted debug modes
  7146. * @api private
  7147. */
  7148. function load() {
  7149. var r;
  7150. try {
  7151. r = exports.storage.debug;
  7152. } catch(e) {}
  7153. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  7154. if (!r && typeof process !== 'undefined' && 'env' in process) {
  7155. r = process.env.DEBUG;
  7156. }
  7157. return r;
  7158. }
  7159. /**
  7160. * Enable namespaces listed in `localStorage.debug` initially.
  7161. */
  7162. exports.enable(load());
  7163. /**
  7164. * Localstorage attempts to return the localstorage.
  7165. *
  7166. * This is necessary because safari throws
  7167. * when a user disables cookies/localstorage
  7168. * and you attempt to access it.
  7169. *
  7170. * @return {LocalStorage}
  7171. * @api private
  7172. */
  7173. function localstorage() {
  7174. try {
  7175. return window.localStorage;
  7176. } catch (e) {}
  7177. }
  7178. }).call(this,require('_process'))
  7179. },{"./debug":143,"_process":159}],143:[function(require,module,exports){
  7180. /**
  7181. * This is the common logic for both the Node.js and web browser
  7182. * implementations of `debug()`.
  7183. *
  7184. * Expose `debug()` as the module.
  7185. */
  7186. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  7187. exports.coerce = coerce;
  7188. exports.disable = disable;
  7189. exports.enable = enable;
  7190. exports.enabled = enabled;
  7191. exports.humanize = require('ms');
  7192. /**
  7193. * The currently active debug mode names, and names to skip.
  7194. */
  7195. exports.names = [];
  7196. exports.skips = [];
  7197. /**
  7198. * Map of special "%n" handling functions, for the debug "format" argument.
  7199. *
  7200. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  7201. */
  7202. exports.formatters = {};
  7203. /**
  7204. * Previous log timestamp.
  7205. */
  7206. var prevTime;
  7207. /**
  7208. * Select a color.
  7209. * @param {String} namespace
  7210. * @return {Number}
  7211. * @api private
  7212. */
  7213. function selectColor(namespace) {
  7214. var hash = 0, i;
  7215. for (i in namespace) {
  7216. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  7217. hash |= 0; // Convert to 32bit integer
  7218. }
  7219. return exports.colors[Math.abs(hash) % exports.colors.length];
  7220. }
  7221. /**
  7222. * Create a debugger with the given `namespace`.
  7223. *
  7224. * @param {String} namespace
  7225. * @return {Function}
  7226. * @api public
  7227. */
  7228. function createDebug(namespace) {
  7229. function debug() {
  7230. // disabled?
  7231. if (!debug.enabled) return;
  7232. var self = debug;
  7233. // set `diff` timestamp
  7234. var curr = +new Date();
  7235. var ms = curr - (prevTime || curr);
  7236. self.diff = ms;
  7237. self.prev = prevTime;
  7238. self.curr = curr;
  7239. prevTime = curr;
  7240. // turn the `arguments` into a proper Array
  7241. var args = new Array(arguments.length);
  7242. for (var i = 0; i < args.length; i++) {
  7243. args[i] = arguments[i];
  7244. }
  7245. args[0] = exports.coerce(args[0]);
  7246. if ('string' !== typeof args[0]) {
  7247. // anything else let's inspect with %O
  7248. args.unshift('%O');
  7249. }
  7250. // apply any `formatters` transformations
  7251. var index = 0;
  7252. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  7253. // if we encounter an escaped % then don't increase the array index
  7254. if (match === '%%') return match;
  7255. index++;
  7256. var formatter = exports.formatters[format];
  7257. if ('function' === typeof formatter) {
  7258. var val = args[index];
  7259. match = formatter.call(self, val);
  7260. // now we need to remove `args[index]` since it's inlined in the `format`
  7261. args.splice(index, 1);
  7262. index--;
  7263. }
  7264. return match;
  7265. });
  7266. // apply env-specific formatting (colors, etc.)
  7267. exports.formatArgs.call(self, args);
  7268. var logFn = debug.log || exports.log || console.log.bind(console);
  7269. logFn.apply(self, args);
  7270. }
  7271. debug.namespace = namespace;
  7272. debug.enabled = exports.enabled(namespace);
  7273. debug.useColors = exports.useColors();
  7274. debug.color = selectColor(namespace);
  7275. // env-specific initialization logic for debug instances
  7276. if ('function' === typeof exports.init) {
  7277. exports.init(debug);
  7278. }
  7279. return debug;
  7280. }
  7281. /**
  7282. * Enables a debug mode by namespaces. This can include modes
  7283. * separated by a colon and wildcards.
  7284. *
  7285. * @param {String} namespaces
  7286. * @api public
  7287. */
  7288. function enable(namespaces) {
  7289. exports.save(namespaces);
  7290. exports.names = [];
  7291. exports.skips = [];
  7292. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  7293. var len = split.length;
  7294. for (var i = 0; i < len; i++) {
  7295. if (!split[i]) continue; // ignore empty strings
  7296. namespaces = split[i].replace(/\*/g, '.*?');
  7297. if (namespaces[0] === '-') {
  7298. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  7299. } else {
  7300. exports.names.push(new RegExp('^' + namespaces + '$'));
  7301. }
  7302. }
  7303. }
  7304. /**
  7305. * Disable debug output.
  7306. *
  7307. * @api public
  7308. */
  7309. function disable() {
  7310. exports.enable('');
  7311. }
  7312. /**
  7313. * Returns true if the given mode name is enabled, false otherwise.
  7314. *
  7315. * @param {String} name
  7316. * @return {Boolean}
  7317. * @api public
  7318. */
  7319. function enabled(name) {
  7320. var i, len;
  7321. for (i = 0, len = exports.skips.length; i < len; i++) {
  7322. if (exports.skips[i].test(name)) {
  7323. return false;
  7324. }
  7325. }
  7326. for (i = 0, len = exports.names.length; i < len; i++) {
  7327. if (exports.names[i].test(name)) {
  7328. return true;
  7329. }
  7330. }
  7331. return false;
  7332. }
  7333. /**
  7334. * Coerce `val`.
  7335. *
  7336. * @param {Mixed} val
  7337. * @return {Mixed}
  7338. * @api private
  7339. */
  7340. function coerce(val) {
  7341. if (val instanceof Error) return val.stack || val.message;
  7342. return val;
  7343. }
  7344. },{"ms":155}],144:[function(require,module,exports){
  7345. /*!
  7346. * escape-html
  7347. * Copyright(c) 2012-2013 TJ Holowaychuk
  7348. * Copyright(c) 2015 Andreas Lubbe
  7349. * Copyright(c) 2015 Tiancheng "Timothy" Gu
  7350. * MIT Licensed
  7351. */
  7352. 'use strict';
  7353. /**
  7354. * Module variables.
  7355. * @private
  7356. */
  7357. var matchHtmlRegExp = /["'&<>]/;
  7358. /**
  7359. * Module exports.
  7360. * @public
  7361. */
  7362. module.exports = escapeHtml;
  7363. /**
  7364. * Escape special characters in the given string of html.
  7365. *
  7366. * @param {string} string The string to escape for inserting into HTML
  7367. * @return {string}
  7368. * @public
  7369. */
  7370. function escapeHtml(string) {
  7371. var str = '' + string;
  7372. var match = matchHtmlRegExp.exec(str);
  7373. if (!match) {
  7374. return str;
  7375. }
  7376. var escape;
  7377. var html = '';
  7378. var index = 0;
  7379. var lastIndex = 0;
  7380. for (index = match.index; index < str.length; index++) {
  7381. switch (str.charCodeAt(index)) {
  7382. case 34: // "
  7383. escape = '&quot;';
  7384. break;
  7385. case 38: // &
  7386. escape = '&amp;';
  7387. break;
  7388. case 39: // '
  7389. escape = '&#39;';
  7390. break;
  7391. case 60: // <
  7392. escape = '&lt;';
  7393. break;
  7394. case 62: // >
  7395. escape = '&gt;';
  7396. break;
  7397. default:
  7398. continue;
  7399. }
  7400. if (lastIndex !== index) {
  7401. html += str.substring(lastIndex, index);
  7402. }
  7403. lastIndex = index + 1;
  7404. html += escape;
  7405. }
  7406. return lastIndex !== index
  7407. ? html + str.substring(lastIndex, index)
  7408. : html;
  7409. }
  7410. },{}],145:[function(require,module,exports){
  7411. // Copyright Joyent, Inc. and other Node contributors.
  7412. //
  7413. // Permission is hereby granted, free of charge, to any person obtaining a
  7414. // copy of this software and associated documentation files (the
  7415. // "Software"), to deal in the Software without restriction, including
  7416. // without limitation the rights to use, copy, modify, merge, publish,
  7417. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7418. // persons to whom the Software is furnished to do so, subject to the
  7419. // following conditions:
  7420. //
  7421. // The above copyright notice and this permission notice shall be included
  7422. // in all copies or substantial portions of the Software.
  7423. //
  7424. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7425. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7426. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7427. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7428. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7429. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7430. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7431. function EventEmitter() {
  7432. this._events = this._events || {};
  7433. this._maxListeners = this._maxListeners || undefined;
  7434. }
  7435. module.exports = EventEmitter;
  7436. // Backwards-compat with node 0.10.x
  7437. EventEmitter.EventEmitter = EventEmitter;
  7438. EventEmitter.prototype._events = undefined;
  7439. EventEmitter.prototype._maxListeners = undefined;
  7440. // By default EventEmitters will print a warning if more than 10 listeners are
  7441. // added to it. This is a useful default which helps finding memory leaks.
  7442. EventEmitter.defaultMaxListeners = 10;
  7443. // Obviously not all Emitters should be limited to 10. This function allows
  7444. // that to be increased. Set to zero for unlimited.
  7445. EventEmitter.prototype.setMaxListeners = function(n) {
  7446. if (!isNumber(n) || n < 0 || isNaN(n))
  7447. throw TypeError('n must be a positive number');
  7448. this._maxListeners = n;
  7449. return this;
  7450. };
  7451. EventEmitter.prototype.emit = function(type) {
  7452. var er, handler, len, args, i, listeners;
  7453. if (!this._events)
  7454. this._events = {};
  7455. // If there is no 'error' event listener then throw.
  7456. if (type === 'error') {
  7457. if (!this._events.error ||
  7458. (isObject(this._events.error) && !this._events.error.length)) {
  7459. er = arguments[1];
  7460. if (er instanceof Error) {
  7461. throw er; // Unhandled 'error' event
  7462. } else {
  7463. // At least give some kind of context to the user
  7464. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  7465. err.context = er;
  7466. throw err;
  7467. }
  7468. }
  7469. }
  7470. handler = this._events[type];
  7471. if (isUndefined(handler))
  7472. return false;
  7473. if (isFunction(handler)) {
  7474. switch (arguments.length) {
  7475. // fast cases
  7476. case 1:
  7477. handler.call(this);
  7478. break;
  7479. case 2:
  7480. handler.call(this, arguments[1]);
  7481. break;
  7482. case 3:
  7483. handler.call(this, arguments[1], arguments[2]);
  7484. break;
  7485. // slower
  7486. default:
  7487. args = Array.prototype.slice.call(arguments, 1);
  7488. handler.apply(this, args);
  7489. }
  7490. } else if (isObject(handler)) {
  7491. args = Array.prototype.slice.call(arguments, 1);
  7492. listeners = handler.slice();
  7493. len = listeners.length;
  7494. for (i = 0; i < len; i++)
  7495. listeners[i].apply(this, args);
  7496. }
  7497. return true;
  7498. };
  7499. EventEmitter.prototype.addListener = function(type, listener) {
  7500. var m;
  7501. if (!isFunction(listener))
  7502. throw TypeError('listener must be a function');
  7503. if (!this._events)
  7504. this._events = {};
  7505. // To avoid recursion in the case that type === "newListener"! Before
  7506. // adding it to the listeners, first emit "newListener".
  7507. if (this._events.newListener)
  7508. this.emit('newListener', type,
  7509. isFunction(listener.listener) ?
  7510. listener.listener : listener);
  7511. if (!this._events[type])
  7512. // Optimize the case of one listener. Don't need the extra array object.
  7513. this._events[type] = listener;
  7514. else if (isObject(this._events[type]))
  7515. // If we've already got an array, just append.
  7516. this._events[type].push(listener);
  7517. else
  7518. // Adding the second element, need to change to array.
  7519. this._events[type] = [this._events[type], listener];
  7520. // Check for listener leak
  7521. if (isObject(this._events[type]) && !this._events[type].warned) {
  7522. if (!isUndefined(this._maxListeners)) {
  7523. m = this._maxListeners;
  7524. } else {
  7525. m = EventEmitter.defaultMaxListeners;
  7526. }
  7527. if (m && m > 0 && this._events[type].length > m) {
  7528. this._events[type].warned = true;
  7529. console.error('(node) warning: possible EventEmitter memory ' +
  7530. 'leak detected. %d listeners added. ' +
  7531. 'Use emitter.setMaxListeners() to increase limit.',
  7532. this._events[type].length);
  7533. if (typeof console.trace === 'function') {
  7534. // not supported in IE 10
  7535. console.trace();
  7536. }
  7537. }
  7538. }
  7539. return this;
  7540. };
  7541. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  7542. EventEmitter.prototype.once = function(type, listener) {
  7543. if (!isFunction(listener))
  7544. throw TypeError('listener must be a function');
  7545. var fired = false;
  7546. function g() {
  7547. this.removeListener(type, g);
  7548. if (!fired) {
  7549. fired = true;
  7550. listener.apply(this, arguments);
  7551. }
  7552. }
  7553. g.listener = listener;
  7554. this.on(type, g);
  7555. return this;
  7556. };
  7557. // emits a 'removeListener' event iff the listener was removed
  7558. EventEmitter.prototype.removeListener = function(type, listener) {
  7559. var list, position, length, i;
  7560. if (!isFunction(listener))
  7561. throw TypeError('listener must be a function');
  7562. if (!this._events || !this._events[type])
  7563. return this;
  7564. list = this._events[type];
  7565. length = list.length;
  7566. position = -1;
  7567. if (list === listener ||
  7568. (isFunction(list.listener) && list.listener === listener)) {
  7569. delete this._events[type];
  7570. if (this._events.removeListener)
  7571. this.emit('removeListener', type, listener);
  7572. } else if (isObject(list)) {
  7573. for (i = length; i-- > 0;) {
  7574. if (list[i] === listener ||
  7575. (list[i].listener && list[i].listener === listener)) {
  7576. position = i;
  7577. break;
  7578. }
  7579. }
  7580. if (position < 0)
  7581. return this;
  7582. if (list.length === 1) {
  7583. list.length = 0;
  7584. delete this._events[type];
  7585. } else {
  7586. list.splice(position, 1);
  7587. }
  7588. if (this._events.removeListener)
  7589. this.emit('removeListener', type, listener);
  7590. }
  7591. return this;
  7592. };
  7593. EventEmitter.prototype.removeAllListeners = function(type) {
  7594. var key, listeners;
  7595. if (!this._events)
  7596. return this;
  7597. // not listening for removeListener, no need to emit
  7598. if (!this._events.removeListener) {
  7599. if (arguments.length === 0)
  7600. this._events = {};
  7601. else if (this._events[type])
  7602. delete this._events[type];
  7603. return this;
  7604. }
  7605. // emit removeListener for all listeners on all events
  7606. if (arguments.length === 0) {
  7607. for (key in this._events) {
  7608. if (key === 'removeListener') continue;
  7609. this.removeAllListeners(key);
  7610. }
  7611. this.removeAllListeners('removeListener');
  7612. this._events = {};
  7613. return this;
  7614. }
  7615. listeners = this._events[type];
  7616. if (isFunction(listeners)) {
  7617. this.removeListener(type, listeners);
  7618. } else if (listeners) {
  7619. // LIFO order
  7620. while (listeners.length)
  7621. this.removeListener(type, listeners[listeners.length - 1]);
  7622. }
  7623. delete this._events[type];
  7624. return this;
  7625. };
  7626. EventEmitter.prototype.listeners = function(type) {
  7627. var ret;
  7628. if (!this._events || !this._events[type])
  7629. ret = [];
  7630. else if (isFunction(this._events[type]))
  7631. ret = [this._events[type]];
  7632. else
  7633. ret = this._events[type].slice();
  7634. return ret;
  7635. };
  7636. EventEmitter.prototype.listenerCount = function(type) {
  7637. if (this._events) {
  7638. var evlistener = this._events[type];
  7639. if (isFunction(evlistener))
  7640. return 1;
  7641. else if (evlistener)
  7642. return evlistener.length;
  7643. }
  7644. return 0;
  7645. };
  7646. EventEmitter.listenerCount = function(emitter, type) {
  7647. return emitter.listenerCount(type);
  7648. };
  7649. function isFunction(arg) {
  7650. return typeof arg === 'function';
  7651. }
  7652. function isNumber(arg) {
  7653. return typeof arg === 'number';
  7654. }
  7655. function isObject(arg) {
  7656. return typeof arg === 'object' && arg !== null;
  7657. }
  7658. function isUndefined(arg) {
  7659. return arg === void 0;
  7660. }
  7661. },{}],146:[function(require,module,exports){
  7662. var http = require('http');
  7663. var https = module.exports;
  7664. for (var key in http) {
  7665. if (http.hasOwnProperty(key)) https[key] = http[key];
  7666. };
  7667. https.request = function (params, cb) {
  7668. if (!params) params = {};
  7669. params.scheme = 'https';
  7670. params.protocol = 'https:';
  7671. return http.request.call(this, params, cb);
  7672. }
  7673. },{"http":184}],147:[function(require,module,exports){
  7674. /*!
  7675. * humanize-ms - index.js
  7676. * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
  7677. * MIT Licensed
  7678. */
  7679. 'use strict';
  7680. /**
  7681. * Module dependencies.
  7682. */
  7683. var util = require('util');
  7684. var ms = require('ms');
  7685. module.exports = function (t) {
  7686. if (typeof t === 'number') return t;
  7687. var r = ms(t);
  7688. if (r === undefined) {
  7689. var err = new Error(util.format('humanize-ms(%j) result undefined', t));
  7690. console.warn(err.stack);
  7691. }
  7692. return r;
  7693. };
  7694. },{"ms":155,"util":196}],148:[function(require,module,exports){
  7695. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7696. var e, m
  7697. var eLen = nBytes * 8 - mLen - 1
  7698. var eMax = (1 << eLen) - 1
  7699. var eBias = eMax >> 1
  7700. var nBits = -7
  7701. var i = isLE ? (nBytes - 1) : 0
  7702. var d = isLE ? -1 : 1
  7703. var s = buffer[offset + i]
  7704. i += d
  7705. e = s & ((1 << (-nBits)) - 1)
  7706. s >>= (-nBits)
  7707. nBits += eLen
  7708. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  7709. m = e & ((1 << (-nBits)) - 1)
  7710. e >>= (-nBits)
  7711. nBits += mLen
  7712. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  7713. if (e === 0) {
  7714. e = 1 - eBias
  7715. } else if (e === eMax) {
  7716. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7717. } else {
  7718. m = m + Math.pow(2, mLen)
  7719. e = e - eBias
  7720. }
  7721. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7722. }
  7723. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7724. var e, m, c
  7725. var eLen = nBytes * 8 - mLen - 1
  7726. var eMax = (1 << eLen) - 1
  7727. var eBias = eMax >> 1
  7728. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7729. var i = isLE ? 0 : (nBytes - 1)
  7730. var d = isLE ? 1 : -1
  7731. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7732. value = Math.abs(value)
  7733. if (isNaN(value) || value === Infinity) {
  7734. m = isNaN(value) ? 1 : 0
  7735. e = eMax
  7736. } else {
  7737. e = Math.floor(Math.log(value) / Math.LN2)
  7738. if (value * (c = Math.pow(2, -e)) < 1) {
  7739. e--
  7740. c *= 2
  7741. }
  7742. if (e + eBias >= 1) {
  7743. value += rt / c
  7744. } else {
  7745. value += rt * Math.pow(2, 1 - eBias)
  7746. }
  7747. if (value * c >= 2) {
  7748. e++
  7749. c /= 2
  7750. }
  7751. if (e + eBias >= eMax) {
  7752. m = 0
  7753. e = eMax
  7754. } else if (e + eBias >= 1) {
  7755. m = (value * c - 1) * Math.pow(2, mLen)
  7756. e = e + eBias
  7757. } else {
  7758. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7759. e = 0
  7760. }
  7761. }
  7762. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7763. e = (e << mLen) | m
  7764. eLen += mLen
  7765. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7766. buffer[offset + i - d] |= s * 128
  7767. }
  7768. },{}],149:[function(require,module,exports){
  7769. if (typeof Object.create === 'function') {
  7770. // implementation from standard node.js 'util' module
  7771. module.exports = function inherits(ctor, superCtor) {
  7772. ctor.super_ = superCtor
  7773. ctor.prototype = Object.create(superCtor.prototype, {
  7774. constructor: {
  7775. value: ctor,
  7776. enumerable: false,
  7777. writable: true,
  7778. configurable: true
  7779. }
  7780. });
  7781. };
  7782. } else {
  7783. // old school shim for old browsers
  7784. module.exports = function inherits(ctor, superCtor) {
  7785. ctor.super_ = superCtor
  7786. var TempCtor = function () {}
  7787. TempCtor.prototype = superCtor.prototype
  7788. ctor.prototype = new TempCtor()
  7789. ctor.prototype.constructor = ctor
  7790. }
  7791. }
  7792. },{}],150:[function(require,module,exports){
  7793. /*!
  7794. * Determine if an object is a Buffer
  7795. *
  7796. * @author Feross Aboukhadijeh <https://feross.org>
  7797. * @license MIT
  7798. */
  7799. // The _isBuffer check is for Safari 5-7 support, because it's missing
  7800. // Object.prototype.constructor. Remove this eventually
  7801. module.exports = function (obj) {
  7802. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  7803. }
  7804. function isBuffer (obj) {
  7805. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  7806. }
  7807. // For Node v0.10 support. Remove this eventually.
  7808. function isSlowBuffer (obj) {
  7809. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  7810. }
  7811. },{}],151:[function(require,module,exports){
  7812. (function(root) {
  7813. var toString = Function.prototype.toString;
  7814. function fnBody(fn) {
  7815. return toString.call(fn).replace(/^[^{]*{\s*/,'').replace(/\s*}[^}]*$/,'');
  7816. }
  7817. function isClass(fn) {
  7818. return (typeof fn === 'function' &&
  7819. (/^class\s/.test(toString.call(fn)) ||
  7820. (/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
  7821. );
  7822. }
  7823. if (typeof exports !== 'undefined') {
  7824. if (typeof module !== 'undefined' && module.exports) {
  7825. exports = module.exports = isClass;
  7826. }
  7827. exports.isClass = isClass;
  7828. } else if (typeof define === 'function' && define.amd) {
  7829. define([], function() {
  7830. return isClass;
  7831. });
  7832. } else {
  7833. root.isClass = isClass;
  7834. }
  7835. })(this);
  7836. },{}],152:[function(require,module,exports){
  7837. 'use strict';
  7838. var utils = require('core-util-is');
  7839. var isStearm = require('isstream');
  7840. var isClass = require('is-class');
  7841. /**
  7842. * Expose all methods in core-util-is
  7843. */
  7844. Object.keys(utils).map(function (name) {
  7845. exports[transform(name)] = utils[name];
  7846. });
  7847. /**
  7848. * Stream detected by isstream
  7849. */
  7850. exports.stream = isStearm;
  7851. exports.readableStream = isStearm.isReadable;
  7852. exports.writableStream = isStearm.isWritable;
  7853. exports.duplexStream = isStearm.isDuplex;
  7854. /**
  7855. * Class detected by is-class
  7856. */
  7857. exports.class = isClass;
  7858. /**
  7859. * Extend method
  7860. */
  7861. exports.finite = function (obj) {
  7862. return Number.isFinite(obj);
  7863. };
  7864. exports.NaN = function (obj) {
  7865. return Number.isNaN(obj);
  7866. };
  7867. exports.generator = function (obj) {
  7868. return obj
  7869. && 'function' === typeof obj.next
  7870. && 'function' === typeof obj.throw;
  7871. };
  7872. exports.generatorFunction = function (obj) {
  7873. return obj
  7874. && obj.constructor
  7875. && 'GeneratorFunction' === obj.constructor.name;
  7876. };
  7877. exports.asyncFunction = function (obj) {
  7878. return obj
  7879. && obj.constructor
  7880. && 'AsyncFunction' === obj.constructor.name;
  7881. };
  7882. exports.promise = function (obj) {
  7883. return obj
  7884. && 'function' === typeof obj.then;
  7885. };
  7886. var MAX_INT_31 = Math.pow(2, 31);
  7887. exports.int = function (obj) {
  7888. return utils.isNumber(obj)
  7889. && obj % 1 === 0;
  7890. };
  7891. exports.int32 = function (obj) {
  7892. return exports.int(obj)
  7893. && obj < MAX_INT_31
  7894. && obj >= -MAX_INT_31;
  7895. };
  7896. exports.long = function (obj) {
  7897. return exports.int(obj)
  7898. && (obj >= MAX_INT_31 || obj < -MAX_INT_31);
  7899. };
  7900. exports.Long = function (obj) {
  7901. return exports.object(obj)
  7902. && exports.number(obj.high)
  7903. && exports.number(obj.low);
  7904. };
  7905. exports.double = function (obj) {
  7906. return utils.isNumber(obj)
  7907. && !isNaN(obj)
  7908. && obj % 1 !== 0;
  7909. };
  7910. /**
  7911. * override core-util-is
  7912. */
  7913. exports.date = function isDate(obj) {
  7914. return obj instanceof Date;
  7915. };
  7916. exports.regExp = function isRegExp(obj) {
  7917. return obj instanceof RegExp;
  7918. };
  7919. exports.regexp = exports.regExp;
  7920. exports.error = function isError(obj) {
  7921. return obj instanceof Error;
  7922. };
  7923. exports.array = function isArray(obj) {
  7924. return Array.isArray(obj);
  7925. };
  7926. /**
  7927. * transform isNull type to null
  7928. * @param {[type]} m [description]
  7929. * @return {[type]} [description]
  7930. */
  7931. function transform(m) {
  7932. var name = m.slice(2);
  7933. name = name[0].toLowerCase() + name.slice(1);
  7934. return name;
  7935. }
  7936. },{"core-util-is":134,"is-class":151,"isstream":153}],153:[function(require,module,exports){
  7937. var stream = require('stream')
  7938. function isStream (obj) {
  7939. return obj instanceof stream.Stream
  7940. }
  7941. function isReadable (obj) {
  7942. return isStream(obj) && typeof obj._read == 'function' && typeof obj._readableState == 'object'
  7943. }
  7944. function isWritable (obj) {
  7945. return isStream(obj) && typeof obj._write == 'function' && typeof obj._writableState == 'object'
  7946. }
  7947. function isDuplex (obj) {
  7948. return isReadable(obj) && isWritable(obj)
  7949. }
  7950. module.exports = isStream
  7951. module.exports.isReadable = isReadable
  7952. module.exports.isWritable = isWritable
  7953. module.exports.isDuplex = isDuplex
  7954. },{"stream":183}],154:[function(require,module,exports){
  7955. /*!
  7956. * merge-descriptors
  7957. * Copyright(c) 2014 Jonathan Ong
  7958. * Copyright(c) 2015 Douglas Christopher Wilson
  7959. * MIT Licensed
  7960. */
  7961. 'use strict'
  7962. /**
  7963. * Module exports.
  7964. * @public
  7965. */
  7966. module.exports = merge
  7967. /**
  7968. * Module variables.
  7969. * @private
  7970. */
  7971. var hasOwnProperty = Object.prototype.hasOwnProperty
  7972. /**
  7973. * Merge the property descriptors of `src` into `dest`
  7974. *
  7975. * @param {object} dest Object to add descriptors to
  7976. * @param {object} src Object to clone descriptors from
  7977. * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
  7978. * @returns {object} Reference to dest
  7979. * @public
  7980. */
  7981. function merge(dest, src, redefine) {
  7982. if (!dest) {
  7983. throw new TypeError('argument dest is required')
  7984. }
  7985. if (!src) {
  7986. throw new TypeError('argument src is required')
  7987. }
  7988. if (redefine === undefined) {
  7989. // Default to true
  7990. redefine = true
  7991. }
  7992. Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
  7993. if (!redefine && hasOwnProperty.call(dest, name)) {
  7994. // Skip desriptor
  7995. return
  7996. }
  7997. // Copy descriptor
  7998. var descriptor = Object.getOwnPropertyDescriptor(src, name)
  7999. Object.defineProperty(dest, name, descriptor)
  8000. })
  8001. return dest
  8002. }
  8003. },{}],155:[function(require,module,exports){
  8004. /**
  8005. * Helpers.
  8006. */
  8007. var s = 1000;
  8008. var m = s * 60;
  8009. var h = m * 60;
  8010. var d = h * 24;
  8011. var y = d * 365.25;
  8012. /**
  8013. * Parse or format the given `val`.
  8014. *
  8015. * Options:
  8016. *
  8017. * - `long` verbose formatting [false]
  8018. *
  8019. * @param {String|Number} val
  8020. * @param {Object} [options]
  8021. * @throws {Error} throw an error if val is not a non-empty string or a number
  8022. * @return {String|Number}
  8023. * @api public
  8024. */
  8025. module.exports = function(val, options) {
  8026. options = options || {};
  8027. var type = typeof val;
  8028. if (type === 'string' && val.length > 0) {
  8029. return parse(val);
  8030. } else if (type === 'number' && isNaN(val) === false) {
  8031. return options.long ? fmtLong(val) : fmtShort(val);
  8032. }
  8033. throw new Error(
  8034. 'val is not a non-empty string or a valid number. val=' +
  8035. JSON.stringify(val)
  8036. );
  8037. };
  8038. /**
  8039. * Parse the given `str` and return milliseconds.
  8040. *
  8041. * @param {String} str
  8042. * @return {Number}
  8043. * @api private
  8044. */
  8045. function parse(str) {
  8046. str = String(str);
  8047. if (str.length > 100) {
  8048. return;
  8049. }
  8050. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
  8051. str
  8052. );
  8053. if (!match) {
  8054. return;
  8055. }
  8056. var n = parseFloat(match[1]);
  8057. var type = (match[2] || 'ms').toLowerCase();
  8058. switch (type) {
  8059. case 'years':
  8060. case 'year':
  8061. case 'yrs':
  8062. case 'yr':
  8063. case 'y':
  8064. return n * y;
  8065. case 'days':
  8066. case 'day':
  8067. case 'd':
  8068. return n * d;
  8069. case 'hours':
  8070. case 'hour':
  8071. case 'hrs':
  8072. case 'hr':
  8073. case 'h':
  8074. return n * h;
  8075. case 'minutes':
  8076. case 'minute':
  8077. case 'mins':
  8078. case 'min':
  8079. case 'm':
  8080. return n * m;
  8081. case 'seconds':
  8082. case 'second':
  8083. case 'secs':
  8084. case 'sec':
  8085. case 's':
  8086. return n * s;
  8087. case 'milliseconds':
  8088. case 'millisecond':
  8089. case 'msecs':
  8090. case 'msec':
  8091. case 'ms':
  8092. return n;
  8093. default:
  8094. return undefined;
  8095. }
  8096. }
  8097. /**
  8098. * Short format for `ms`.
  8099. *
  8100. * @param {Number} ms
  8101. * @return {String}
  8102. * @api private
  8103. */
  8104. function fmtShort(ms) {
  8105. if (ms >= d) {
  8106. return Math.round(ms / d) + 'd';
  8107. }
  8108. if (ms >= h) {
  8109. return Math.round(ms / h) + 'h';
  8110. }
  8111. if (ms >= m) {
  8112. return Math.round(ms / m) + 'm';
  8113. }
  8114. if (ms >= s) {
  8115. return Math.round(ms / s) + 's';
  8116. }
  8117. return ms + 'ms';
  8118. }
  8119. /**
  8120. * Long format for `ms`.
  8121. *
  8122. * @param {Number} ms
  8123. * @return {String}
  8124. * @api private
  8125. */
  8126. function fmtLong(ms) {
  8127. return plural(ms, d, 'day') ||
  8128. plural(ms, h, 'hour') ||
  8129. plural(ms, m, 'minute') ||
  8130. plural(ms, s, 'second') ||
  8131. ms + ' ms';
  8132. }
  8133. /**
  8134. * Pluralization helper.
  8135. */
  8136. function plural(ms, n, name) {
  8137. if (ms < n) {
  8138. return;
  8139. }
  8140. if (ms < n * 1.5) {
  8141. return Math.floor(ms / n) + ' ' + name;
  8142. }
  8143. return Math.ceil(ms / n) + ' ' + name + 's';
  8144. }
  8145. },{}],156:[function(require,module,exports){
  8146. (function (process){
  8147. // Copyright Joyent, Inc. and other Node contributors.
  8148. //
  8149. // Permission is hereby granted, free of charge, to any person obtaining a
  8150. // copy of this software and associated documentation files (the
  8151. // "Software"), to deal in the Software without restriction, including
  8152. // without limitation the rights to use, copy, modify, merge, publish,
  8153. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8154. // persons to whom the Software is furnished to do so, subject to the
  8155. // following conditions:
  8156. //
  8157. // The above copyright notice and this permission notice shall be included
  8158. // in all copies or substantial portions of the Software.
  8159. //
  8160. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8161. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8162. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8163. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8164. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8165. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8166. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8167. // resolves . and .. elements in a path array with directory names there
  8168. // must be no slashes, empty elements, or device names (c:\) in the array
  8169. // (so also no leading and trailing slashes - it does not distinguish
  8170. // relative and absolute paths)
  8171. function normalizeArray(parts, allowAboveRoot) {
  8172. // if the path tries to go above the root, `up` ends up > 0
  8173. var up = 0;
  8174. for (var i = parts.length - 1; i >= 0; i--) {
  8175. var last = parts[i];
  8176. if (last === '.') {
  8177. parts.splice(i, 1);
  8178. } else if (last === '..') {
  8179. parts.splice(i, 1);
  8180. up++;
  8181. } else if (up) {
  8182. parts.splice(i, 1);
  8183. up--;
  8184. }
  8185. }
  8186. // if the path is allowed to go above the root, restore leading ..s
  8187. if (allowAboveRoot) {
  8188. for (; up--; up) {
  8189. parts.unshift('..');
  8190. }
  8191. }
  8192. return parts;
  8193. }
  8194. // Split a filename into [root, dir, basename, ext], unix version
  8195. // 'root' is just a slash, or nothing.
  8196. var splitPathRe =
  8197. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  8198. var splitPath = function(filename) {
  8199. return splitPathRe.exec(filename).slice(1);
  8200. };
  8201. // path.resolve([from ...], to)
  8202. // posix version
  8203. exports.resolve = function() {
  8204. var resolvedPath = '',
  8205. resolvedAbsolute = false;
  8206. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  8207. var path = (i >= 0) ? arguments[i] : process.cwd();
  8208. // Skip empty and invalid entries
  8209. if (typeof path !== 'string') {
  8210. throw new TypeError('Arguments to path.resolve must be strings');
  8211. } else if (!path) {
  8212. continue;
  8213. }
  8214. resolvedPath = path + '/' + resolvedPath;
  8215. resolvedAbsolute = path.charAt(0) === '/';
  8216. }
  8217. // At this point the path should be resolved to a full absolute path, but
  8218. // handle relative paths to be safe (might happen when process.cwd() fails)
  8219. // Normalize the path
  8220. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  8221. return !!p;
  8222. }), !resolvedAbsolute).join('/');
  8223. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  8224. };
  8225. // path.normalize(path)
  8226. // posix version
  8227. exports.normalize = function(path) {
  8228. var isAbsolute = exports.isAbsolute(path),
  8229. trailingSlash = substr(path, -1) === '/';
  8230. // Normalize the path
  8231. path = normalizeArray(filter(path.split('/'), function(p) {
  8232. return !!p;
  8233. }), !isAbsolute).join('/');
  8234. if (!path && !isAbsolute) {
  8235. path = '.';
  8236. }
  8237. if (path && trailingSlash) {
  8238. path += '/';
  8239. }
  8240. return (isAbsolute ? '/' : '') + path;
  8241. };
  8242. // posix version
  8243. exports.isAbsolute = function(path) {
  8244. return path.charAt(0) === '/';
  8245. };
  8246. // posix version
  8247. exports.join = function() {
  8248. var paths = Array.prototype.slice.call(arguments, 0);
  8249. return exports.normalize(filter(paths, function(p, index) {
  8250. if (typeof p !== 'string') {
  8251. throw new TypeError('Arguments to path.join must be strings');
  8252. }
  8253. return p;
  8254. }).join('/'));
  8255. };
  8256. // path.relative(from, to)
  8257. // posix version
  8258. exports.relative = function(from, to) {
  8259. from = exports.resolve(from).substr(1);
  8260. to = exports.resolve(to).substr(1);
  8261. function trim(arr) {
  8262. var start = 0;
  8263. for (; start < arr.length; start++) {
  8264. if (arr[start] !== '') break;
  8265. }
  8266. var end = arr.length - 1;
  8267. for (; end >= 0; end--) {
  8268. if (arr[end] !== '') break;
  8269. }
  8270. if (start > end) return [];
  8271. return arr.slice(start, end - start + 1);
  8272. }
  8273. var fromParts = trim(from.split('/'));
  8274. var toParts = trim(to.split('/'));
  8275. var length = Math.min(fromParts.length, toParts.length);
  8276. var samePartsLength = length;
  8277. for (var i = 0; i < length; i++) {
  8278. if (fromParts[i] !== toParts[i]) {
  8279. samePartsLength = i;
  8280. break;
  8281. }
  8282. }
  8283. var outputParts = [];
  8284. for (var i = samePartsLength; i < fromParts.length; i++) {
  8285. outputParts.push('..');
  8286. }
  8287. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  8288. return outputParts.join('/');
  8289. };
  8290. exports.sep = '/';
  8291. exports.delimiter = ':';
  8292. exports.dirname = function(path) {
  8293. var result = splitPath(path),
  8294. root = result[0],
  8295. dir = result[1];
  8296. if (!root && !dir) {
  8297. // No dirname whatsoever
  8298. return '.';
  8299. }
  8300. if (dir) {
  8301. // It has a dirname, strip trailing slash
  8302. dir = dir.substr(0, dir.length - 1);
  8303. }
  8304. return root + dir;
  8305. };
  8306. exports.basename = function(path, ext) {
  8307. var f = splitPath(path)[2];
  8308. // TODO: make this comparison case-insensitive on windows?
  8309. if (ext && f.substr(-1 * ext.length) === ext) {
  8310. f = f.substr(0, f.length - ext.length);
  8311. }
  8312. return f;
  8313. };
  8314. exports.extname = function(path) {
  8315. return splitPath(path)[3];
  8316. };
  8317. function filter (xs, f) {
  8318. if (xs.filter) return xs.filter(f);
  8319. var res = [];
  8320. for (var i = 0; i < xs.length; i++) {
  8321. if (f(xs[i], i, xs)) res.push(xs[i]);
  8322. }
  8323. return res;
  8324. }
  8325. // String.prototype.substr - negative index don't work in IE8
  8326. var substr = 'ab'.substr(-1) === 'b'
  8327. ? function (str, start, len) { return str.substr(start, len) }
  8328. : function (str, start, len) {
  8329. if (start < 0) start = str.length + start;
  8330. return str.substr(start, len);
  8331. }
  8332. ;
  8333. }).call(this,require('_process'))
  8334. },{"_process":159}],157:[function(require,module,exports){
  8335. (function (global){
  8336. /*!
  8337. * Platform.js <https://mths.be/platform>
  8338. * Copyright 2014-2016 Benjamin Tan <https://demoneaux.github.io/>
  8339. * Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
  8340. * Available under MIT license <https://mths.be/mit>
  8341. */
  8342. ;(function() {
  8343. 'use strict';
  8344. /** Used to determine if values are of the language type `Object`. */
  8345. var objectTypes = {
  8346. 'function': true,
  8347. 'object': true
  8348. };
  8349. /** Used as a reference to the global object. */
  8350. var root = (objectTypes[typeof window] && window) || this;
  8351. /** Backup possible global object. */
  8352. var oldRoot = root;
  8353. /** Detect free variable `exports`. */
  8354. var freeExports = objectTypes[typeof exports] && exports;
  8355. /** Detect free variable `module`. */
  8356. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  8357. /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
  8358. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
  8359. if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
  8360. root = freeGlobal;
  8361. }
  8362. /**
  8363. * Used as the maximum length of an array-like object.
  8364. * See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
  8365. * for more details.
  8366. */
  8367. var maxSafeInteger = Math.pow(2, 53) - 1;
  8368. /** Regular expression to detect Opera. */
  8369. var reOpera = /\bOpera/;
  8370. /** Possible global object. */
  8371. var thisBinding = this;
  8372. /** Used for native method references. */
  8373. var objectProto = Object.prototype;
  8374. /** Used to check for own properties of an object. */
  8375. var hasOwnProperty = objectProto.hasOwnProperty;
  8376. /** Used to resolve the internal `[[Class]]` of values. */
  8377. var toString = objectProto.toString;
  8378. /*--------------------------------------------------------------------------*/
  8379. /**
  8380. * Capitalizes a string value.
  8381. *
  8382. * @private
  8383. * @param {string} string The string to capitalize.
  8384. * @returns {string} The capitalized string.
  8385. */
  8386. function capitalize(string) {
  8387. string = String(string);
  8388. return string.charAt(0).toUpperCase() + string.slice(1);
  8389. }
  8390. /**
  8391. * A utility function to clean up the OS name.
  8392. *
  8393. * @private
  8394. * @param {string} os The OS name to clean up.
  8395. * @param {string} [pattern] A `RegExp` pattern matching the OS name.
  8396. * @param {string} [label] A label for the OS.
  8397. */
  8398. function cleanupOS(os, pattern, label) {
  8399. // Platform tokens are defined at:
  8400. // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
  8401. // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
  8402. var data = {
  8403. '10.0': '10',
  8404. '6.4': '10 Technical Preview',
  8405. '6.3': '8.1',
  8406. '6.2': '8',
  8407. '6.1': 'Server 2008 R2 / 7',
  8408. '6.0': 'Server 2008 / Vista',
  8409. '5.2': 'Server 2003 / XP 64-bit',
  8410. '5.1': 'XP',
  8411. '5.01': '2000 SP1',
  8412. '5.0': '2000',
  8413. '4.0': 'NT',
  8414. '4.90': 'ME'
  8415. };
  8416. // Detect Windows version from platform tokens.
  8417. if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
  8418. (data = data[/[\d.]+$/.exec(os)])) {
  8419. os = 'Windows ' + data;
  8420. }
  8421. // Correct character case and cleanup string.
  8422. os = String(os);
  8423. if (pattern && label) {
  8424. os = os.replace(RegExp(pattern, 'i'), label);
  8425. }
  8426. os = format(
  8427. os.replace(/ ce$/i, ' CE')
  8428. .replace(/\bhpw/i, 'web')
  8429. .replace(/\bMacintosh\b/, 'Mac OS')
  8430. .replace(/_PowerPC\b/i, ' OS')
  8431. .replace(/\b(OS X) [^ \d]+/i, '$1')
  8432. .replace(/\bMac (OS X)\b/, '$1')
  8433. .replace(/\/(\d)/, ' $1')
  8434. .replace(/_/g, '.')
  8435. .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
  8436. .replace(/\bx86\.64\b/gi, 'x86_64')
  8437. .replace(/\b(Windows Phone) OS\b/, '$1')
  8438. .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
  8439. .split(' on ')[0]
  8440. );
  8441. return os;
  8442. }
  8443. /**
  8444. * An iteration utility for arrays and objects.
  8445. *
  8446. * @private
  8447. * @param {Array|Object} object The object to iterate over.
  8448. * @param {Function} callback The function called per iteration.
  8449. */
  8450. function each(object, callback) {
  8451. var index = -1,
  8452. length = object ? object.length : 0;
  8453. if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
  8454. while (++index < length) {
  8455. callback(object[index], index, object);
  8456. }
  8457. } else {
  8458. forOwn(object, callback);
  8459. }
  8460. }
  8461. /**
  8462. * Trim and conditionally capitalize string values.
  8463. *
  8464. * @private
  8465. * @param {string} string The string to format.
  8466. * @returns {string} The formatted string.
  8467. */
  8468. function format(string) {
  8469. string = trim(string);
  8470. return /^(?:webOS|i(?:OS|P))/.test(string)
  8471. ? string
  8472. : capitalize(string);
  8473. }
  8474. /**
  8475. * Iterates over an object's own properties, executing the `callback` for each.
  8476. *
  8477. * @private
  8478. * @param {Object} object The object to iterate over.
  8479. * @param {Function} callback The function executed per own property.
  8480. */
  8481. function forOwn(object, callback) {
  8482. for (var key in object) {
  8483. if (hasOwnProperty.call(object, key)) {
  8484. callback(object[key], key, object);
  8485. }
  8486. }
  8487. }
  8488. /**
  8489. * Gets the internal `[[Class]]` of a value.
  8490. *
  8491. * @private
  8492. * @param {*} value The value.
  8493. * @returns {string} The `[[Class]]`.
  8494. */
  8495. function getClassOf(value) {
  8496. return value == null
  8497. ? capitalize(value)
  8498. : toString.call(value).slice(8, -1);
  8499. }
  8500. /**
  8501. * Host objects can return type values that are different from their actual
  8502. * data type. The objects we are concerned with usually return non-primitive
  8503. * types of "object", "function", or "unknown".
  8504. *
  8505. * @private
  8506. * @param {*} object The owner of the property.
  8507. * @param {string} property The property to check.
  8508. * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
  8509. */
  8510. function isHostType(object, property) {
  8511. var type = object != null ? typeof object[property] : 'number';
  8512. return !/^(?:boolean|number|string|undefined)$/.test(type) &&
  8513. (type == 'object' ? !!object[property] : true);
  8514. }
  8515. /**
  8516. * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
  8517. *
  8518. * @private
  8519. * @param {string} string The string to qualify.
  8520. * @returns {string} The qualified string.
  8521. */
  8522. function qualify(string) {
  8523. return String(string).replace(/([ -])(?!$)/g, '$1?');
  8524. }
  8525. /**
  8526. * A bare-bones `Array#reduce` like utility function.
  8527. *
  8528. * @private
  8529. * @param {Array} array The array to iterate over.
  8530. * @param {Function} callback The function called per iteration.
  8531. * @returns {*} The accumulated result.
  8532. */
  8533. function reduce(array, callback) {
  8534. var accumulator = null;
  8535. each(array, function(value, index) {
  8536. accumulator = callback(accumulator, value, index, array);
  8537. });
  8538. return accumulator;
  8539. }
  8540. /**
  8541. * Removes leading and trailing whitespace from a string.
  8542. *
  8543. * @private
  8544. * @param {string} string The string to trim.
  8545. * @returns {string} The trimmed string.
  8546. */
  8547. function trim(string) {
  8548. return String(string).replace(/^ +| +$/g, '');
  8549. }
  8550. /*--------------------------------------------------------------------------*/
  8551. /**
  8552. * Creates a new platform object.
  8553. *
  8554. * @memberOf platform
  8555. * @param {Object|string} [ua=navigator.userAgent] The user agent string or
  8556. * context object.
  8557. * @returns {Object} A platform object.
  8558. */
  8559. function parse(ua) {
  8560. /** The environment context object. */
  8561. var context = root;
  8562. /** Used to flag when a custom context is provided. */
  8563. var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
  8564. // Juggle arguments.
  8565. if (isCustomContext) {
  8566. context = ua;
  8567. ua = null;
  8568. }
  8569. /** Browser navigator object. */
  8570. var nav = context.navigator || {};
  8571. /** Browser user agent string. */
  8572. var userAgent = nav.userAgent || '';
  8573. ua || (ua = userAgent);
  8574. /** Used to flag when `thisBinding` is the [ModuleScope]. */
  8575. var isModuleScope = isCustomContext || thisBinding == oldRoot;
  8576. /** Used to detect if browser is like Chrome. */
  8577. var likeChrome = isCustomContext
  8578. ? !!nav.likeChrome
  8579. : /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
  8580. /** Internal `[[Class]]` value shortcuts. */
  8581. var objectClass = 'Object',
  8582. airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
  8583. enviroClass = isCustomContext ? objectClass : 'Environment',
  8584. javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
  8585. phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
  8586. /** Detect Java environments. */
  8587. var java = /\bJava/.test(javaClass) && context.java;
  8588. /** Detect Rhino. */
  8589. var rhino = java && getClassOf(context.environment) == enviroClass;
  8590. /** A character to represent alpha. */
  8591. var alpha = java ? 'a' : '\u03b1';
  8592. /** A character to represent beta. */
  8593. var beta = java ? 'b' : '\u03b2';
  8594. /** Browser document object. */
  8595. var doc = context.document || {};
  8596. /**
  8597. * Detect Opera browser (Presto-based).
  8598. * http://www.howtocreate.co.uk/operaStuff/operaObject.html
  8599. * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
  8600. */
  8601. var opera = context.operamini || context.opera;
  8602. /** Opera `[[Class]]`. */
  8603. var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
  8604. ? operaClass
  8605. : (opera = null);
  8606. /*------------------------------------------------------------------------*/
  8607. /** Temporary variable used over the script's lifetime. */
  8608. var data;
  8609. /** The CPU architecture. */
  8610. var arch = ua;
  8611. /** Platform description array. */
  8612. var description = [];
  8613. /** Platform alpha/beta indicator. */
  8614. var prerelease = null;
  8615. /** A flag to indicate that environment features should be used to resolve the platform. */
  8616. var useFeatures = ua == userAgent;
  8617. /** The browser/environment version. */
  8618. var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
  8619. /** A flag to indicate if the OS ends with "/ Version" */
  8620. var isSpecialCasedOS;
  8621. /* Detectable layout engines (order is important). */
  8622. var layout = getLayout([
  8623. { 'label': 'EdgeHTML', 'pattern': 'Edge' },
  8624. 'Trident',
  8625. { 'label': 'WebKit', 'pattern': 'AppleWebKit' },
  8626. 'iCab',
  8627. 'Presto',
  8628. 'NetFront',
  8629. 'Tasman',
  8630. 'KHTML',
  8631. 'Gecko'
  8632. ]);
  8633. /* Detectable browser names (order is important). */
  8634. var name = getName([
  8635. 'Adobe AIR',
  8636. 'Arora',
  8637. 'Avant Browser',
  8638. 'Breach',
  8639. 'Camino',
  8640. 'Electron',
  8641. 'Epiphany',
  8642. 'Fennec',
  8643. 'Flock',
  8644. 'Galeon',
  8645. 'GreenBrowser',
  8646. 'iCab',
  8647. 'Iceweasel',
  8648. 'K-Meleon',
  8649. 'Konqueror',
  8650. 'Lunascape',
  8651. 'Maxthon',
  8652. { 'label': 'Microsoft Edge', 'pattern': 'Edge' },
  8653. 'Midori',
  8654. 'Nook Browser',
  8655. 'PaleMoon',
  8656. 'PhantomJS',
  8657. 'Raven',
  8658. 'Rekonq',
  8659. 'RockMelt',
  8660. { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
  8661. 'SeaMonkey',
  8662. { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
  8663. 'Sleipnir',
  8664. 'SlimBrowser',
  8665. { 'label': 'SRWare Iron', 'pattern': 'Iron' },
  8666. 'Sunrise',
  8667. 'Swiftfox',
  8668. 'Waterfox',
  8669. 'WebPositive',
  8670. 'Opera Mini',
  8671. { 'label': 'Opera Mini', 'pattern': 'OPiOS' },
  8672. 'Opera',
  8673. { 'label': 'Opera', 'pattern': 'OPR' },
  8674. 'Chrome',
  8675. { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
  8676. { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
  8677. { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
  8678. { 'label': 'IE', 'pattern': 'IEMobile' },
  8679. { 'label': 'IE', 'pattern': 'MSIE' },
  8680. 'Safari'
  8681. ]);
  8682. /* Detectable products (order is important). */
  8683. var product = getProduct([
  8684. { 'label': 'BlackBerry', 'pattern': 'BB10' },
  8685. 'BlackBerry',
  8686. { 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
  8687. { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
  8688. { 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
  8689. { 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
  8690. { 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
  8691. { 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
  8692. { 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
  8693. { 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
  8694. { 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
  8695. 'Google TV',
  8696. 'Lumia',
  8697. 'iPad',
  8698. 'iPod',
  8699. 'iPhone',
  8700. 'Kindle',
  8701. { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
  8702. 'Nexus',
  8703. 'Nook',
  8704. 'PlayBook',
  8705. 'PlayStation Vita',
  8706. 'PlayStation',
  8707. 'TouchPad',
  8708. 'Transformer',
  8709. { 'label': 'Wii U', 'pattern': 'WiiU' },
  8710. 'Wii',
  8711. 'Xbox One',
  8712. { 'label': 'Xbox 360', 'pattern': 'Xbox' },
  8713. 'Xoom'
  8714. ]);
  8715. /* Detectable manufacturers. */
  8716. var manufacturer = getManufacturer({
  8717. 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
  8718. 'Archos': {},
  8719. 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
  8720. 'Asus': { 'Transformer': 1 },
  8721. 'Barnes & Noble': { 'Nook': 1 },
  8722. 'BlackBerry': { 'PlayBook': 1 },
  8723. 'Google': { 'Google TV': 1, 'Nexus': 1 },
  8724. 'HP': { 'TouchPad': 1 },
  8725. 'HTC': {},
  8726. 'LG': {},
  8727. 'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
  8728. 'Motorola': { 'Xoom': 1 },
  8729. 'Nintendo': { 'Wii U': 1, 'Wii': 1 },
  8730. 'Nokia': { 'Lumia': 1 },
  8731. 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
  8732. 'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 }
  8733. });
  8734. /* Detectable operating systems (order is important). */
  8735. var os = getOS([
  8736. 'Windows Phone',
  8737. 'Android',
  8738. 'CentOS',
  8739. { 'label': 'Chrome OS', 'pattern': 'CrOS' },
  8740. 'Debian',
  8741. 'Fedora',
  8742. 'FreeBSD',
  8743. 'Gentoo',
  8744. 'Haiku',
  8745. 'Kubuntu',
  8746. 'Linux Mint',
  8747. 'OpenBSD',
  8748. 'Red Hat',
  8749. 'SuSE',
  8750. 'Ubuntu',
  8751. 'Xubuntu',
  8752. 'Cygwin',
  8753. 'Symbian OS',
  8754. 'hpwOS',
  8755. 'webOS ',
  8756. 'webOS',
  8757. 'Tablet OS',
  8758. 'Tizen',
  8759. 'Linux',
  8760. 'Mac OS X',
  8761. 'Macintosh',
  8762. 'Mac',
  8763. 'Windows 98;',
  8764. 'Windows '
  8765. ]);
  8766. /*------------------------------------------------------------------------*/
  8767. /**
  8768. * Picks the layout engine from an array of guesses.
  8769. *
  8770. * @private
  8771. * @param {Array} guesses An array of guesses.
  8772. * @returns {null|string} The detected layout engine.
  8773. */
  8774. function getLayout(guesses) {
  8775. return reduce(guesses, function(result, guess) {
  8776. return result || RegExp('\\b' + (
  8777. guess.pattern || qualify(guess)
  8778. ) + '\\b', 'i').exec(ua) && (guess.label || guess);
  8779. });
  8780. }
  8781. /**
  8782. * Picks the manufacturer from an array of guesses.
  8783. *
  8784. * @private
  8785. * @param {Array} guesses An object of guesses.
  8786. * @returns {null|string} The detected manufacturer.
  8787. */
  8788. function getManufacturer(guesses) {
  8789. return reduce(guesses, function(result, value, key) {
  8790. // Lookup the manufacturer by product or scan the UA for the manufacturer.
  8791. return result || (
  8792. value[product] ||
  8793. value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
  8794. RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
  8795. ) && key;
  8796. });
  8797. }
  8798. /**
  8799. * Picks the browser name from an array of guesses.
  8800. *
  8801. * @private
  8802. * @param {Array} guesses An array of guesses.
  8803. * @returns {null|string} The detected browser name.
  8804. */
  8805. function getName(guesses) {
  8806. return reduce(guesses, function(result, guess) {
  8807. return result || RegExp('\\b' + (
  8808. guess.pattern || qualify(guess)
  8809. ) + '\\b', 'i').exec(ua) && (guess.label || guess);
  8810. });
  8811. }
  8812. /**
  8813. * Picks the OS name from an array of guesses.
  8814. *
  8815. * @private
  8816. * @param {Array} guesses An array of guesses.
  8817. * @returns {null|string} The detected OS name.
  8818. */
  8819. function getOS(guesses) {
  8820. return reduce(guesses, function(result, guess) {
  8821. var pattern = guess.pattern || qualify(guess);
  8822. if (!result && (result =
  8823. RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
  8824. )) {
  8825. result = cleanupOS(result, pattern, guess.label || guess);
  8826. }
  8827. return result;
  8828. });
  8829. }
  8830. /**
  8831. * Picks the product name from an array of guesses.
  8832. *
  8833. * @private
  8834. * @param {Array} guesses An array of guesses.
  8835. * @returns {null|string} The detected product name.
  8836. */
  8837. function getProduct(guesses) {
  8838. return reduce(guesses, function(result, guess) {
  8839. var pattern = guess.pattern || qualify(guess);
  8840. if (!result && (result =
  8841. RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
  8842. RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
  8843. RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
  8844. )) {
  8845. // Split by forward slash and append product version if needed.
  8846. if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
  8847. result[0] += ' ' + result[1];
  8848. }
  8849. // Correct character case and cleanup string.
  8850. guess = guess.label || guess;
  8851. result = format(result[0]
  8852. .replace(RegExp(pattern, 'i'), guess)
  8853. .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
  8854. .replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
  8855. }
  8856. return result;
  8857. });
  8858. }
  8859. /**
  8860. * Resolves the version using an array of UA patterns.
  8861. *
  8862. * @private
  8863. * @param {Array} patterns An array of UA patterns.
  8864. * @returns {null|string} The detected version.
  8865. */
  8866. function getVersion(patterns) {
  8867. return reduce(patterns, function(result, pattern) {
  8868. return result || (RegExp(pattern +
  8869. '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
  8870. });
  8871. }
  8872. /**
  8873. * Returns `platform.description` when the platform object is coerced to a string.
  8874. *
  8875. * @name toString
  8876. * @memberOf platform
  8877. * @returns {string} Returns `platform.description` if available, else an empty string.
  8878. */
  8879. function toStringPlatform() {
  8880. return this.description || '';
  8881. }
  8882. /*------------------------------------------------------------------------*/
  8883. // Convert layout to an array so we can add extra details.
  8884. layout && (layout = [layout]);
  8885. // Detect product names that contain their manufacturer's name.
  8886. if (manufacturer && !product) {
  8887. product = getProduct([manufacturer]);
  8888. }
  8889. // Clean up Google TV.
  8890. if ((data = /\bGoogle TV\b/.exec(product))) {
  8891. product = data[0];
  8892. }
  8893. // Detect simulators.
  8894. if (/\bSimulator\b/i.test(ua)) {
  8895. product = (product ? product + ' ' : '') + 'Simulator';
  8896. }
  8897. // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
  8898. if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
  8899. description.push('running in Turbo/Uncompressed mode');
  8900. }
  8901. // Detect IE Mobile 11.
  8902. if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
  8903. data = parse(ua.replace(/like iPhone OS/, ''));
  8904. manufacturer = data.manufacturer;
  8905. product = data.product;
  8906. }
  8907. // Detect iOS.
  8908. else if (/^iP/.test(product)) {
  8909. name || (name = 'Safari');
  8910. os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
  8911. ? ' ' + data[1].replace(/_/g, '.')
  8912. : '');
  8913. }
  8914. // Detect Kubuntu.
  8915. else if (name == 'Konqueror' && !/buntu/i.test(os)) {
  8916. os = 'Kubuntu';
  8917. }
  8918. // Detect Android browsers.
  8919. else if ((manufacturer && manufacturer != 'Google' &&
  8920. ((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
  8921. (/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
  8922. name = 'Android Browser';
  8923. os = /\bAndroid\b/.test(os) ? os : 'Android';
  8924. }
  8925. // Detect Silk desktop/accelerated modes.
  8926. else if (name == 'Silk') {
  8927. if (!/\bMobi/i.test(ua)) {
  8928. os = 'Android';
  8929. description.unshift('desktop mode');
  8930. }
  8931. if (/Accelerated *= *true/i.test(ua)) {
  8932. description.unshift('accelerated');
  8933. }
  8934. }
  8935. // Detect PaleMoon identifying as Firefox.
  8936. else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
  8937. description.push('identifying as Firefox ' + data[1]);
  8938. }
  8939. // Detect Firefox OS and products running Firefox.
  8940. else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
  8941. os || (os = 'Firefox OS');
  8942. product || (product = data[1]);
  8943. }
  8944. // Detect false positives for Firefox/Safari.
  8945. else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
  8946. // Escape the `/` for Firefox 1.
  8947. if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
  8948. // Clear name of false positives.
  8949. name = null;
  8950. }
  8951. // Reassign a generic name.
  8952. if ((data = product || manufacturer || os) &&
  8953. (product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
  8954. name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
  8955. }
  8956. }
  8957. // Add Chrome version to description for Electron.
  8958. else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
  8959. description.push('Chromium ' + data);
  8960. }
  8961. // Detect non-Opera (Presto-based) versions (order is important).
  8962. if (!version) {
  8963. version = getVersion([
  8964. '(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
  8965. 'Version',
  8966. qualify(name),
  8967. '(?:Firefox|Minefield|NetFront)'
  8968. ]);
  8969. }
  8970. // Detect stubborn layout engines.
  8971. if ((data =
  8972. layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
  8973. /\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
  8974. /\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
  8975. !layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
  8976. layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
  8977. )) {
  8978. layout = [data];
  8979. }
  8980. // Detect Windows Phone 7 desktop mode.
  8981. if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
  8982. name += ' Mobile';
  8983. os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
  8984. description.unshift('desktop mode');
  8985. }
  8986. // Detect Windows Phone 8.x desktop mode.
  8987. else if (/\bWPDesktop\b/i.test(ua)) {
  8988. name = 'IE Mobile';
  8989. os = 'Windows Phone 8.x';
  8990. description.unshift('desktop mode');
  8991. version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
  8992. }
  8993. // Detect IE 11 identifying as other browsers.
  8994. else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
  8995. if (name) {
  8996. description.push('identifying as ' + name + (version ? ' ' + version : ''));
  8997. }
  8998. name = 'IE';
  8999. version = data[1];
  9000. }
  9001. // Leverage environment features.
  9002. if (useFeatures) {
  9003. // Detect server-side environments.
  9004. // Rhino has a global function while others have a global object.
  9005. if (isHostType(context, 'global')) {
  9006. if (java) {
  9007. data = java.lang.System;
  9008. arch = data.getProperty('os.arch');
  9009. os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
  9010. }
  9011. if (isModuleScope && isHostType(context, 'system') && (data = [context.system])[0]) {
  9012. os || (os = data[0].os || null);
  9013. try {
  9014. data[1] = context.require('ringo/engine').version;
  9015. version = data[1].join('.');
  9016. name = 'RingoJS';
  9017. } catch(e) {
  9018. if (data[0].global.system == context.system) {
  9019. name = 'Narwhal';
  9020. }
  9021. }
  9022. }
  9023. else if (
  9024. typeof context.process == 'object' && !context.process.browser &&
  9025. (data = context.process)
  9026. ) {
  9027. if (typeof data.versions == 'object') {
  9028. if (typeof data.versions.electron == 'string') {
  9029. description.push('Node ' + data.versions.node);
  9030. name = 'Electron';
  9031. version = data.versions.electron;
  9032. } else if (typeof data.versions.nw == 'string') {
  9033. description.push('Chromium ' + version, 'Node ' + data.versions.node);
  9034. name = 'NW.js';
  9035. version = data.versions.nw;
  9036. }
  9037. } else {
  9038. name = 'Node.js';
  9039. arch = data.arch;
  9040. os = data.platform;
  9041. version = /[\d.]+/.exec(data.version)
  9042. version = version ? version[0] : 'unknown';
  9043. }
  9044. }
  9045. else if (rhino) {
  9046. name = 'Rhino';
  9047. }
  9048. }
  9049. // Detect Adobe AIR.
  9050. else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
  9051. name = 'Adobe AIR';
  9052. os = data.flash.system.Capabilities.os;
  9053. }
  9054. // Detect PhantomJS.
  9055. else if (getClassOf((data = context.phantom)) == phantomClass) {
  9056. name = 'PhantomJS';
  9057. version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
  9058. }
  9059. // Detect IE compatibility modes.
  9060. else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
  9061. // We're in compatibility mode when the Trident version + 4 doesn't
  9062. // equal the document mode.
  9063. version = [version, doc.documentMode];
  9064. if ((data = +data[1] + 4) != version[1]) {
  9065. description.push('IE ' + version[1] + ' mode');
  9066. layout && (layout[1] = '');
  9067. version[1] = data;
  9068. }
  9069. version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
  9070. }
  9071. // Detect IE 11 masking as other browsers.
  9072. else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
  9073. description.push('masking as ' + name + ' ' + version);
  9074. name = 'IE';
  9075. version = '11.0';
  9076. layout = ['Trident'];
  9077. os = 'Windows';
  9078. }
  9079. os = os && format(os);
  9080. }
  9081. // Detect prerelease phases.
  9082. if (version && (data =
  9083. /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
  9084. /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
  9085. /\bMinefield\b/i.test(ua) && 'a'
  9086. )) {
  9087. prerelease = /b/i.test(data) ? 'beta' : 'alpha';
  9088. version = version.replace(RegExp(data + '\\+?$'), '') +
  9089. (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
  9090. }
  9091. // Detect Firefox Mobile.
  9092. if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS)\b/.test(os)) {
  9093. name = 'Firefox Mobile';
  9094. }
  9095. // Obscure Maxthon's unreliable version.
  9096. else if (name == 'Maxthon' && version) {
  9097. version = version.replace(/\.[\d.]+/, '.x');
  9098. }
  9099. // Detect Xbox 360 and Xbox One.
  9100. else if (/\bXbox\b/i.test(product)) {
  9101. if (product == 'Xbox 360') {
  9102. os = null;
  9103. }
  9104. if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
  9105. description.unshift('mobile mode');
  9106. }
  9107. }
  9108. // Add mobile postfix.
  9109. else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
  9110. (os == 'Windows CE' || /Mobi/i.test(ua))) {
  9111. name += ' Mobile';
  9112. }
  9113. // Detect IE platform preview.
  9114. else if (name == 'IE' && useFeatures) {
  9115. try {
  9116. if (context.external === null) {
  9117. description.unshift('platform preview');
  9118. }
  9119. } catch(e) {
  9120. description.unshift('embedded');
  9121. }
  9122. }
  9123. // Detect BlackBerry OS version.
  9124. // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
  9125. else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
  9126. (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
  9127. version
  9128. )) {
  9129. data = [data, /BB10/.test(ua)];
  9130. os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
  9131. version = null;
  9132. }
  9133. // Detect Opera identifying/masking itself as another browser.
  9134. // http://www.opera.com/support/kb/view/843/
  9135. else if (this != forOwn && product != 'Wii' && (
  9136. (useFeatures && opera) ||
  9137. (/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
  9138. (name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
  9139. (name == 'IE' && (
  9140. (os && !/^Win/.test(os) && version > 5.5) ||
  9141. /\bWindows XP\b/.test(os) && version > 8 ||
  9142. version == 8 && !/\bTrident\b/.test(ua)
  9143. ))
  9144. ) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
  9145. // When "identifying", the UA contains both Opera and the other browser's name.
  9146. data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
  9147. if (reOpera.test(name)) {
  9148. if (/\bIE\b/.test(data) && os == 'Mac OS') {
  9149. os = null;
  9150. }
  9151. data = 'identify' + data;
  9152. }
  9153. // When "masking", the UA contains only the other browser's name.
  9154. else {
  9155. data = 'mask' + data;
  9156. if (operaClass) {
  9157. name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
  9158. } else {
  9159. name = 'Opera';
  9160. }
  9161. if (/\bIE\b/.test(data)) {
  9162. os = null;
  9163. }
  9164. if (!useFeatures) {
  9165. version = null;
  9166. }
  9167. }
  9168. layout = ['Presto'];
  9169. description.push(data);
  9170. }
  9171. // Detect WebKit Nightly and approximate Chrome/Safari versions.
  9172. if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
  9173. // Correct build number for numeric comparison.
  9174. // (e.g. "532.5" becomes "532.05")
  9175. data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
  9176. // Nightly builds are postfixed with a "+".
  9177. if (name == 'Safari' && data[1].slice(-1) == '+') {
  9178. name = 'WebKit Nightly';
  9179. prerelease = 'alpha';
  9180. version = data[1].slice(0, -1);
  9181. }
  9182. // Clear incorrect browser versions.
  9183. else if (version == data[1] ||
  9184. version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
  9185. version = null;
  9186. }
  9187. // Use the full Chrome version when available.
  9188. data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
  9189. // Detect Blink layout engine.
  9190. if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
  9191. layout = ['Blink'];
  9192. }
  9193. // Detect JavaScriptCore.
  9194. // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
  9195. if (!useFeatures || (!likeChrome && !data[1])) {
  9196. layout && (layout[1] = 'like Safari');
  9197. data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : '8');
  9198. } else {
  9199. layout && (layout[1] = 'like Chrome');
  9200. data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
  9201. }
  9202. // Add the postfix of ".x" or "+" for approximate versions.
  9203. layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
  9204. // Obscure version for some Safari 1-2 releases.
  9205. if (name == 'Safari' && (!version || parseInt(version) > 45)) {
  9206. version = data;
  9207. }
  9208. }
  9209. // Detect Opera desktop modes.
  9210. if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
  9211. name += ' ';
  9212. description.unshift('desktop mode');
  9213. if (data == 'zvav') {
  9214. name += 'Mini';
  9215. version = null;
  9216. } else {
  9217. name += 'Mobile';
  9218. }
  9219. os = os.replace(RegExp(' *' + data + '$'), '');
  9220. }
  9221. // Detect Chrome desktop mode.
  9222. else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
  9223. description.unshift('desktop mode');
  9224. name = 'Chrome Mobile';
  9225. version = null;
  9226. if (/\bOS X\b/.test(os)) {
  9227. manufacturer = 'Apple';
  9228. os = 'iOS 4.3+';
  9229. } else {
  9230. os = null;
  9231. }
  9232. }
  9233. // Strip incorrect OS versions.
  9234. if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
  9235. ua.indexOf('/' + data + '-') > -1) {
  9236. os = trim(os.replace(data, ''));
  9237. }
  9238. // Add layout engine.
  9239. if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
  9240. /Browser|Lunascape|Maxthon/.test(name) ||
  9241. name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
  9242. /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(name) && layout[1])) {
  9243. // Don't add layout details to description if they are falsey.
  9244. (data = layout[layout.length - 1]) && description.push(data);
  9245. }
  9246. // Combine contextual information.
  9247. if (description.length) {
  9248. description = ['(' + description.join('; ') + ')'];
  9249. }
  9250. // Append manufacturer to description.
  9251. if (manufacturer && product && product.indexOf(manufacturer) < 0) {
  9252. description.push('on ' + manufacturer);
  9253. }
  9254. // Append product to description.
  9255. if (product) {
  9256. description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
  9257. }
  9258. // Parse the OS into an object.
  9259. if (os) {
  9260. data = / ([\d.+]+)$/.exec(os);
  9261. isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
  9262. os = {
  9263. 'architecture': 32,
  9264. 'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
  9265. 'version': data ? data[1] : null,
  9266. 'toString': function() {
  9267. var version = this.version;
  9268. return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
  9269. }
  9270. };
  9271. }
  9272. // Add browser/OS architecture.
  9273. if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
  9274. if (os) {
  9275. os.architecture = 64;
  9276. os.family = os.family.replace(RegExp(' *' + data), '');
  9277. }
  9278. if (
  9279. name && (/\bWOW64\b/i.test(ua) ||
  9280. (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
  9281. ) {
  9282. description.unshift('32-bit');
  9283. }
  9284. }
  9285. // Chrome 39 and above on OS X is always 64-bit.
  9286. else if (
  9287. os && /^OS X/.test(os.family) &&
  9288. name == 'Chrome' && parseFloat(version) >= 39
  9289. ) {
  9290. os.architecture = 64;
  9291. }
  9292. ua || (ua = null);
  9293. /*------------------------------------------------------------------------*/
  9294. /**
  9295. * The platform object.
  9296. *
  9297. * @name platform
  9298. * @type Object
  9299. */
  9300. var platform = {};
  9301. /**
  9302. * The platform description.
  9303. *
  9304. * @memberOf platform
  9305. * @type string|null
  9306. */
  9307. platform.description = ua;
  9308. /**
  9309. * The name of the browser's layout engine.
  9310. *
  9311. * The list of common layout engines include:
  9312. * "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
  9313. *
  9314. * @memberOf platform
  9315. * @type string|null
  9316. */
  9317. platform.layout = layout && layout[0];
  9318. /**
  9319. * The name of the product's manufacturer.
  9320. *
  9321. * The list of manufacturers include:
  9322. * "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
  9323. * "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
  9324. * "Nokia", "Samsung" and "Sony"
  9325. *
  9326. * @memberOf platform
  9327. * @type string|null
  9328. */
  9329. platform.manufacturer = manufacturer;
  9330. /**
  9331. * The name of the browser/environment.
  9332. *
  9333. * The list of common browser names include:
  9334. * "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
  9335. * "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
  9336. * "Opera Mini" and "Opera"
  9337. *
  9338. * Mobile versions of some browsers have "Mobile" appended to their name:
  9339. * eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
  9340. *
  9341. * @memberOf platform
  9342. * @type string|null
  9343. */
  9344. platform.name = name;
  9345. /**
  9346. * The alpha/beta release indicator.
  9347. *
  9348. * @memberOf platform
  9349. * @type string|null
  9350. */
  9351. platform.prerelease = prerelease;
  9352. /**
  9353. * The name of the product hosting the browser.
  9354. *
  9355. * The list of common products include:
  9356. *
  9357. * "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
  9358. * "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
  9359. *
  9360. * @memberOf platform
  9361. * @type string|null
  9362. */
  9363. platform.product = product;
  9364. /**
  9365. * The browser's user agent string.
  9366. *
  9367. * @memberOf platform
  9368. * @type string|null
  9369. */
  9370. platform.ua = ua;
  9371. /**
  9372. * The browser/environment version.
  9373. *
  9374. * @memberOf platform
  9375. * @type string|null
  9376. */
  9377. platform.version = name && version;
  9378. /**
  9379. * The name of the operating system.
  9380. *
  9381. * @memberOf platform
  9382. * @type Object
  9383. */
  9384. platform.os = os || {
  9385. /**
  9386. * The CPU architecture the OS is built for.
  9387. *
  9388. * @memberOf platform.os
  9389. * @type number|null
  9390. */
  9391. 'architecture': null,
  9392. /**
  9393. * The family of the OS.
  9394. *
  9395. * Common values include:
  9396. * "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
  9397. * "Windows XP", "OS X", "Ubuntu", "Debian", "Fedora", "Red Hat", "SuSE",
  9398. * "Android", "iOS" and "Windows Phone"
  9399. *
  9400. * @memberOf platform.os
  9401. * @type string|null
  9402. */
  9403. 'family': null,
  9404. /**
  9405. * The version of the OS.
  9406. *
  9407. * @memberOf platform.os
  9408. * @type string|null
  9409. */
  9410. 'version': null,
  9411. /**
  9412. * Returns the OS string.
  9413. *
  9414. * @memberOf platform.os
  9415. * @returns {string} The OS string.
  9416. */
  9417. 'toString': function() { return 'null'; }
  9418. };
  9419. platform.parse = parse;
  9420. platform.toString = toStringPlatform;
  9421. if (platform.version) {
  9422. description.unshift(version);
  9423. }
  9424. if (platform.name) {
  9425. description.unshift(name);
  9426. }
  9427. if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
  9428. description.push(product ? '(' + os + ')' : 'on ' + os);
  9429. }
  9430. if (description.length) {
  9431. platform.description = description.join(' ');
  9432. }
  9433. return platform;
  9434. }
  9435. /*--------------------------------------------------------------------------*/
  9436. // Export platform.
  9437. var platform = parse();
  9438. // Some AMD build optimizers, like r.js, check for condition patterns like the following:
  9439. if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
  9440. // Expose platform on the global object to prevent errors when platform is
  9441. // loaded by a script tag in the presence of an AMD loader.
  9442. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  9443. root.platform = platform;
  9444. // Define as an anonymous module so platform can be aliased through path mapping.
  9445. define(function() {
  9446. return platform;
  9447. });
  9448. }
  9449. // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
  9450. else if (freeExports && freeModule) {
  9451. // Export for CommonJS support.
  9452. forOwn(platform, function(value, key) {
  9453. freeExports[key] = value;
  9454. });
  9455. }
  9456. else {
  9457. // Export to the global object.
  9458. root.platform = platform;
  9459. }
  9460. }.call(this));
  9461. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  9462. },{}],158:[function(require,module,exports){
  9463. (function (process){
  9464. 'use strict';
  9465. if (!process.version ||
  9466. process.version.indexOf('v0.') === 0 ||
  9467. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  9468. module.exports = nextTick;
  9469. } else {
  9470. module.exports = process.nextTick;
  9471. }
  9472. function nextTick(fn, arg1, arg2, arg3) {
  9473. if (typeof fn !== 'function') {
  9474. throw new TypeError('"callback" argument must be a function');
  9475. }
  9476. var len = arguments.length;
  9477. var args, i;
  9478. switch (len) {
  9479. case 0:
  9480. case 1:
  9481. return process.nextTick(fn);
  9482. case 2:
  9483. return process.nextTick(function afterTickOne() {
  9484. fn.call(null, arg1);
  9485. });
  9486. case 3:
  9487. return process.nextTick(function afterTickTwo() {
  9488. fn.call(null, arg1, arg2);
  9489. });
  9490. case 4:
  9491. return process.nextTick(function afterTickThree() {
  9492. fn.call(null, arg1, arg2, arg3);
  9493. });
  9494. default:
  9495. args = new Array(len - 1);
  9496. i = 0;
  9497. while (i < args.length) {
  9498. args[i++] = arguments[i];
  9499. }
  9500. return process.nextTick(function afterTick() {
  9501. fn.apply(null, args);
  9502. });
  9503. }
  9504. }
  9505. }).call(this,require('_process'))
  9506. },{"_process":159}],159:[function(require,module,exports){
  9507. // shim for using process in browser
  9508. var process = module.exports = {};
  9509. // cached from whatever global is present so that test runners that stub it
  9510. // don't break things. But we need to wrap it in a try catch in case it is
  9511. // wrapped in strict mode code which doesn't define any globals. It's inside a
  9512. // function because try/catches deoptimize in certain engines.
  9513. var cachedSetTimeout;
  9514. var cachedClearTimeout;
  9515. function defaultSetTimout() {
  9516. throw new Error('setTimeout has not been defined');
  9517. }
  9518. function defaultClearTimeout () {
  9519. throw new Error('clearTimeout has not been defined');
  9520. }
  9521. (function () {
  9522. try {
  9523. if (typeof setTimeout === 'function') {
  9524. cachedSetTimeout = setTimeout;
  9525. } else {
  9526. cachedSetTimeout = defaultSetTimout;
  9527. }
  9528. } catch (e) {
  9529. cachedSetTimeout = defaultSetTimout;
  9530. }
  9531. try {
  9532. if (typeof clearTimeout === 'function') {
  9533. cachedClearTimeout = clearTimeout;
  9534. } else {
  9535. cachedClearTimeout = defaultClearTimeout;
  9536. }
  9537. } catch (e) {
  9538. cachedClearTimeout = defaultClearTimeout;
  9539. }
  9540. } ())
  9541. function runTimeout(fun) {
  9542. if (cachedSetTimeout === setTimeout) {
  9543. //normal enviroments in sane situations
  9544. return setTimeout(fun, 0);
  9545. }
  9546. // if setTimeout wasn't available but was latter defined
  9547. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  9548. cachedSetTimeout = setTimeout;
  9549. return setTimeout(fun, 0);
  9550. }
  9551. try {
  9552. // when when somebody has screwed with setTimeout but no I.E. maddness
  9553. return cachedSetTimeout(fun, 0);
  9554. } catch(e){
  9555. try {
  9556. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  9557. return cachedSetTimeout.call(null, fun, 0);
  9558. } catch(e){
  9559. // 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
  9560. return cachedSetTimeout.call(this, fun, 0);
  9561. }
  9562. }
  9563. }
  9564. function runClearTimeout(marker) {
  9565. if (cachedClearTimeout === clearTimeout) {
  9566. //normal enviroments in sane situations
  9567. return clearTimeout(marker);
  9568. }
  9569. // if clearTimeout wasn't available but was latter defined
  9570. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  9571. cachedClearTimeout = clearTimeout;
  9572. return clearTimeout(marker);
  9573. }
  9574. try {
  9575. // when when somebody has screwed with setTimeout but no I.E. maddness
  9576. return cachedClearTimeout(marker);
  9577. } catch (e){
  9578. try {
  9579. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  9580. return cachedClearTimeout.call(null, marker);
  9581. } catch (e){
  9582. // 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.
  9583. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  9584. return cachedClearTimeout.call(this, marker);
  9585. }
  9586. }
  9587. }
  9588. var queue = [];
  9589. var draining = false;
  9590. var currentQueue;
  9591. var queueIndex = -1;
  9592. function cleanUpNextTick() {
  9593. if (!draining || !currentQueue) {
  9594. return;
  9595. }
  9596. draining = false;
  9597. if (currentQueue.length) {
  9598. queue = currentQueue.concat(queue);
  9599. } else {
  9600. queueIndex = -1;
  9601. }
  9602. if (queue.length) {
  9603. drainQueue();
  9604. }
  9605. }
  9606. function drainQueue() {
  9607. if (draining) {
  9608. return;
  9609. }
  9610. var timeout = runTimeout(cleanUpNextTick);
  9611. draining = true;
  9612. var len = queue.length;
  9613. while(len) {
  9614. currentQueue = queue;
  9615. queue = [];
  9616. while (++queueIndex < len) {
  9617. if (currentQueue) {
  9618. currentQueue[queueIndex].run();
  9619. }
  9620. }
  9621. queueIndex = -1;
  9622. len = queue.length;
  9623. }
  9624. currentQueue = null;
  9625. draining = false;
  9626. runClearTimeout(timeout);
  9627. }
  9628. process.nextTick = function (fun) {
  9629. var args = new Array(arguments.length - 1);
  9630. if (arguments.length > 1) {
  9631. for (var i = 1; i < arguments.length; i++) {
  9632. args[i - 1] = arguments[i];
  9633. }
  9634. }
  9635. queue.push(new Item(fun, args));
  9636. if (queue.length === 1 && !draining) {
  9637. runTimeout(drainQueue);
  9638. }
  9639. };
  9640. // v8 likes predictible objects
  9641. function Item(fun, array) {
  9642. this.fun = fun;
  9643. this.array = array;
  9644. }
  9645. Item.prototype.run = function () {
  9646. this.fun.apply(null, this.array);
  9647. };
  9648. process.title = 'browser';
  9649. process.browser = true;
  9650. process.env = {};
  9651. process.argv = [];
  9652. process.version = ''; // empty string to avoid regexp issues
  9653. process.versions = {};
  9654. function noop() {}
  9655. process.on = noop;
  9656. process.addListener = noop;
  9657. process.once = noop;
  9658. process.off = noop;
  9659. process.removeListener = noop;
  9660. process.removeAllListeners = noop;
  9661. process.emit = noop;
  9662. process.prependListener = noop;
  9663. process.prependOnceListener = noop;
  9664. process.listeners = function (name) { return [] }
  9665. process.binding = function (name) {
  9666. throw new Error('process.binding is not supported');
  9667. };
  9668. process.cwd = function () { return '/' };
  9669. process.chdir = function (dir) {
  9670. throw new Error('process.chdir is not supported');
  9671. };
  9672. process.umask = function() { return 0; };
  9673. },{}],160:[function(require,module,exports){
  9674. (function (global){
  9675. /*! https://mths.be/punycode v1.4.1 by @mathias */
  9676. ;(function(root) {
  9677. /** Detect free variables */
  9678. var freeExports = typeof exports == 'object' && exports &&
  9679. !exports.nodeType && exports;
  9680. var freeModule = typeof module == 'object' && module &&
  9681. !module.nodeType && module;
  9682. var freeGlobal = typeof global == 'object' && global;
  9683. if (
  9684. freeGlobal.global === freeGlobal ||
  9685. freeGlobal.window === freeGlobal ||
  9686. freeGlobal.self === freeGlobal
  9687. ) {
  9688. root = freeGlobal;
  9689. }
  9690. /**
  9691. * The `punycode` object.
  9692. * @name punycode
  9693. * @type Object
  9694. */
  9695. var punycode,
  9696. /** Highest positive signed 32-bit float value */
  9697. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  9698. /** Bootstring parameters */
  9699. base = 36,
  9700. tMin = 1,
  9701. tMax = 26,
  9702. skew = 38,
  9703. damp = 700,
  9704. initialBias = 72,
  9705. initialN = 128, // 0x80
  9706. delimiter = '-', // '\x2D'
  9707. /** Regular expressions */
  9708. regexPunycode = /^xn--/,
  9709. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  9710. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  9711. /** Error messages */
  9712. errors = {
  9713. 'overflow': 'Overflow: input needs wider integers to process',
  9714. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  9715. 'invalid-input': 'Invalid input'
  9716. },
  9717. /** Convenience shortcuts */
  9718. baseMinusTMin = base - tMin,
  9719. floor = Math.floor,
  9720. stringFromCharCode = String.fromCharCode,
  9721. /** Temporary variable */
  9722. key;
  9723. /*--------------------------------------------------------------------------*/
  9724. /**
  9725. * A generic error utility function.
  9726. * @private
  9727. * @param {String} type The error type.
  9728. * @returns {Error} Throws a `RangeError` with the applicable error message.
  9729. */
  9730. function error(type) {
  9731. throw new RangeError(errors[type]);
  9732. }
  9733. /**
  9734. * A generic `Array#map` utility function.
  9735. * @private
  9736. * @param {Array} array The array to iterate over.
  9737. * @param {Function} callback The function that gets called for every array
  9738. * item.
  9739. * @returns {Array} A new array of values returned by the callback function.
  9740. */
  9741. function map(array, fn) {
  9742. var length = array.length;
  9743. var result = [];
  9744. while (length--) {
  9745. result[length] = fn(array[length]);
  9746. }
  9747. return result;
  9748. }
  9749. /**
  9750. * A simple `Array#map`-like wrapper to work with domain name strings or email
  9751. * addresses.
  9752. * @private
  9753. * @param {String} domain The domain name or email address.
  9754. * @param {Function} callback The function that gets called for every
  9755. * character.
  9756. * @returns {Array} A new string of characters returned by the callback
  9757. * function.
  9758. */
  9759. function mapDomain(string, fn) {
  9760. var parts = string.split('@');
  9761. var result = '';
  9762. if (parts.length > 1) {
  9763. // In email addresses, only the domain name should be punycoded. Leave
  9764. // the local part (i.e. everything up to `@`) intact.
  9765. result = parts[0] + '@';
  9766. string = parts[1];
  9767. }
  9768. // Avoid `split(regex)` for IE8 compatibility. See #17.
  9769. string = string.replace(regexSeparators, '\x2E');
  9770. var labels = string.split('.');
  9771. var encoded = map(labels, fn).join('.');
  9772. return result + encoded;
  9773. }
  9774. /**
  9775. * Creates an array containing the numeric code points of each Unicode
  9776. * character in the string. While JavaScript uses UCS-2 internally,
  9777. * this function will convert a pair of surrogate halves (each of which
  9778. * UCS-2 exposes as separate characters) into a single code point,
  9779. * matching UTF-16.
  9780. * @see `punycode.ucs2.encode`
  9781. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  9782. * @memberOf punycode.ucs2
  9783. * @name decode
  9784. * @param {String} string The Unicode input string (UCS-2).
  9785. * @returns {Array} The new array of code points.
  9786. */
  9787. function ucs2decode(string) {
  9788. var output = [],
  9789. counter = 0,
  9790. length = string.length,
  9791. value,
  9792. extra;
  9793. while (counter < length) {
  9794. value = string.charCodeAt(counter++);
  9795. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  9796. // high surrogate, and there is a next character
  9797. extra = string.charCodeAt(counter++);
  9798. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  9799. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  9800. } else {
  9801. // unmatched surrogate; only append this code unit, in case the next
  9802. // code unit is the high surrogate of a surrogate pair
  9803. output.push(value);
  9804. counter--;
  9805. }
  9806. } else {
  9807. output.push(value);
  9808. }
  9809. }
  9810. return output;
  9811. }
  9812. /**
  9813. * Creates a string based on an array of numeric code points.
  9814. * @see `punycode.ucs2.decode`
  9815. * @memberOf punycode.ucs2
  9816. * @name encode
  9817. * @param {Array} codePoints The array of numeric code points.
  9818. * @returns {String} The new Unicode string (UCS-2).
  9819. */
  9820. function ucs2encode(array) {
  9821. return map(array, function(value) {
  9822. var output = '';
  9823. if (value > 0xFFFF) {
  9824. value -= 0x10000;
  9825. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  9826. value = 0xDC00 | value & 0x3FF;
  9827. }
  9828. output += stringFromCharCode(value);
  9829. return output;
  9830. }).join('');
  9831. }
  9832. /**
  9833. * Converts a basic code point into a digit/integer.
  9834. * @see `digitToBasic()`
  9835. * @private
  9836. * @param {Number} codePoint The basic numeric code point value.
  9837. * @returns {Number} The numeric value of a basic code point (for use in
  9838. * representing integers) in the range `0` to `base - 1`, or `base` if
  9839. * the code point does not represent a value.
  9840. */
  9841. function basicToDigit(codePoint) {
  9842. if (codePoint - 48 < 10) {
  9843. return codePoint - 22;
  9844. }
  9845. if (codePoint - 65 < 26) {
  9846. return codePoint - 65;
  9847. }
  9848. if (codePoint - 97 < 26) {
  9849. return codePoint - 97;
  9850. }
  9851. return base;
  9852. }
  9853. /**
  9854. * Converts a digit/integer into a basic code point.
  9855. * @see `basicToDigit()`
  9856. * @private
  9857. * @param {Number} digit The numeric value of a basic code point.
  9858. * @returns {Number} The basic code point whose value (when used for
  9859. * representing integers) is `digit`, which needs to be in the range
  9860. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  9861. * used; else, the lowercase form is used. The behavior is undefined
  9862. * if `flag` is non-zero and `digit` has no uppercase form.
  9863. */
  9864. function digitToBasic(digit, flag) {
  9865. // 0..25 map to ASCII a..z or A..Z
  9866. // 26..35 map to ASCII 0..9
  9867. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  9868. }
  9869. /**
  9870. * Bias adaptation function as per section 3.4 of RFC 3492.
  9871. * https://tools.ietf.org/html/rfc3492#section-3.4
  9872. * @private
  9873. */
  9874. function adapt(delta, numPoints, firstTime) {
  9875. var k = 0;
  9876. delta = firstTime ? floor(delta / damp) : delta >> 1;
  9877. delta += floor(delta / numPoints);
  9878. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  9879. delta = floor(delta / baseMinusTMin);
  9880. }
  9881. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  9882. }
  9883. /**
  9884. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  9885. * symbols.
  9886. * @memberOf punycode
  9887. * @param {String} input The Punycode string of ASCII-only symbols.
  9888. * @returns {String} The resulting string of Unicode symbols.
  9889. */
  9890. function decode(input) {
  9891. // Don't use UCS-2
  9892. var output = [],
  9893. inputLength = input.length,
  9894. out,
  9895. i = 0,
  9896. n = initialN,
  9897. bias = initialBias,
  9898. basic,
  9899. j,
  9900. index,
  9901. oldi,
  9902. w,
  9903. k,
  9904. digit,
  9905. t,
  9906. /** Cached calculation results */
  9907. baseMinusT;
  9908. // Handle the basic code points: let `basic` be the number of input code
  9909. // points before the last delimiter, or `0` if there is none, then copy
  9910. // the first basic code points to the output.
  9911. basic = input.lastIndexOf(delimiter);
  9912. if (basic < 0) {
  9913. basic = 0;
  9914. }
  9915. for (j = 0; j < basic; ++j) {
  9916. // if it's not a basic code point
  9917. if (input.charCodeAt(j) >= 0x80) {
  9918. error('not-basic');
  9919. }
  9920. output.push(input.charCodeAt(j));
  9921. }
  9922. // Main decoding loop: start just after the last delimiter if any basic code
  9923. // points were copied; start at the beginning otherwise.
  9924. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  9925. // `index` is the index of the next character to be consumed.
  9926. // Decode a generalized variable-length integer into `delta`,
  9927. // which gets added to `i`. The overflow checking is easier
  9928. // if we increase `i` as we go, then subtract off its starting
  9929. // value at the end to obtain `delta`.
  9930. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  9931. if (index >= inputLength) {
  9932. error('invalid-input');
  9933. }
  9934. digit = basicToDigit(input.charCodeAt(index++));
  9935. if (digit >= base || digit > floor((maxInt - i) / w)) {
  9936. error('overflow');
  9937. }
  9938. i += digit * w;
  9939. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  9940. if (digit < t) {
  9941. break;
  9942. }
  9943. baseMinusT = base - t;
  9944. if (w > floor(maxInt / baseMinusT)) {
  9945. error('overflow');
  9946. }
  9947. w *= baseMinusT;
  9948. }
  9949. out = output.length + 1;
  9950. bias = adapt(i - oldi, out, oldi == 0);
  9951. // `i` was supposed to wrap around from `out` to `0`,
  9952. // incrementing `n` each time, so we'll fix that now:
  9953. if (floor(i / out) > maxInt - n) {
  9954. error('overflow');
  9955. }
  9956. n += floor(i / out);
  9957. i %= out;
  9958. // Insert `n` at position `i` of the output
  9959. output.splice(i++, 0, n);
  9960. }
  9961. return ucs2encode(output);
  9962. }
  9963. /**
  9964. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  9965. * Punycode string of ASCII-only symbols.
  9966. * @memberOf punycode
  9967. * @param {String} input The string of Unicode symbols.
  9968. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  9969. */
  9970. function encode(input) {
  9971. var n,
  9972. delta,
  9973. handledCPCount,
  9974. basicLength,
  9975. bias,
  9976. j,
  9977. m,
  9978. q,
  9979. k,
  9980. t,
  9981. currentValue,
  9982. output = [],
  9983. /** `inputLength` will hold the number of code points in `input`. */
  9984. inputLength,
  9985. /** Cached calculation results */
  9986. handledCPCountPlusOne,
  9987. baseMinusT,
  9988. qMinusT;
  9989. // Convert the input in UCS-2 to Unicode
  9990. input = ucs2decode(input);
  9991. // Cache the length
  9992. inputLength = input.length;
  9993. // Initialize the state
  9994. n = initialN;
  9995. delta = 0;
  9996. bias = initialBias;
  9997. // Handle the basic code points
  9998. for (j = 0; j < inputLength; ++j) {
  9999. currentValue = input[j];
  10000. if (currentValue < 0x80) {
  10001. output.push(stringFromCharCode(currentValue));
  10002. }
  10003. }
  10004. handledCPCount = basicLength = output.length;
  10005. // `handledCPCount` is the number of code points that have been handled;
  10006. // `basicLength` is the number of basic code points.
  10007. // Finish the basic string - if it is not empty - with a delimiter
  10008. if (basicLength) {
  10009. output.push(delimiter);
  10010. }
  10011. // Main encoding loop:
  10012. while (handledCPCount < inputLength) {
  10013. // All non-basic code points < n have been handled already. Find the next
  10014. // larger one:
  10015. for (m = maxInt, j = 0; j < inputLength; ++j) {
  10016. currentValue = input[j];
  10017. if (currentValue >= n && currentValue < m) {
  10018. m = currentValue;
  10019. }
  10020. }
  10021. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  10022. // but guard against overflow
  10023. handledCPCountPlusOne = handledCPCount + 1;
  10024. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  10025. error('overflow');
  10026. }
  10027. delta += (m - n) * handledCPCountPlusOne;
  10028. n = m;
  10029. for (j = 0; j < inputLength; ++j) {
  10030. currentValue = input[j];
  10031. if (currentValue < n && ++delta > maxInt) {
  10032. error('overflow');
  10033. }
  10034. if (currentValue == n) {
  10035. // Represent delta as a generalized variable-length integer
  10036. for (q = delta, k = base; /* no condition */; k += base) {
  10037. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  10038. if (q < t) {
  10039. break;
  10040. }
  10041. qMinusT = q - t;
  10042. baseMinusT = base - t;
  10043. output.push(
  10044. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  10045. );
  10046. q = floor(qMinusT / baseMinusT);
  10047. }
  10048. output.push(stringFromCharCode(digitToBasic(q, 0)));
  10049. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  10050. delta = 0;
  10051. ++handledCPCount;
  10052. }
  10053. }
  10054. ++delta;
  10055. ++n;
  10056. }
  10057. return output.join('');
  10058. }
  10059. /**
  10060. * Converts a Punycode string representing a domain name or an email address
  10061. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  10062. * it doesn't matter if you call it on a string that has already been
  10063. * converted to Unicode.
  10064. * @memberOf punycode
  10065. * @param {String} input The Punycoded domain name or email address to
  10066. * convert to Unicode.
  10067. * @returns {String} The Unicode representation of the given Punycode
  10068. * string.
  10069. */
  10070. function toUnicode(input) {
  10071. return mapDomain(input, function(string) {
  10072. return regexPunycode.test(string)
  10073. ? decode(string.slice(4).toLowerCase())
  10074. : string;
  10075. });
  10076. }
  10077. /**
  10078. * Converts a Unicode string representing a domain name or an email address to
  10079. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  10080. * i.e. it doesn't matter if you call it with a domain that's already in
  10081. * ASCII.
  10082. * @memberOf punycode
  10083. * @param {String} input The domain name or email address to convert, as a
  10084. * Unicode string.
  10085. * @returns {String} The Punycode representation of the given domain name or
  10086. * email address.
  10087. */
  10088. function toASCII(input) {
  10089. return mapDomain(input, function(string) {
  10090. return regexNonASCII.test(string)
  10091. ? 'xn--' + encode(string)
  10092. : string;
  10093. });
  10094. }
  10095. /*--------------------------------------------------------------------------*/
  10096. /** Define the public API */
  10097. punycode = {
  10098. /**
  10099. * A string representing the current Punycode.js version number.
  10100. * @memberOf punycode
  10101. * @type String
  10102. */
  10103. 'version': '1.4.1',
  10104. /**
  10105. * An object of methods to convert from JavaScript's internal character
  10106. * representation (UCS-2) to Unicode code points, and back.
  10107. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  10108. * @memberOf punycode
  10109. * @type Object
  10110. */
  10111. 'ucs2': {
  10112. 'decode': ucs2decode,
  10113. 'encode': ucs2encode
  10114. },
  10115. 'decode': decode,
  10116. 'encode': encode,
  10117. 'toASCII': toASCII,
  10118. 'toUnicode': toUnicode
  10119. };
  10120. /** Expose `punycode` */
  10121. // Some AMD build optimizers, like r.js, check for specific condition patterns
  10122. // like the following:
  10123. if (
  10124. typeof define == 'function' &&
  10125. typeof define.amd == 'object' &&
  10126. define.amd
  10127. ) {
  10128. define('punycode', function() {
  10129. return punycode;
  10130. });
  10131. } else if (freeExports && freeModule) {
  10132. if (module.exports == freeExports) {
  10133. // in Node.js, io.js, or RingoJS v0.8.0+
  10134. freeModule.exports = punycode;
  10135. } else {
  10136. // in Narwhal or RingoJS v0.7.0-
  10137. for (key in punycode) {
  10138. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  10139. }
  10140. }
  10141. } else {
  10142. // in Rhino or a web browser
  10143. root.punycode = punycode;
  10144. }
  10145. }(this));
  10146. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  10147. },{}],161:[function(require,module,exports){
  10148. // Copyright Joyent, Inc. and other Node contributors.
  10149. //
  10150. // Permission is hereby granted, free of charge, to any person obtaining a
  10151. // copy of this software and associated documentation files (the
  10152. // "Software"), to deal in the Software without restriction, including
  10153. // without limitation the rights to use, copy, modify, merge, publish,
  10154. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10155. // persons to whom the Software is furnished to do so, subject to the
  10156. // following conditions:
  10157. //
  10158. // The above copyright notice and this permission notice shall be included
  10159. // in all copies or substantial portions of the Software.
  10160. //
  10161. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10162. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10163. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10164. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10165. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10166. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10167. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10168. 'use strict';
  10169. // If obj.hasOwnProperty has been overridden, then calling
  10170. // obj.hasOwnProperty(prop) will break.
  10171. // See: https://github.com/joyent/node/issues/1707
  10172. function hasOwnProperty(obj, prop) {
  10173. return Object.prototype.hasOwnProperty.call(obj, prop);
  10174. }
  10175. module.exports = function(qs, sep, eq, options) {
  10176. sep = sep || '&';
  10177. eq = eq || '=';
  10178. var obj = {};
  10179. if (typeof qs !== 'string' || qs.length === 0) {
  10180. return obj;
  10181. }
  10182. var regexp = /\+/g;
  10183. qs = qs.split(sep);
  10184. var maxKeys = 1000;
  10185. if (options && typeof options.maxKeys === 'number') {
  10186. maxKeys = options.maxKeys;
  10187. }
  10188. var len = qs.length;
  10189. // maxKeys <= 0 means that we should not limit keys count
  10190. if (maxKeys > 0 && len > maxKeys) {
  10191. len = maxKeys;
  10192. }
  10193. for (var i = 0; i < len; ++i) {
  10194. var x = qs[i].replace(regexp, '%20'),
  10195. idx = x.indexOf(eq),
  10196. kstr, vstr, k, v;
  10197. if (idx >= 0) {
  10198. kstr = x.substr(0, idx);
  10199. vstr = x.substr(idx + 1);
  10200. } else {
  10201. kstr = x;
  10202. vstr = '';
  10203. }
  10204. k = decodeURIComponent(kstr);
  10205. v = decodeURIComponent(vstr);
  10206. if (!hasOwnProperty(obj, k)) {
  10207. obj[k] = v;
  10208. } else if (isArray(obj[k])) {
  10209. obj[k].push(v);
  10210. } else {
  10211. obj[k] = [obj[k], v];
  10212. }
  10213. }
  10214. return obj;
  10215. };
  10216. var isArray = Array.isArray || function (xs) {
  10217. return Object.prototype.toString.call(xs) === '[object Array]';
  10218. };
  10219. },{}],162:[function(require,module,exports){
  10220. // Copyright Joyent, Inc. and other Node contributors.
  10221. //
  10222. // Permission is hereby granted, free of charge, to any person obtaining a
  10223. // copy of this software and associated documentation files (the
  10224. // "Software"), to deal in the Software without restriction, including
  10225. // without limitation the rights to use, copy, modify, merge, publish,
  10226. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10227. // persons to whom the Software is furnished to do so, subject to the
  10228. // following conditions:
  10229. //
  10230. // The above copyright notice and this permission notice shall be included
  10231. // in all copies or substantial portions of the Software.
  10232. //
  10233. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10234. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10235. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10236. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10237. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10238. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10239. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10240. 'use strict';
  10241. var stringifyPrimitive = function(v) {
  10242. switch (typeof v) {
  10243. case 'string':
  10244. return v;
  10245. case 'boolean':
  10246. return v ? 'true' : 'false';
  10247. case 'number':
  10248. return isFinite(v) ? v : '';
  10249. default:
  10250. return '';
  10251. }
  10252. };
  10253. module.exports = function(obj, sep, eq, name) {
  10254. sep = sep || '&';
  10255. eq = eq || '=';
  10256. if (obj === null) {
  10257. obj = undefined;
  10258. }
  10259. if (typeof obj === 'object') {
  10260. return map(objectKeys(obj), function(k) {
  10261. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  10262. if (isArray(obj[k])) {
  10263. return map(obj[k], function(v) {
  10264. return ks + encodeURIComponent(stringifyPrimitive(v));
  10265. }).join(sep);
  10266. } else {
  10267. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  10268. }
  10269. }).join(sep);
  10270. }
  10271. if (!name) return '';
  10272. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  10273. encodeURIComponent(stringifyPrimitive(obj));
  10274. };
  10275. var isArray = Array.isArray || function (xs) {
  10276. return Object.prototype.toString.call(xs) === '[object Array]';
  10277. };
  10278. function map (xs, f) {
  10279. if (xs.map) return xs.map(f);
  10280. var res = [];
  10281. for (var i = 0; i < xs.length; i++) {
  10282. res.push(f(xs[i], i));
  10283. }
  10284. return res;
  10285. }
  10286. var objectKeys = Object.keys || function (obj) {
  10287. var res = [];
  10288. for (var key in obj) {
  10289. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  10290. }
  10291. return res;
  10292. };
  10293. },{}],163:[function(require,module,exports){
  10294. 'use strict';
  10295. exports.decode = exports.parse = require('./decode');
  10296. exports.encode = exports.stringify = require('./encode');
  10297. },{"./decode":161,"./encode":162}],164:[function(require,module,exports){
  10298. module.exports = require('./lib/_stream_duplex.js');
  10299. },{"./lib/_stream_duplex.js":165}],165:[function(require,module,exports){
  10300. // Copyright Joyent, Inc. and other Node contributors.
  10301. //
  10302. // Permission is hereby granted, free of charge, to any person obtaining a
  10303. // copy of this software and associated documentation files (the
  10304. // "Software"), to deal in the Software without restriction, including
  10305. // without limitation the rights to use, copy, modify, merge, publish,
  10306. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10307. // persons to whom the Software is furnished to do so, subject to the
  10308. // following conditions:
  10309. //
  10310. // The above copyright notice and this permission notice shall be included
  10311. // in all copies or substantial portions of the Software.
  10312. //
  10313. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10314. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10315. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10316. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10317. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10318. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10319. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10320. // a duplex stream is just a stream that is both readable and writable.
  10321. // Since JS doesn't have multiple prototypal inheritance, this class
  10322. // prototypally inherits from Readable, and then parasitically from
  10323. // Writable.
  10324. 'use strict';
  10325. /*<replacement>*/
  10326. var _keys = require('babel-runtime/core-js/object/keys');
  10327. var _keys2 = _interopRequireDefault(_keys);
  10328. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10329. var processNextTick = require('process-nextick-args');
  10330. /*</replacement>*/
  10331. /*<replacement>*/
  10332. var objectKeys = _keys2.default || function (obj) {
  10333. var keys = [];
  10334. for (var key in obj) {
  10335. keys.push(key);
  10336. }return keys;
  10337. };
  10338. /*</replacement>*/
  10339. module.exports = Duplex;
  10340. /*<replacement>*/
  10341. var util = require('core-util-is');
  10342. util.inherits = require('inherits');
  10343. /*</replacement>*/
  10344. var Readable = require('./_stream_readable');
  10345. var Writable = require('./_stream_writable');
  10346. util.inherits(Duplex, Readable);
  10347. var keys = objectKeys(Writable.prototype);
  10348. for (var v = 0; v < keys.length; v++) {
  10349. var method = keys[v];
  10350. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  10351. }
  10352. function Duplex(options) {
  10353. if (!(this instanceof Duplex)) return new Duplex(options);
  10354. Readable.call(this, options);
  10355. Writable.call(this, options);
  10356. if (options && options.readable === false) this.readable = false;
  10357. if (options && options.writable === false) this.writable = false;
  10358. this.allowHalfOpen = true;
  10359. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  10360. this.once('end', onend);
  10361. }
  10362. // the no-half-open enforcer
  10363. function onend() {
  10364. // if we allow half-open state, or if the writable side ended,
  10365. // then we're ok.
  10366. if (this.allowHalfOpen || this._writableState.ended) return;
  10367. // no more data can be written.
  10368. // But allow more writes to happen in this tick.
  10369. processNextTick(onEndNT, this);
  10370. }
  10371. function onEndNT(self) {
  10372. self.end();
  10373. }
  10374. Object.defineProperty(Duplex.prototype, 'destroyed', {
  10375. get: function get() {
  10376. if (this._readableState === undefined || this._writableState === undefined) {
  10377. return false;
  10378. }
  10379. return this._readableState.destroyed && this._writableState.destroyed;
  10380. },
  10381. set: function set(value) {
  10382. // we ignore the value if the stream
  10383. // has not been initialized yet
  10384. if (this._readableState === undefined || this._writableState === undefined) {
  10385. return;
  10386. }
  10387. // backward compatibility, the user is explicitly
  10388. // managing destroyed
  10389. this._readableState.destroyed = value;
  10390. this._writableState.destroyed = value;
  10391. }
  10392. });
  10393. Duplex.prototype._destroy = function (err, cb) {
  10394. this.push(null);
  10395. this.end();
  10396. processNextTick(cb, err);
  10397. };
  10398. function forEach(xs, f) {
  10399. for (var i = 0, l = xs.length; i < l; i++) {
  10400. f(xs[i], i);
  10401. }
  10402. }
  10403. },{"./_stream_readable":167,"./_stream_writable":169,"babel-runtime/core-js/object/keys":18,"core-util-is":134,"inherits":149,"process-nextick-args":158}],166:[function(require,module,exports){
  10404. // Copyright Joyent, Inc. and other Node contributors.
  10405. //
  10406. // Permission is hereby granted, free of charge, to any person obtaining a
  10407. // copy of this software and associated documentation files (the
  10408. // "Software"), to deal in the Software without restriction, including
  10409. // without limitation the rights to use, copy, modify, merge, publish,
  10410. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10411. // persons to whom the Software is furnished to do so, subject to the
  10412. // following conditions:
  10413. //
  10414. // The above copyright notice and this permission notice shall be included
  10415. // in all copies or substantial portions of the Software.
  10416. //
  10417. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10418. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10419. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10420. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10421. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10422. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10423. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10424. // a passthrough stream.
  10425. // basically just the most minimal sort of Transform stream.
  10426. // Every written chunk gets output as-is.
  10427. 'use strict';
  10428. module.exports = PassThrough;
  10429. var Transform = require('./_stream_transform');
  10430. /*<replacement>*/
  10431. var util = require('core-util-is');
  10432. util.inherits = require('inherits');
  10433. /*</replacement>*/
  10434. util.inherits(PassThrough, Transform);
  10435. function PassThrough(options) {
  10436. if (!(this instanceof PassThrough)) return new PassThrough(options);
  10437. Transform.call(this, options);
  10438. }
  10439. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  10440. cb(null, chunk);
  10441. };
  10442. },{"./_stream_transform":168,"core-util-is":134,"inherits":149}],167:[function(require,module,exports){
  10443. (function (process,global){
  10444. // Copyright Joyent, Inc. and other Node contributors.
  10445. //
  10446. // Permission is hereby granted, free of charge, to any person obtaining a
  10447. // copy of this software and associated documentation files (the
  10448. // "Software"), to deal in the Software without restriction, including
  10449. // without limitation the rights to use, copy, modify, merge, publish,
  10450. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10451. // persons to whom the Software is furnished to do so, subject to the
  10452. // following conditions:
  10453. //
  10454. // The above copyright notice and this permission notice shall be included
  10455. // in all copies or substantial portions of the Software.
  10456. //
  10457. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10458. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10459. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10460. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10461. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10462. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10463. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10464. 'use strict';
  10465. /*<replacement>*/
  10466. var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  10467. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  10468. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10469. var processNextTick = require('process-nextick-args');
  10470. /*</replacement>*/
  10471. module.exports = Readable;
  10472. /*<replacement>*/
  10473. var isArray = require('isarray');
  10474. /*</replacement>*/
  10475. /*<replacement>*/
  10476. var Duplex;
  10477. /*</replacement>*/
  10478. Readable.ReadableState = ReadableState;
  10479. /*<replacement>*/
  10480. var EE = require('events').EventEmitter;
  10481. var EElistenerCount = function EElistenerCount(emitter, type) {
  10482. return emitter.listeners(type).length;
  10483. };
  10484. /*</replacement>*/
  10485. /*<replacement>*/
  10486. var Stream = require('./internal/streams/stream');
  10487. /*</replacement>*/
  10488. // TODO(bmeurer): Change this back to const once hole checks are
  10489. // properly optimized away early in Ignition+TurboFan.
  10490. /*<replacement>*/
  10491. var Buffer = require('safe-buffer').Buffer;
  10492. var OurUint8Array = global.Uint8Array || function () {};
  10493. function _uint8ArrayToBuffer(chunk) {
  10494. return Buffer.from(chunk);
  10495. }
  10496. function _isUint8Array(obj) {
  10497. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  10498. }
  10499. /*</replacement>*/
  10500. /*<replacement>*/
  10501. var util = require('core-util-is');
  10502. util.inherits = require('inherits');
  10503. /*</replacement>*/
  10504. /*<replacement>*/
  10505. var debugUtil = require('util');
  10506. var debug = void 0;
  10507. if (debugUtil && debugUtil.debuglog) {
  10508. debug = debugUtil.debuglog('stream');
  10509. } else {
  10510. debug = function debug() {};
  10511. }
  10512. /*</replacement>*/
  10513. var BufferList = require('./internal/streams/BufferList');
  10514. var destroyImpl = require('./internal/streams/destroy');
  10515. var StringDecoder;
  10516. util.inherits(Readable, Stream);
  10517. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  10518. function prependListener(emitter, event, fn) {
  10519. // Sadly this is not cacheable as some libraries bundle their own
  10520. // event emitter implementation with them.
  10521. if (typeof emitter.prependListener === 'function') {
  10522. return emitter.prependListener(event, fn);
  10523. } else {
  10524. // This is a hack to make sure that our error handler is attached before any
  10525. // userland ones. NEVER DO THIS. This is here only because this code needs
  10526. // to continue to work with older versions of Node.js that do not include
  10527. // the prependListener() method. The goal is to eventually remove this hack.
  10528. 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]];
  10529. }
  10530. }
  10531. function ReadableState(options, stream) {
  10532. Duplex = Duplex || require('./_stream_duplex');
  10533. options = options || {};
  10534. // object stream flag. Used to make read(n) ignore n and to
  10535. // make all the buffer merging and length checks go away
  10536. this.objectMode = !!options.objectMode;
  10537. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  10538. // the point at which it stops calling _read() to fill the buffer
  10539. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  10540. var hwm = options.highWaterMark;
  10541. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  10542. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  10543. // cast to ints.
  10544. this.highWaterMark = Math.floor(this.highWaterMark);
  10545. // A linked list is used to store data chunks instead of an array because the
  10546. // linked list can remove elements from the beginning faster than
  10547. // array.shift()
  10548. this.buffer = new BufferList();
  10549. this.length = 0;
  10550. this.pipes = null;
  10551. this.pipesCount = 0;
  10552. this.flowing = null;
  10553. this.ended = false;
  10554. this.endEmitted = false;
  10555. this.reading = false;
  10556. // a flag to be able to tell if the event 'readable'/'data' is emitted
  10557. // immediately, or on a later tick. We set this to true at first, because
  10558. // any actions that shouldn't happen until "later" should generally also
  10559. // not happen before the first read call.
  10560. this.sync = true;
  10561. // whenever we return null, then we set a flag to say
  10562. // that we're awaiting a 'readable' event emission.
  10563. this.needReadable = false;
  10564. this.emittedReadable = false;
  10565. this.readableListening = false;
  10566. this.resumeScheduled = false;
  10567. // has it been destroyed
  10568. this.destroyed = false;
  10569. // Crypto is kind of old and crusty. Historically, its default string
  10570. // encoding is 'binary' so we have to make this configurable.
  10571. // Everything else in the universe uses 'utf8', though.
  10572. this.defaultEncoding = options.defaultEncoding || 'utf8';
  10573. // the number of writers that are awaiting a drain event in .pipe()s
  10574. this.awaitDrain = 0;
  10575. // if true, a maybeReadMore has been scheduled
  10576. this.readingMore = false;
  10577. this.decoder = null;
  10578. this.encoding = null;
  10579. if (options.encoding) {
  10580. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  10581. this.decoder = new StringDecoder(options.encoding);
  10582. this.encoding = options.encoding;
  10583. }
  10584. }
  10585. function Readable(options) {
  10586. Duplex = Duplex || require('./_stream_duplex');
  10587. if (!(this instanceof Readable)) return new Readable(options);
  10588. this._readableState = new ReadableState(options, this);
  10589. // legacy
  10590. this.readable = true;
  10591. if (options) {
  10592. if (typeof options.read === 'function') this._read = options.read;
  10593. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  10594. }
  10595. Stream.call(this);
  10596. }
  10597. Object.defineProperty(Readable.prototype, 'destroyed', {
  10598. get: function get() {
  10599. if (this._readableState === undefined) {
  10600. return false;
  10601. }
  10602. return this._readableState.destroyed;
  10603. },
  10604. set: function set(value) {
  10605. // we ignore the value if the stream
  10606. // has not been initialized yet
  10607. if (!this._readableState) {
  10608. return;
  10609. }
  10610. // backward compatibility, the user is explicitly
  10611. // managing destroyed
  10612. this._readableState.destroyed = value;
  10613. }
  10614. });
  10615. Readable.prototype.destroy = destroyImpl.destroy;
  10616. Readable.prototype._undestroy = destroyImpl.undestroy;
  10617. Readable.prototype._destroy = function (err, cb) {
  10618. this.push(null);
  10619. cb(err);
  10620. };
  10621. // Manually shove something into the read() buffer.
  10622. // This returns true if the highWaterMark has not been hit yet,
  10623. // similar to how Writable.write() returns true if you should
  10624. // write() some more.
  10625. Readable.prototype.push = function (chunk, encoding) {
  10626. var state = this._readableState;
  10627. var skipChunkCheck;
  10628. if (!state.objectMode) {
  10629. if (typeof chunk === 'string') {
  10630. encoding = encoding || state.defaultEncoding;
  10631. if (encoding !== state.encoding) {
  10632. chunk = Buffer.from(chunk, encoding);
  10633. encoding = '';
  10634. }
  10635. skipChunkCheck = true;
  10636. }
  10637. } else {
  10638. skipChunkCheck = true;
  10639. }
  10640. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  10641. };
  10642. // Unshift should *always* be something directly out of read()
  10643. Readable.prototype.unshift = function (chunk) {
  10644. return readableAddChunk(this, chunk, null, true, false);
  10645. };
  10646. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  10647. var state = stream._readableState;
  10648. if (chunk === null) {
  10649. state.reading = false;
  10650. onEofChunk(stream, state);
  10651. } else {
  10652. var er;
  10653. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  10654. if (er) {
  10655. stream.emit('error', er);
  10656. } else if (state.objectMode || chunk && chunk.length > 0) {
  10657. if (typeof chunk !== 'string' && !state.objectMode && (0, _getPrototypeOf2.default)(chunk) !== Buffer.prototype) {
  10658. chunk = _uint8ArrayToBuffer(chunk);
  10659. }
  10660. if (addToFront) {
  10661. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  10662. } else if (state.ended) {
  10663. stream.emit('error', new Error('stream.push() after EOF'));
  10664. } else {
  10665. state.reading = false;
  10666. if (state.decoder && !encoding) {
  10667. chunk = state.decoder.write(chunk);
  10668. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  10669. } else {
  10670. addChunk(stream, state, chunk, false);
  10671. }
  10672. }
  10673. } else if (!addToFront) {
  10674. state.reading = false;
  10675. }
  10676. }
  10677. return needMoreData(state);
  10678. }
  10679. function addChunk(stream, state, chunk, addToFront) {
  10680. if (state.flowing && state.length === 0 && !state.sync) {
  10681. stream.emit('data', chunk);
  10682. stream.read(0);
  10683. } else {
  10684. // update the buffer info.
  10685. state.length += state.objectMode ? 1 : chunk.length;
  10686. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  10687. if (state.needReadable) emitReadable(stream);
  10688. }
  10689. maybeReadMore(stream, state);
  10690. }
  10691. function chunkInvalid(state, chunk) {
  10692. var er;
  10693. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  10694. er = new TypeError('Invalid non-string/buffer chunk');
  10695. }
  10696. return er;
  10697. }
  10698. // if it's past the high water mark, we can push in some more.
  10699. // Also, if we have no data yet, we can stand some
  10700. // more bytes. This is to work around cases where hwm=0,
  10701. // such as the repl. Also, if the push() triggered a
  10702. // readable event, and the user called read(largeNumber) such that
  10703. // needReadable was set, then we ought to push more, so that another
  10704. // 'readable' event will be triggered.
  10705. function needMoreData(state) {
  10706. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  10707. }
  10708. Readable.prototype.isPaused = function () {
  10709. return this._readableState.flowing === false;
  10710. };
  10711. // backwards compatibility.
  10712. Readable.prototype.setEncoding = function (enc) {
  10713. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  10714. this._readableState.decoder = new StringDecoder(enc);
  10715. this._readableState.encoding = enc;
  10716. return this;
  10717. };
  10718. // Don't raise the hwm > 8MB
  10719. var MAX_HWM = 0x800000;
  10720. function computeNewHighWaterMark(n) {
  10721. if (n >= MAX_HWM) {
  10722. n = MAX_HWM;
  10723. } else {
  10724. // Get the next highest power of 2 to prevent increasing hwm excessively in
  10725. // tiny amounts
  10726. n--;
  10727. n |= n >>> 1;
  10728. n |= n >>> 2;
  10729. n |= n >>> 4;
  10730. n |= n >>> 8;
  10731. n |= n >>> 16;
  10732. n++;
  10733. }
  10734. return n;
  10735. }
  10736. // This function is designed to be inlinable, so please take care when making
  10737. // changes to the function body.
  10738. function howMuchToRead(n, state) {
  10739. if (n <= 0 || state.length === 0 && state.ended) return 0;
  10740. if (state.objectMode) return 1;
  10741. if (n !== n) {
  10742. // Only flow one buffer at a time
  10743. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  10744. }
  10745. // If we're asking for more than the current hwm, then raise the hwm.
  10746. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  10747. if (n <= state.length) return n;
  10748. // Don't have enough
  10749. if (!state.ended) {
  10750. state.needReadable = true;
  10751. return 0;
  10752. }
  10753. return state.length;
  10754. }
  10755. // you can override either this method, or the async _read(n) below.
  10756. Readable.prototype.read = function (n) {
  10757. debug('read', n);
  10758. n = parseInt(n, 10);
  10759. var state = this._readableState;
  10760. var nOrig = n;
  10761. if (n !== 0) state.emittedReadable = false;
  10762. // if we're doing read(0) to trigger a readable event, but we
  10763. // already have a bunch of data in the buffer, then just trigger
  10764. // the 'readable' event and move on.
  10765. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  10766. debug('read: emitReadable', state.length, state.ended);
  10767. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  10768. return null;
  10769. }
  10770. n = howMuchToRead(n, state);
  10771. // if we've ended, and we're now clear, then finish it up.
  10772. if (n === 0 && state.ended) {
  10773. if (state.length === 0) endReadable(this);
  10774. return null;
  10775. }
  10776. // All the actual chunk generation logic needs to be
  10777. // *below* the call to _read. The reason is that in certain
  10778. // synthetic stream cases, such as passthrough streams, _read
  10779. // may be a completely synchronous operation which may change
  10780. // the state of the read buffer, providing enough data when
  10781. // before there was *not* enough.
  10782. //
  10783. // So, the steps are:
  10784. // 1. Figure out what the state of things will be after we do
  10785. // a read from the buffer.
  10786. //
  10787. // 2. If that resulting state will trigger a _read, then call _read.
  10788. // Note that this may be asynchronous, or synchronous. Yes, it is
  10789. // deeply ugly to write APIs this way, but that still doesn't mean
  10790. // that the Readable class should behave improperly, as streams are
  10791. // designed to be sync/async agnostic.
  10792. // Take note if the _read call is sync or async (ie, if the read call
  10793. // has returned yet), so that we know whether or not it's safe to emit
  10794. // 'readable' etc.
  10795. //
  10796. // 3. Actually pull the requested chunks out of the buffer and return.
  10797. // if we need a readable event, then we need to do some reading.
  10798. var doRead = state.needReadable;
  10799. debug('need readable', doRead);
  10800. // if we currently have less than the highWaterMark, then also read some
  10801. if (state.length === 0 || state.length - n < state.highWaterMark) {
  10802. doRead = true;
  10803. debug('length less than watermark', doRead);
  10804. }
  10805. // however, if we've ended, then there's no point, and if we're already
  10806. // reading, then it's unnecessary.
  10807. if (state.ended || state.reading) {
  10808. doRead = false;
  10809. debug('reading or ended', doRead);
  10810. } else if (doRead) {
  10811. debug('do read');
  10812. state.reading = true;
  10813. state.sync = true;
  10814. // if the length is currently zero, then we *need* a readable event.
  10815. if (state.length === 0) state.needReadable = true;
  10816. // call internal read method
  10817. this._read(state.highWaterMark);
  10818. state.sync = false;
  10819. // If _read pushed data synchronously, then `reading` will be false,
  10820. // and we need to re-evaluate how much data we can return to the user.
  10821. if (!state.reading) n = howMuchToRead(nOrig, state);
  10822. }
  10823. var ret;
  10824. if (n > 0) ret = fromList(n, state);else ret = null;
  10825. if (ret === null) {
  10826. state.needReadable = true;
  10827. n = 0;
  10828. } else {
  10829. state.length -= n;
  10830. }
  10831. if (state.length === 0) {
  10832. // If we have nothing in the buffer, then we want to know
  10833. // as soon as we *do* get something into the buffer.
  10834. if (!state.ended) state.needReadable = true;
  10835. // If we tried to read() past the EOF, then emit end on the next tick.
  10836. if (nOrig !== n && state.ended) endReadable(this);
  10837. }
  10838. if (ret !== null) this.emit('data', ret);
  10839. return ret;
  10840. };
  10841. function onEofChunk(stream, state) {
  10842. if (state.ended) return;
  10843. if (state.decoder) {
  10844. var chunk = state.decoder.end();
  10845. if (chunk && chunk.length) {
  10846. state.buffer.push(chunk);
  10847. state.length += state.objectMode ? 1 : chunk.length;
  10848. }
  10849. }
  10850. state.ended = true;
  10851. // emit 'readable' now to make sure it gets picked up.
  10852. emitReadable(stream);
  10853. }
  10854. // Don't emit readable right away in sync mode, because this can trigger
  10855. // another read() call => stack overflow. This way, it might trigger
  10856. // a nextTick recursion warning, but that's not so bad.
  10857. function emitReadable(stream) {
  10858. var state = stream._readableState;
  10859. state.needReadable = false;
  10860. if (!state.emittedReadable) {
  10861. debug('emitReadable', state.flowing);
  10862. state.emittedReadable = true;
  10863. if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
  10864. }
  10865. }
  10866. function emitReadable_(stream) {
  10867. debug('emit readable');
  10868. stream.emit('readable');
  10869. flow(stream);
  10870. }
  10871. // at this point, the user has presumably seen the 'readable' event,
  10872. // and called read() to consume some data. that may have triggered
  10873. // in turn another _read(n) call, in which case reading = true if
  10874. // it's in progress.
  10875. // However, if we're not ended, or reading, and the length < hwm,
  10876. // then go ahead and try to read some more preemptively.
  10877. function maybeReadMore(stream, state) {
  10878. if (!state.readingMore) {
  10879. state.readingMore = true;
  10880. processNextTick(maybeReadMore_, stream, state);
  10881. }
  10882. }
  10883. function maybeReadMore_(stream, state) {
  10884. var len = state.length;
  10885. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  10886. debug('maybeReadMore read 0');
  10887. stream.read(0);
  10888. if (len === state.length)
  10889. // didn't get any data, stop spinning.
  10890. break;else len = state.length;
  10891. }
  10892. state.readingMore = false;
  10893. }
  10894. // abstract method. to be overridden in specific implementation classes.
  10895. // call cb(er, data) where data is <= n in length.
  10896. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  10897. // arbitrary, and perhaps not very meaningful.
  10898. Readable.prototype._read = function (n) {
  10899. this.emit('error', new Error('_read() is not implemented'));
  10900. };
  10901. Readable.prototype.pipe = function (dest, pipeOpts) {
  10902. var src = this;
  10903. var state = this._readableState;
  10904. switch (state.pipesCount) {
  10905. case 0:
  10906. state.pipes = dest;
  10907. break;
  10908. case 1:
  10909. state.pipes = [state.pipes, dest];
  10910. break;
  10911. default:
  10912. state.pipes.push(dest);
  10913. break;
  10914. }
  10915. state.pipesCount += 1;
  10916. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  10917. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  10918. var endFn = doEnd ? onend : unpipe;
  10919. if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
  10920. dest.on('unpipe', onunpipe);
  10921. function onunpipe(readable, unpipeInfo) {
  10922. debug('onunpipe');
  10923. if (readable === src) {
  10924. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  10925. unpipeInfo.hasUnpiped = true;
  10926. cleanup();
  10927. }
  10928. }
  10929. }
  10930. function onend() {
  10931. debug('onend');
  10932. dest.end();
  10933. }
  10934. // when the dest drains, it reduces the awaitDrain counter
  10935. // on the source. This would be more elegant with a .once()
  10936. // handler in flow(), but adding and removing repeatedly is
  10937. // too slow.
  10938. var ondrain = pipeOnDrain(src);
  10939. dest.on('drain', ondrain);
  10940. var cleanedUp = false;
  10941. function cleanup() {
  10942. debug('cleanup');
  10943. // cleanup event handlers once the pipe is broken
  10944. dest.removeListener('close', onclose);
  10945. dest.removeListener('finish', onfinish);
  10946. dest.removeListener('drain', ondrain);
  10947. dest.removeListener('error', onerror);
  10948. dest.removeListener('unpipe', onunpipe);
  10949. src.removeListener('end', onend);
  10950. src.removeListener('end', unpipe);
  10951. src.removeListener('data', ondata);
  10952. cleanedUp = true;
  10953. // if the reader is waiting for a drain event from this
  10954. // specific writer, then it would cause it to never start
  10955. // flowing again.
  10956. // So, if this is awaiting a drain, then we just call it now.
  10957. // If we don't know, then assume that we are waiting for one.
  10958. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  10959. }
  10960. // If the user pushes more data while we're writing to dest then we'll end up
  10961. // in ondata again. However, we only want to increase awaitDrain once because
  10962. // dest will only emit one 'drain' event for the multiple writes.
  10963. // => Introduce a guard on increasing awaitDrain.
  10964. var increasedAwaitDrain = false;
  10965. src.on('data', ondata);
  10966. function ondata(chunk) {
  10967. debug('ondata');
  10968. increasedAwaitDrain = false;
  10969. var ret = dest.write(chunk);
  10970. if (false === ret && !increasedAwaitDrain) {
  10971. // If the user unpiped during `dest.write()`, it is possible
  10972. // to get stuck in a permanently paused state if that write
  10973. // also returned false.
  10974. // => Check whether `dest` is still a piping destination.
  10975. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  10976. debug('false write response, pause', src._readableState.awaitDrain);
  10977. src._readableState.awaitDrain++;
  10978. increasedAwaitDrain = true;
  10979. }
  10980. src.pause();
  10981. }
  10982. }
  10983. // if the dest has an error, then stop piping into it.
  10984. // however, don't suppress the throwing behavior for this.
  10985. function onerror(er) {
  10986. debug('onerror', er);
  10987. unpipe();
  10988. dest.removeListener('error', onerror);
  10989. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  10990. }
  10991. // Make sure our error handler is attached before userland ones.
  10992. prependListener(dest, 'error', onerror);
  10993. // Both close and finish should trigger unpipe, but only once.
  10994. function onclose() {
  10995. dest.removeListener('finish', onfinish);
  10996. unpipe();
  10997. }
  10998. dest.once('close', onclose);
  10999. function onfinish() {
  11000. debug('onfinish');
  11001. dest.removeListener('close', onclose);
  11002. unpipe();
  11003. }
  11004. dest.once('finish', onfinish);
  11005. function unpipe() {
  11006. debug('unpipe');
  11007. src.unpipe(dest);
  11008. }
  11009. // tell the dest that it's being piped to
  11010. dest.emit('pipe', src);
  11011. // start the flow if it hasn't been started already.
  11012. if (!state.flowing) {
  11013. debug('pipe resume');
  11014. src.resume();
  11015. }
  11016. return dest;
  11017. };
  11018. function pipeOnDrain(src) {
  11019. return function () {
  11020. var state = src._readableState;
  11021. debug('pipeOnDrain', state.awaitDrain);
  11022. if (state.awaitDrain) state.awaitDrain--;
  11023. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  11024. state.flowing = true;
  11025. flow(src);
  11026. }
  11027. };
  11028. }
  11029. Readable.prototype.unpipe = function (dest) {
  11030. var state = this._readableState;
  11031. var unpipeInfo = { hasUnpiped: false };
  11032. // if we're not piping anywhere, then do nothing.
  11033. if (state.pipesCount === 0) return this;
  11034. // just one destination. most common case.
  11035. if (state.pipesCount === 1) {
  11036. // passed in one, but it's not the right one.
  11037. if (dest && dest !== state.pipes) return this;
  11038. if (!dest) dest = state.pipes;
  11039. // got a match.
  11040. state.pipes = null;
  11041. state.pipesCount = 0;
  11042. state.flowing = false;
  11043. if (dest) dest.emit('unpipe', this, unpipeInfo);
  11044. return this;
  11045. }
  11046. // slow case. multiple pipe destinations.
  11047. if (!dest) {
  11048. // remove all.
  11049. var dests = state.pipes;
  11050. var len = state.pipesCount;
  11051. state.pipes = null;
  11052. state.pipesCount = 0;
  11053. state.flowing = false;
  11054. for (var i = 0; i < len; i++) {
  11055. dests[i].emit('unpipe', this, unpipeInfo);
  11056. }return this;
  11057. }
  11058. // try to find the right one.
  11059. var index = indexOf(state.pipes, dest);
  11060. if (index === -1) return this;
  11061. state.pipes.splice(index, 1);
  11062. state.pipesCount -= 1;
  11063. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  11064. dest.emit('unpipe', this, unpipeInfo);
  11065. return this;
  11066. };
  11067. // set up data events if they are asked for
  11068. // Ensure readable listeners eventually get something
  11069. Readable.prototype.on = function (ev, fn) {
  11070. var res = Stream.prototype.on.call(this, ev, fn);
  11071. if (ev === 'data') {
  11072. // Start flowing on next tick if stream isn't explicitly paused
  11073. if (this._readableState.flowing !== false) this.resume();
  11074. } else if (ev === 'readable') {
  11075. var state = this._readableState;
  11076. if (!state.endEmitted && !state.readableListening) {
  11077. state.readableListening = state.needReadable = true;
  11078. state.emittedReadable = false;
  11079. if (!state.reading) {
  11080. processNextTick(nReadingNextTick, this);
  11081. } else if (state.length) {
  11082. emitReadable(this);
  11083. }
  11084. }
  11085. }
  11086. return res;
  11087. };
  11088. Readable.prototype.addListener = Readable.prototype.on;
  11089. function nReadingNextTick(self) {
  11090. debug('readable nexttick read 0');
  11091. self.read(0);
  11092. }
  11093. // pause() and resume() are remnants of the legacy readable stream API
  11094. // If the user uses them, then switch into old mode.
  11095. Readable.prototype.resume = function () {
  11096. var state = this._readableState;
  11097. if (!state.flowing) {
  11098. debug('resume');
  11099. state.flowing = true;
  11100. resume(this, state);
  11101. }
  11102. return this;
  11103. };
  11104. function resume(stream, state) {
  11105. if (!state.resumeScheduled) {
  11106. state.resumeScheduled = true;
  11107. processNextTick(resume_, stream, state);
  11108. }
  11109. }
  11110. function resume_(stream, state) {
  11111. if (!state.reading) {
  11112. debug('resume read 0');
  11113. stream.read(0);
  11114. }
  11115. state.resumeScheduled = false;
  11116. state.awaitDrain = 0;
  11117. stream.emit('resume');
  11118. flow(stream);
  11119. if (state.flowing && !state.reading) stream.read(0);
  11120. }
  11121. Readable.prototype.pause = function () {
  11122. debug('call pause flowing=%j', this._readableState.flowing);
  11123. if (false !== this._readableState.flowing) {
  11124. debug('pause');
  11125. this._readableState.flowing = false;
  11126. this.emit('pause');
  11127. }
  11128. return this;
  11129. };
  11130. function flow(stream) {
  11131. var state = stream._readableState;
  11132. debug('flow', state.flowing);
  11133. while (state.flowing && stream.read() !== null) {}
  11134. }
  11135. // wrap an old-style stream as the async data source.
  11136. // This is *not* part of the readable stream interface.
  11137. // It is an ugly unfortunate mess of history.
  11138. Readable.prototype.wrap = function (stream) {
  11139. var state = this._readableState;
  11140. var paused = false;
  11141. var self = this;
  11142. stream.on('end', function () {
  11143. debug('wrapped end');
  11144. if (state.decoder && !state.ended) {
  11145. var chunk = state.decoder.end();
  11146. if (chunk && chunk.length) self.push(chunk);
  11147. }
  11148. self.push(null);
  11149. });
  11150. stream.on('data', function (chunk) {
  11151. debug('wrapped data');
  11152. if (state.decoder) chunk = state.decoder.write(chunk);
  11153. // don't skip over falsy values in objectMode
  11154. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  11155. var ret = self.push(chunk);
  11156. if (!ret) {
  11157. paused = true;
  11158. stream.pause();
  11159. }
  11160. });
  11161. // proxy all the other methods.
  11162. // important when wrapping filters and duplexes.
  11163. for (var i in stream) {
  11164. if (this[i] === undefined && typeof stream[i] === 'function') {
  11165. this[i] = function (method) {
  11166. return function () {
  11167. return stream[method].apply(stream, arguments);
  11168. };
  11169. }(i);
  11170. }
  11171. }
  11172. // proxy certain important events.
  11173. for (var n = 0; n < kProxyEvents.length; n++) {
  11174. stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
  11175. }
  11176. // when we try to consume some more bytes, simply unpause the
  11177. // underlying stream.
  11178. self._read = function (n) {
  11179. debug('wrapped _read', n);
  11180. if (paused) {
  11181. paused = false;
  11182. stream.resume();
  11183. }
  11184. };
  11185. return self;
  11186. };
  11187. // exposed for testing purposes only.
  11188. Readable._fromList = fromList;
  11189. // Pluck off n bytes from an array of buffers.
  11190. // Length is the combined lengths of all the buffers in the list.
  11191. // This function is designed to be inlinable, so please take care when making
  11192. // changes to the function body.
  11193. function fromList(n, state) {
  11194. // nothing buffered
  11195. if (state.length === 0) return null;
  11196. var ret;
  11197. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  11198. // read it all, truncate the list
  11199. 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);
  11200. state.buffer.clear();
  11201. } else {
  11202. // read part of list
  11203. ret = fromListPartial(n, state.buffer, state.decoder);
  11204. }
  11205. return ret;
  11206. }
  11207. // Extracts only enough buffered data to satisfy the amount requested.
  11208. // This function is designed to be inlinable, so please take care when making
  11209. // changes to the function body.
  11210. function fromListPartial(n, list, hasStrings) {
  11211. var ret;
  11212. if (n < list.head.data.length) {
  11213. // slice is the same for buffers and strings
  11214. ret = list.head.data.slice(0, n);
  11215. list.head.data = list.head.data.slice(n);
  11216. } else if (n === list.head.data.length) {
  11217. // first chunk is a perfect match
  11218. ret = list.shift();
  11219. } else {
  11220. // result spans more than one buffer
  11221. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  11222. }
  11223. return ret;
  11224. }
  11225. // Copies a specified amount of characters from the list of buffered data
  11226. // chunks.
  11227. // This function is designed to be inlinable, so please take care when making
  11228. // changes to the function body.
  11229. function copyFromBufferString(n, list) {
  11230. var p = list.head;
  11231. var c = 1;
  11232. var ret = p.data;
  11233. n -= ret.length;
  11234. while (p = p.next) {
  11235. var str = p.data;
  11236. var nb = n > str.length ? str.length : n;
  11237. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  11238. n -= nb;
  11239. if (n === 0) {
  11240. if (nb === str.length) {
  11241. ++c;
  11242. if (p.next) list.head = p.next;else list.head = list.tail = null;
  11243. } else {
  11244. list.head = p;
  11245. p.data = str.slice(nb);
  11246. }
  11247. break;
  11248. }
  11249. ++c;
  11250. }
  11251. list.length -= c;
  11252. return ret;
  11253. }
  11254. // Copies a specified amount of bytes from the list of buffered data chunks.
  11255. // This function is designed to be inlinable, so please take care when making
  11256. // changes to the function body.
  11257. function copyFromBuffer(n, list) {
  11258. var ret = Buffer.allocUnsafe(n);
  11259. var p = list.head;
  11260. var c = 1;
  11261. p.data.copy(ret);
  11262. n -= p.data.length;
  11263. while (p = p.next) {
  11264. var buf = p.data;
  11265. var nb = n > buf.length ? buf.length : n;
  11266. buf.copy(ret, ret.length - n, 0, nb);
  11267. n -= nb;
  11268. if (n === 0) {
  11269. if (nb === buf.length) {
  11270. ++c;
  11271. if (p.next) list.head = p.next;else list.head = list.tail = null;
  11272. } else {
  11273. list.head = p;
  11274. p.data = buf.slice(nb);
  11275. }
  11276. break;
  11277. }
  11278. ++c;
  11279. }
  11280. list.length -= c;
  11281. return ret;
  11282. }
  11283. function endReadable(stream) {
  11284. var state = stream._readableState;
  11285. // If we get here before consuming all the bytes, then that is a
  11286. // bug in node. Should never happen.
  11287. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  11288. if (!state.endEmitted) {
  11289. state.ended = true;
  11290. processNextTick(endReadableNT, state, stream);
  11291. }
  11292. }
  11293. function endReadableNT(state, stream) {
  11294. // Check that we didn't get one last unshift.
  11295. if (!state.endEmitted && state.length === 0) {
  11296. state.endEmitted = true;
  11297. stream.readable = false;
  11298. stream.emit('end');
  11299. }
  11300. }
  11301. function forEach(xs, f) {
  11302. for (var i = 0, l = xs.length; i < l; i++) {
  11303. f(xs[i], i);
  11304. }
  11305. }
  11306. function indexOf(xs, x) {
  11307. for (var i = 0, l = xs.length; i < l; i++) {
  11308. if (xs[i] === x) return i;
  11309. }
  11310. return -1;
  11311. }
  11312. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  11313. },{"./_stream_duplex":165,"./internal/streams/BufferList":170,"./internal/streams/destroy":171,"./internal/streams/stream":172,"_process":159,"babel-runtime/core-js/object/get-prototype-of":17,"core-util-is":134,"events":145,"inherits":149,"isarray":173,"process-nextick-args":158,"safe-buffer":181,"string_decoder/":174,"util":30}],168:[function(require,module,exports){
  11314. // Copyright Joyent, Inc. and other Node contributors.
  11315. //
  11316. // Permission is hereby granted, free of charge, to any person obtaining a
  11317. // copy of this software and associated documentation files (the
  11318. // "Software"), to deal in the Software without restriction, including
  11319. // without limitation the rights to use, copy, modify, merge, publish,
  11320. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11321. // persons to whom the Software is furnished to do so, subject to the
  11322. // following conditions:
  11323. //
  11324. // The above copyright notice and this permission notice shall be included
  11325. // in all copies or substantial portions of the Software.
  11326. //
  11327. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11328. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11329. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11330. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11331. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11332. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11333. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11334. // a transform stream is a readable/writable stream where you do
  11335. // something with the data. Sometimes it's called a "filter",
  11336. // but that's not a great name for it, since that implies a thing where
  11337. // some bits pass through, and others are simply ignored. (That would
  11338. // be a valid example of a transform, of course.)
  11339. //
  11340. // While the output is causally related to the input, it's not a
  11341. // necessarily symmetric or synchronous transformation. For example,
  11342. // a zlib stream might take multiple plain-text writes(), and then
  11343. // emit a single compressed chunk some time in the future.
  11344. //
  11345. // Here's how this works:
  11346. //
  11347. // The Transform stream has all the aspects of the readable and writable
  11348. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  11349. // internally, and returns false if there's a lot of pending writes
  11350. // buffered up. When you call read(), that calls _read(n) until
  11351. // there's enough pending readable data buffered up.
  11352. //
  11353. // In a transform stream, the written data is placed in a buffer. When
  11354. // _read(n) is called, it transforms the queued up data, calling the
  11355. // buffered _write cb's as it consumes chunks. If consuming a single
  11356. // written chunk would result in multiple output chunks, then the first
  11357. // outputted bit calls the readcb, and subsequent chunks just go into
  11358. // the read buffer, and will cause it to emit 'readable' if necessary.
  11359. //
  11360. // This way, back-pressure is actually determined by the reading side,
  11361. // since _read has to be called to start processing a new chunk. However,
  11362. // a pathological inflate type of transform can cause excessive buffering
  11363. // here. For example, imagine a stream where every byte of input is
  11364. // interpreted as an integer from 0-255, and then results in that many
  11365. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  11366. // 1kb of data being output. In this case, you could write a very small
  11367. // amount of input, and end up with a very large amount of output. In
  11368. // such a pathological inflating mechanism, there'd be no way to tell
  11369. // the system to stop doing the transform. A single 4MB write could
  11370. // cause the system to run out of memory.
  11371. //
  11372. // However, even in such a pathological case, only a single written chunk
  11373. // would be consumed, and then the rest would wait (un-transformed) until
  11374. // the results of the previous transformed chunk were consumed.
  11375. 'use strict';
  11376. module.exports = Transform;
  11377. var Duplex = require('./_stream_duplex');
  11378. /*<replacement>*/
  11379. var util = require('core-util-is');
  11380. util.inherits = require('inherits');
  11381. /*</replacement>*/
  11382. util.inherits(Transform, Duplex);
  11383. function TransformState(stream) {
  11384. this.afterTransform = function (er, data) {
  11385. return afterTransform(stream, er, data);
  11386. };
  11387. this.needTransform = false;
  11388. this.transforming = false;
  11389. this.writecb = null;
  11390. this.writechunk = null;
  11391. this.writeencoding = null;
  11392. }
  11393. function afterTransform(stream, er, data) {
  11394. var ts = stream._transformState;
  11395. ts.transforming = false;
  11396. var cb = ts.writecb;
  11397. if (!cb) {
  11398. return stream.emit('error', new Error('write callback called multiple times'));
  11399. }
  11400. ts.writechunk = null;
  11401. ts.writecb = null;
  11402. if (data !== null && data !== undefined) stream.push(data);
  11403. cb(er);
  11404. var rs = stream._readableState;
  11405. rs.reading = false;
  11406. if (rs.needReadable || rs.length < rs.highWaterMark) {
  11407. stream._read(rs.highWaterMark);
  11408. }
  11409. }
  11410. function Transform(options) {
  11411. if (!(this instanceof Transform)) return new Transform(options);
  11412. Duplex.call(this, options);
  11413. this._transformState = new TransformState(this);
  11414. var stream = this;
  11415. // start out asking for a readable event once data is transformed.
  11416. this._readableState.needReadable = true;
  11417. // we have implemented the _read method, and done the other things
  11418. // that Readable wants before the first _read call, so unset the
  11419. // sync guard flag.
  11420. this._readableState.sync = false;
  11421. if (options) {
  11422. if (typeof options.transform === 'function') this._transform = options.transform;
  11423. if (typeof options.flush === 'function') this._flush = options.flush;
  11424. }
  11425. // When the writable side finishes, then flush out anything remaining.
  11426. this.once('prefinish', function () {
  11427. if (typeof this._flush === 'function') this._flush(function (er, data) {
  11428. done(stream, er, data);
  11429. });else done(stream);
  11430. });
  11431. }
  11432. Transform.prototype.push = function (chunk, encoding) {
  11433. this._transformState.needTransform = false;
  11434. return Duplex.prototype.push.call(this, chunk, encoding);
  11435. };
  11436. // This is the part where you do stuff!
  11437. // override this function in implementation classes.
  11438. // 'chunk' is an input chunk.
  11439. //
  11440. // Call `push(newChunk)` to pass along transformed output
  11441. // to the readable side. You may call 'push' zero or more times.
  11442. //
  11443. // Call `cb(err)` when you are done with this chunk. If you pass
  11444. // an error, then that'll put the hurt on the whole operation. If you
  11445. // never call cb(), then you'll never get another chunk.
  11446. Transform.prototype._transform = function (chunk, encoding, cb) {
  11447. throw new Error('_transform() is not implemented');
  11448. };
  11449. Transform.prototype._write = function (chunk, encoding, cb) {
  11450. var ts = this._transformState;
  11451. ts.writecb = cb;
  11452. ts.writechunk = chunk;
  11453. ts.writeencoding = encoding;
  11454. if (!ts.transforming) {
  11455. var rs = this._readableState;
  11456. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  11457. }
  11458. };
  11459. // Doesn't matter what the args are here.
  11460. // _transform does all the work.
  11461. // That we got here means that the readable side wants more data.
  11462. Transform.prototype._read = function (n) {
  11463. var ts = this._transformState;
  11464. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  11465. ts.transforming = true;
  11466. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  11467. } else {
  11468. // mark that we need a transform, so that any data that comes in
  11469. // will get processed, now that we've asked for it.
  11470. ts.needTransform = true;
  11471. }
  11472. };
  11473. Transform.prototype._destroy = function (err, cb) {
  11474. var _this = this;
  11475. Duplex.prototype._destroy.call(this, err, function (err2) {
  11476. cb(err2);
  11477. _this.emit('close');
  11478. });
  11479. };
  11480. function done(stream, er, data) {
  11481. if (er) return stream.emit('error', er);
  11482. if (data !== null && data !== undefined) stream.push(data);
  11483. // if there's nothing in the write buffer, then that means
  11484. // that nothing more will ever be provided
  11485. var ws = stream._writableState;
  11486. var ts = stream._transformState;
  11487. if (ws.length) throw new Error('Calling transform done when ws.length != 0');
  11488. if (ts.transforming) throw new Error('Calling transform done when still transforming');
  11489. return stream.push(null);
  11490. }
  11491. },{"./_stream_duplex":165,"core-util-is":134,"inherits":149}],169:[function(require,module,exports){
  11492. (function (process,global){
  11493. // Copyright Joyent, Inc. and other Node contributors.
  11494. //
  11495. // Permission is hereby granted, free of charge, to any person obtaining a
  11496. // copy of this software and associated documentation files (the
  11497. // "Software"), to deal in the Software without restriction, including
  11498. // without limitation the rights to use, copy, modify, merge, publish,
  11499. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11500. // persons to whom the Software is furnished to do so, subject to the
  11501. // following conditions:
  11502. //
  11503. // The above copyright notice and this permission notice shall be included
  11504. // in all copies or substantial portions of the Software.
  11505. //
  11506. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11507. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11508. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11509. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11510. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11511. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11512. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11513. // A bit simpler than readable streams.
  11514. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  11515. // the drain event emission and buffering.
  11516. 'use strict';
  11517. /*<replacement>*/
  11518. var _defineProperty = require('babel-runtime/core-js/object/define-property');
  11519. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  11520. var _hasInstance = require('babel-runtime/core-js/symbol/has-instance');
  11521. var _hasInstance2 = _interopRequireDefault(_hasInstance);
  11522. var _symbol = require('babel-runtime/core-js/symbol');
  11523. var _symbol2 = _interopRequireDefault(_symbol);
  11524. var _setImmediate2 = require('babel-runtime/core-js/set-immediate');
  11525. var _setImmediate3 = _interopRequireDefault(_setImmediate2);
  11526. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11527. var processNextTick = require('process-nextick-args');
  11528. /*</replacement>*/
  11529. module.exports = Writable;
  11530. /* <replacement> */
  11531. function WriteReq(chunk, encoding, cb) {
  11532. this.chunk = chunk;
  11533. this.encoding = encoding;
  11534. this.callback = cb;
  11535. this.next = null;
  11536. }
  11537. // It seems a linked list but it is not
  11538. // there will be only 2 of these for each stream
  11539. function CorkedRequest(state) {
  11540. var _this = this;
  11541. this.next = null;
  11542. this.entry = null;
  11543. this.finish = function () {
  11544. onCorkedFinish(_this, state);
  11545. };
  11546. }
  11547. /* </replacement> */
  11548. /*<replacement>*/
  11549. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? _setImmediate3.default : processNextTick;
  11550. /*</replacement>*/
  11551. /*<replacement>*/
  11552. var Duplex;
  11553. /*</replacement>*/
  11554. Writable.WritableState = WritableState;
  11555. /*<replacement>*/
  11556. var util = require('core-util-is');
  11557. util.inherits = require('inherits');
  11558. /*</replacement>*/
  11559. /*<replacement>*/
  11560. var internalUtil = {
  11561. deprecate: require('util-deprecate')
  11562. };
  11563. /*</replacement>*/
  11564. /*<replacement>*/
  11565. var Stream = require('./internal/streams/stream');
  11566. /*</replacement>*/
  11567. /*<replacement>*/
  11568. var Buffer = require('safe-buffer').Buffer;
  11569. var OurUint8Array = global.Uint8Array || function () {};
  11570. function _uint8ArrayToBuffer(chunk) {
  11571. return Buffer.from(chunk);
  11572. }
  11573. function _isUint8Array(obj) {
  11574. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  11575. }
  11576. /*</replacement>*/
  11577. var destroyImpl = require('./internal/streams/destroy');
  11578. util.inherits(Writable, Stream);
  11579. function nop() {}
  11580. function WritableState(options, stream) {
  11581. Duplex = Duplex || require('./_stream_duplex');
  11582. options = options || {};
  11583. // object stream flag to indicate whether or not this stream
  11584. // contains buffers or objects.
  11585. this.objectMode = !!options.objectMode;
  11586. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  11587. // the point at which write() starts returning false
  11588. // Note: 0 is a valid value, means that we always return false if
  11589. // the entire buffer is not flushed immediately on write()
  11590. var hwm = options.highWaterMark;
  11591. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  11592. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  11593. // cast to ints.
  11594. this.highWaterMark = Math.floor(this.highWaterMark);
  11595. // if _final has been called
  11596. this.finalCalled = false;
  11597. // drain event flag.
  11598. this.needDrain = false;
  11599. // at the start of calling end()
  11600. this.ending = false;
  11601. // when end() has been called, and returned
  11602. this.ended = false;
  11603. // when 'finish' is emitted
  11604. this.finished = false;
  11605. // has it been destroyed
  11606. this.destroyed = false;
  11607. // should we decode strings into buffers before passing to _write?
  11608. // this is here so that some node-core streams can optimize string
  11609. // handling at a lower level.
  11610. var noDecode = options.decodeStrings === false;
  11611. this.decodeStrings = !noDecode;
  11612. // Crypto is kind of old and crusty. Historically, its default string
  11613. // encoding is 'binary' so we have to make this configurable.
  11614. // Everything else in the universe uses 'utf8', though.
  11615. this.defaultEncoding = options.defaultEncoding || 'utf8';
  11616. // not an actual buffer we keep track of, but a measurement
  11617. // of how much we're waiting to get pushed to some underlying
  11618. // socket or file.
  11619. this.length = 0;
  11620. // a flag to see when we're in the middle of a write.
  11621. this.writing = false;
  11622. // when true all writes will be buffered until .uncork() call
  11623. this.corked = 0;
  11624. // a flag to be able to tell if the onwrite cb is called immediately,
  11625. // or on a later tick. We set this to true at first, because any
  11626. // actions that shouldn't happen until "later" should generally also
  11627. // not happen before the first write call.
  11628. this.sync = true;
  11629. // a flag to know if we're processing previously buffered items, which
  11630. // may call the _write() callback in the same tick, so that we don't
  11631. // end up in an overlapped onwrite situation.
  11632. this.bufferProcessing = false;
  11633. // the callback that's passed to _write(chunk,cb)
  11634. this.onwrite = function (er) {
  11635. onwrite(stream, er);
  11636. };
  11637. // the callback that the user supplies to write(chunk,encoding,cb)
  11638. this.writecb = null;
  11639. // the amount that is being written when _write is called.
  11640. this.writelen = 0;
  11641. this.bufferedRequest = null;
  11642. this.lastBufferedRequest = null;
  11643. // number of pending user-supplied write callbacks
  11644. // this must be 0 before 'finish' can be emitted
  11645. this.pendingcb = 0;
  11646. // emit prefinish if the only thing we're waiting for is _write cbs
  11647. // This is relevant for synchronous Transform streams
  11648. this.prefinished = false;
  11649. // True if the error was already emitted and should not be thrown again
  11650. this.errorEmitted = false;
  11651. // count buffered requests
  11652. this.bufferedRequestCount = 0;
  11653. // allocate the first CorkedRequest, there is always
  11654. // one allocated and free to use, and we maintain at most two
  11655. this.corkedRequestsFree = new CorkedRequest(this);
  11656. }
  11657. WritableState.prototype.getBuffer = function getBuffer() {
  11658. var current = this.bufferedRequest;
  11659. var out = [];
  11660. while (current) {
  11661. out.push(current);
  11662. current = current.next;
  11663. }
  11664. return out;
  11665. };
  11666. (function () {
  11667. try {
  11668. Object.defineProperty(WritableState.prototype, 'buffer', {
  11669. get: internalUtil.deprecate(function () {
  11670. return this.getBuffer();
  11671. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  11672. });
  11673. } catch (_) {}
  11674. })();
  11675. // Test _writableState for inheritance to account for Duplex streams,
  11676. // whose prototype chain only points to Readable.
  11677. var realHasInstance;
  11678. if (typeof _symbol2.default === 'function' && _hasInstance2.default && typeof Function.prototype[_hasInstance2.default] === 'function') {
  11679. realHasInstance = Function.prototype[_hasInstance2.default];
  11680. (0, _defineProperty2.default)(Writable, _hasInstance2.default, {
  11681. value: function value(object) {
  11682. if (realHasInstance.call(this, object)) return true;
  11683. return object && object._writableState instanceof WritableState;
  11684. }
  11685. });
  11686. } else {
  11687. realHasInstance = function realHasInstance(object) {
  11688. return object instanceof this;
  11689. };
  11690. }
  11691. function Writable(options) {
  11692. Duplex = Duplex || require('./_stream_duplex');
  11693. // Writable ctor is applied to Duplexes, too.
  11694. // `realHasInstance` is necessary because using plain `instanceof`
  11695. // would return false, as no `_writableState` property is attached.
  11696. // Trying to use the custom `instanceof` for Writable here will also break the
  11697. // Node.js LazyTransform implementation, which has a non-trivial getter for
  11698. // `_writableState` that would lead to infinite recursion.
  11699. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  11700. return new Writable(options);
  11701. }
  11702. this._writableState = new WritableState(options, this);
  11703. // legacy.
  11704. this.writable = true;
  11705. if (options) {
  11706. if (typeof options.write === 'function') this._write = options.write;
  11707. if (typeof options.writev === 'function') this._writev = options.writev;
  11708. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  11709. if (typeof options.final === 'function') this._final = options.final;
  11710. }
  11711. Stream.call(this);
  11712. }
  11713. // Otherwise people can pipe Writable streams, which is just wrong.
  11714. Writable.prototype.pipe = function () {
  11715. this.emit('error', new Error('Cannot pipe, not readable'));
  11716. };
  11717. function writeAfterEnd(stream, cb) {
  11718. var er = new Error('write after end');
  11719. // TODO: defer error events consistently everywhere, not just the cb
  11720. stream.emit('error', er);
  11721. processNextTick(cb, er);
  11722. }
  11723. // Checks that a user-supplied chunk is valid, especially for the particular
  11724. // mode the stream is in. Currently this means that `null` is never accepted
  11725. // and undefined/non-string values are only allowed in object mode.
  11726. function validChunk(stream, state, chunk, cb) {
  11727. var valid = true;
  11728. var er = false;
  11729. if (chunk === null) {
  11730. er = new TypeError('May not write null values to stream');
  11731. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  11732. er = new TypeError('Invalid non-string/buffer chunk');
  11733. }
  11734. if (er) {
  11735. stream.emit('error', er);
  11736. processNextTick(cb, er);
  11737. valid = false;
  11738. }
  11739. return valid;
  11740. }
  11741. Writable.prototype.write = function (chunk, encoding, cb) {
  11742. var state = this._writableState;
  11743. var ret = false;
  11744. var isBuf = _isUint8Array(chunk) && !state.objectMode;
  11745. if (isBuf && !Buffer.isBuffer(chunk)) {
  11746. chunk = _uint8ArrayToBuffer(chunk);
  11747. }
  11748. if (typeof encoding === 'function') {
  11749. cb = encoding;
  11750. encoding = null;
  11751. }
  11752. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  11753. if (typeof cb !== 'function') cb = nop;
  11754. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  11755. state.pendingcb++;
  11756. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  11757. }
  11758. return ret;
  11759. };
  11760. Writable.prototype.cork = function () {
  11761. var state = this._writableState;
  11762. state.corked++;
  11763. };
  11764. Writable.prototype.uncork = function () {
  11765. var state = this._writableState;
  11766. if (state.corked) {
  11767. state.corked--;
  11768. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  11769. }
  11770. };
  11771. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  11772. // node::ParseEncoding() requires lower case.
  11773. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  11774. 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);
  11775. this._writableState.defaultEncoding = encoding;
  11776. return this;
  11777. };
  11778. function decodeChunk(state, chunk, encoding) {
  11779. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  11780. chunk = Buffer.from(chunk, encoding);
  11781. }
  11782. return chunk;
  11783. }
  11784. // if we're already writing something, then just put this
  11785. // in the queue, and wait our turn. Otherwise, call _write
  11786. // If we return false, then we need a drain event, so set that flag.
  11787. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  11788. if (!isBuf) {
  11789. var newChunk = decodeChunk(state, chunk, encoding);
  11790. if (chunk !== newChunk) {
  11791. isBuf = true;
  11792. encoding = 'buffer';
  11793. chunk = newChunk;
  11794. }
  11795. }
  11796. var len = state.objectMode ? 1 : chunk.length;
  11797. state.length += len;
  11798. var ret = state.length < state.highWaterMark;
  11799. // we must ensure that previous needDrain will not be reset to false.
  11800. if (!ret) state.needDrain = true;
  11801. if (state.writing || state.corked) {
  11802. var last = state.lastBufferedRequest;
  11803. state.lastBufferedRequest = {
  11804. chunk: chunk,
  11805. encoding: encoding,
  11806. isBuf: isBuf,
  11807. callback: cb,
  11808. next: null
  11809. };
  11810. if (last) {
  11811. last.next = state.lastBufferedRequest;
  11812. } else {
  11813. state.bufferedRequest = state.lastBufferedRequest;
  11814. }
  11815. state.bufferedRequestCount += 1;
  11816. } else {
  11817. doWrite(stream, state, false, len, chunk, encoding, cb);
  11818. }
  11819. return ret;
  11820. }
  11821. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  11822. state.writelen = len;
  11823. state.writecb = cb;
  11824. state.writing = true;
  11825. state.sync = true;
  11826. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  11827. state.sync = false;
  11828. }
  11829. function onwriteError(stream, state, sync, er, cb) {
  11830. --state.pendingcb;
  11831. if (sync) {
  11832. // defer the callback if we are being called synchronously
  11833. // to avoid piling up things on the stack
  11834. processNextTick(cb, er);
  11835. // this can emit finish, and it will always happen
  11836. // after error
  11837. processNextTick(finishMaybe, stream, state);
  11838. stream._writableState.errorEmitted = true;
  11839. stream.emit('error', er);
  11840. } else {
  11841. // the caller expect this to happen before if
  11842. // it is async
  11843. cb(er);
  11844. stream._writableState.errorEmitted = true;
  11845. stream.emit('error', er);
  11846. // this can emit finish, but finish must
  11847. // always follow error
  11848. finishMaybe(stream, state);
  11849. }
  11850. }
  11851. function onwriteStateUpdate(state) {
  11852. state.writing = false;
  11853. state.writecb = null;
  11854. state.length -= state.writelen;
  11855. state.writelen = 0;
  11856. }
  11857. function onwrite(stream, er) {
  11858. var state = stream._writableState;
  11859. var sync = state.sync;
  11860. var cb = state.writecb;
  11861. onwriteStateUpdate(state);
  11862. if (er) onwriteError(stream, state, sync, er, cb);else {
  11863. // Check if we're actually ready to finish, but don't emit yet
  11864. var finished = needFinish(state);
  11865. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  11866. clearBuffer(stream, state);
  11867. }
  11868. if (sync) {
  11869. /*<replacement>*/
  11870. asyncWrite(afterWrite, stream, state, finished, cb);
  11871. /*</replacement>*/
  11872. } else {
  11873. afterWrite(stream, state, finished, cb);
  11874. }
  11875. }
  11876. }
  11877. function afterWrite(stream, state, finished, cb) {
  11878. if (!finished) onwriteDrain(stream, state);
  11879. state.pendingcb--;
  11880. cb();
  11881. finishMaybe(stream, state);
  11882. }
  11883. // Must force callback to be called on nextTick, so that we don't
  11884. // emit 'drain' before the write() consumer gets the 'false' return
  11885. // value, and has a chance to attach a 'drain' listener.
  11886. function onwriteDrain(stream, state) {
  11887. if (state.length === 0 && state.needDrain) {
  11888. state.needDrain = false;
  11889. stream.emit('drain');
  11890. }
  11891. }
  11892. // if there's something in the buffer waiting, then process it
  11893. function clearBuffer(stream, state) {
  11894. state.bufferProcessing = true;
  11895. var entry = state.bufferedRequest;
  11896. if (stream._writev && entry && entry.next) {
  11897. // Fast case, write everything using _writev()
  11898. var l = state.bufferedRequestCount;
  11899. var buffer = new Array(l);
  11900. var holder = state.corkedRequestsFree;
  11901. holder.entry = entry;
  11902. var count = 0;
  11903. var allBuffers = true;
  11904. while (entry) {
  11905. buffer[count] = entry;
  11906. if (!entry.isBuf) allBuffers = false;
  11907. entry = entry.next;
  11908. count += 1;
  11909. }
  11910. buffer.allBuffers = allBuffers;
  11911. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  11912. // doWrite is almost always async, defer these to save a bit of time
  11913. // as the hot path ends with doWrite
  11914. state.pendingcb++;
  11915. state.lastBufferedRequest = null;
  11916. if (holder.next) {
  11917. state.corkedRequestsFree = holder.next;
  11918. holder.next = null;
  11919. } else {
  11920. state.corkedRequestsFree = new CorkedRequest(state);
  11921. }
  11922. } else {
  11923. // Slow case, write chunks one-by-one
  11924. while (entry) {
  11925. var chunk = entry.chunk;
  11926. var encoding = entry.encoding;
  11927. var cb = entry.callback;
  11928. var len = state.objectMode ? 1 : chunk.length;
  11929. doWrite(stream, state, false, len, chunk, encoding, cb);
  11930. entry = entry.next;
  11931. // if we didn't call the onwrite immediately, then
  11932. // it means that we need to wait until it does.
  11933. // also, that means that the chunk and cb are currently
  11934. // being processed, so move the buffer counter past them.
  11935. if (state.writing) {
  11936. break;
  11937. }
  11938. }
  11939. if (entry === null) state.lastBufferedRequest = null;
  11940. }
  11941. state.bufferedRequestCount = 0;
  11942. state.bufferedRequest = entry;
  11943. state.bufferProcessing = false;
  11944. }
  11945. Writable.prototype._write = function (chunk, encoding, cb) {
  11946. cb(new Error('_write() is not implemented'));
  11947. };
  11948. Writable.prototype._writev = null;
  11949. Writable.prototype.end = function (chunk, encoding, cb) {
  11950. var state = this._writableState;
  11951. if (typeof chunk === 'function') {
  11952. cb = chunk;
  11953. chunk = null;
  11954. encoding = null;
  11955. } else if (typeof encoding === 'function') {
  11956. cb = encoding;
  11957. encoding = null;
  11958. }
  11959. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  11960. // .end() fully uncorks
  11961. if (state.corked) {
  11962. state.corked = 1;
  11963. this.uncork();
  11964. }
  11965. // ignore unnecessary end() calls.
  11966. if (!state.ending && !state.finished) endWritable(this, state, cb);
  11967. };
  11968. function needFinish(state) {
  11969. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  11970. }
  11971. function callFinal(stream, state) {
  11972. stream._final(function (err) {
  11973. state.pendingcb--;
  11974. if (err) {
  11975. stream.emit('error', err);
  11976. }
  11977. state.prefinished = true;
  11978. stream.emit('prefinish');
  11979. finishMaybe(stream, state);
  11980. });
  11981. }
  11982. function prefinish(stream, state) {
  11983. if (!state.prefinished && !state.finalCalled) {
  11984. if (typeof stream._final === 'function') {
  11985. state.pendingcb++;
  11986. state.finalCalled = true;
  11987. processNextTick(callFinal, stream, state);
  11988. } else {
  11989. state.prefinished = true;
  11990. stream.emit('prefinish');
  11991. }
  11992. }
  11993. }
  11994. function finishMaybe(stream, state) {
  11995. var need = needFinish(state);
  11996. if (need) {
  11997. prefinish(stream, state);
  11998. if (state.pendingcb === 0) {
  11999. state.finished = true;
  12000. stream.emit('finish');
  12001. }
  12002. }
  12003. return need;
  12004. }
  12005. function endWritable(stream, state, cb) {
  12006. state.ending = true;
  12007. finishMaybe(stream, state);
  12008. if (cb) {
  12009. if (state.finished) processNextTick(cb);else stream.once('finish', cb);
  12010. }
  12011. state.ended = true;
  12012. stream.writable = false;
  12013. }
  12014. function onCorkedFinish(corkReq, state, err) {
  12015. var entry = corkReq.entry;
  12016. corkReq.entry = null;
  12017. while (entry) {
  12018. var cb = entry.callback;
  12019. state.pendingcb--;
  12020. cb(err);
  12021. entry = entry.next;
  12022. }
  12023. if (state.corkedRequestsFree) {
  12024. state.corkedRequestsFree.next = corkReq;
  12025. } else {
  12026. state.corkedRequestsFree = corkReq;
  12027. }
  12028. }
  12029. Object.defineProperty(Writable.prototype, 'destroyed', {
  12030. get: function get() {
  12031. if (this._writableState === undefined) {
  12032. return false;
  12033. }
  12034. return this._writableState.destroyed;
  12035. },
  12036. set: function set(value) {
  12037. // we ignore the value if the stream
  12038. // has not been initialized yet
  12039. if (!this._writableState) {
  12040. return;
  12041. }
  12042. // backward compatibility, the user is explicitly
  12043. // managing destroyed
  12044. this._writableState.destroyed = value;
  12045. }
  12046. });
  12047. Writable.prototype.destroy = destroyImpl.destroy;
  12048. Writable.prototype._undestroy = destroyImpl.undestroy;
  12049. Writable.prototype._destroy = function (err, cb) {
  12050. this.end();
  12051. cb(err);
  12052. };
  12053. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  12054. },{"./_stream_duplex":165,"./internal/streams/destroy":171,"./internal/streams/stream":172,"_process":159,"babel-runtime/core-js/object/define-property":15,"babel-runtime/core-js/set-immediate":19,"babel-runtime/core-js/symbol":21,"babel-runtime/core-js/symbol/has-instance":22,"core-util-is":134,"inherits":149,"process-nextick-args":158,"safe-buffer":181,"util-deprecate":193}],170:[function(require,module,exports){
  12055. 'use strict';
  12056. /*<replacement>*/
  12057. function _classCallCheck(instance, Constructor) {
  12058. if (!(instance instanceof Constructor)) {
  12059. throw new TypeError("Cannot call a class as a function");
  12060. }
  12061. }
  12062. var Buffer = require('safe-buffer').Buffer;
  12063. /*</replacement>*/
  12064. function copyBuffer(src, target, offset) {
  12065. src.copy(target, offset);
  12066. }
  12067. module.exports = function () {
  12068. function BufferList() {
  12069. _classCallCheck(this, BufferList);
  12070. this.head = null;
  12071. this.tail = null;
  12072. this.length = 0;
  12073. }
  12074. BufferList.prototype.push = function push(v) {
  12075. var entry = { data: v, next: null };
  12076. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  12077. this.tail = entry;
  12078. ++this.length;
  12079. };
  12080. BufferList.prototype.unshift = function unshift(v) {
  12081. var entry = { data: v, next: this.head };
  12082. if (this.length === 0) this.tail = entry;
  12083. this.head = entry;
  12084. ++this.length;
  12085. };
  12086. BufferList.prototype.shift = function shift() {
  12087. if (this.length === 0) return;
  12088. var ret = this.head.data;
  12089. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  12090. --this.length;
  12091. return ret;
  12092. };
  12093. BufferList.prototype.clear = function clear() {
  12094. this.head = this.tail = null;
  12095. this.length = 0;
  12096. };
  12097. BufferList.prototype.join = function join(s) {
  12098. if (this.length === 0) return '';
  12099. var p = this.head;
  12100. var ret = '' + p.data;
  12101. while (p = p.next) {
  12102. ret += s + p.data;
  12103. }return ret;
  12104. };
  12105. BufferList.prototype.concat = function concat(n) {
  12106. if (this.length === 0) return Buffer.alloc(0);
  12107. if (this.length === 1) return this.head.data;
  12108. var ret = Buffer.allocUnsafe(n >>> 0);
  12109. var p = this.head;
  12110. var i = 0;
  12111. while (p) {
  12112. copyBuffer(p.data, ret, i);
  12113. i += p.data.length;
  12114. p = p.next;
  12115. }
  12116. return ret;
  12117. };
  12118. return BufferList;
  12119. }();
  12120. },{"safe-buffer":181}],171:[function(require,module,exports){
  12121. 'use strict';
  12122. /*<replacement>*/
  12123. var processNextTick = require('process-nextick-args');
  12124. /*</replacement>*/
  12125. // undocumented cb() API, needed for core, not for public API
  12126. function destroy(err, cb) {
  12127. var _this = this;
  12128. var readableDestroyed = this._readableState && this._readableState.destroyed;
  12129. var writableDestroyed = this._writableState && this._writableState.destroyed;
  12130. if (readableDestroyed || writableDestroyed) {
  12131. if (cb) {
  12132. cb(err);
  12133. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  12134. processNextTick(emitErrorNT, this, err);
  12135. }
  12136. return;
  12137. }
  12138. // we set destroyed to true before firing error callbacks in order
  12139. // to make it re-entrance safe in case destroy() is called within callbacks
  12140. if (this._readableState) {
  12141. this._readableState.destroyed = true;
  12142. }
  12143. // if this is a duplex stream mark the writable part as destroyed as well
  12144. if (this._writableState) {
  12145. this._writableState.destroyed = true;
  12146. }
  12147. this._destroy(err || null, function (err) {
  12148. if (!cb && err) {
  12149. processNextTick(emitErrorNT, _this, err);
  12150. if (_this._writableState) {
  12151. _this._writableState.errorEmitted = true;
  12152. }
  12153. } else if (cb) {
  12154. cb(err);
  12155. }
  12156. });
  12157. }
  12158. function undestroy() {
  12159. if (this._readableState) {
  12160. this._readableState.destroyed = false;
  12161. this._readableState.reading = false;
  12162. this._readableState.ended = false;
  12163. this._readableState.endEmitted = false;
  12164. }
  12165. if (this._writableState) {
  12166. this._writableState.destroyed = false;
  12167. this._writableState.ended = false;
  12168. this._writableState.ending = false;
  12169. this._writableState.finished = false;
  12170. this._writableState.errorEmitted = false;
  12171. }
  12172. }
  12173. function emitErrorNT(self, err) {
  12174. self.emit('error', err);
  12175. }
  12176. module.exports = {
  12177. destroy: destroy,
  12178. undestroy: undestroy
  12179. };
  12180. },{"process-nextick-args":158}],172:[function(require,module,exports){
  12181. 'use strict';
  12182. module.exports = require('events').EventEmitter;
  12183. },{"events":145}],173:[function(require,module,exports){
  12184. arguments[4][32][0].apply(exports,arguments)
  12185. },{"dup":32}],174:[function(require,module,exports){
  12186. 'use strict';
  12187. var Buffer = require('safe-buffer').Buffer;
  12188. var isEncoding = Buffer.isEncoding || function (encoding) {
  12189. encoding = '' + encoding;
  12190. switch (encoding && encoding.toLowerCase()) {
  12191. 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':
  12192. return true;
  12193. default:
  12194. return false;
  12195. }
  12196. };
  12197. function _normalizeEncoding(enc) {
  12198. if (!enc) return 'utf8';
  12199. var retried;
  12200. while (true) {
  12201. switch (enc) {
  12202. case 'utf8':
  12203. case 'utf-8':
  12204. return 'utf8';
  12205. case 'ucs2':
  12206. case 'ucs-2':
  12207. case 'utf16le':
  12208. case 'utf-16le':
  12209. return 'utf16le';
  12210. case 'latin1':
  12211. case 'binary':
  12212. return 'latin1';
  12213. case 'base64':
  12214. case 'ascii':
  12215. case 'hex':
  12216. return enc;
  12217. default:
  12218. if (retried) return; // undefined
  12219. enc = ('' + enc).toLowerCase();
  12220. retried = true;
  12221. }
  12222. }
  12223. };
  12224. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  12225. // modules monkey-patch it to support additional encodings
  12226. function normalizeEncoding(enc) {
  12227. var nenc = _normalizeEncoding(enc);
  12228. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  12229. return nenc || enc;
  12230. }
  12231. // StringDecoder provides an interface for efficiently splitting a series of
  12232. // buffers into a series of JS strings without breaking apart multi-byte
  12233. // characters.
  12234. exports.StringDecoder = StringDecoder;
  12235. function StringDecoder(encoding) {
  12236. this.encoding = normalizeEncoding(encoding);
  12237. var nb;
  12238. switch (this.encoding) {
  12239. case 'utf16le':
  12240. this.text = utf16Text;
  12241. this.end = utf16End;
  12242. nb = 4;
  12243. break;
  12244. case 'utf8':
  12245. this.fillLast = utf8FillLast;
  12246. nb = 4;
  12247. break;
  12248. case 'base64':
  12249. this.text = base64Text;
  12250. this.end = base64End;
  12251. nb = 3;
  12252. break;
  12253. default:
  12254. this.write = simpleWrite;
  12255. this.end = simpleEnd;
  12256. return;
  12257. }
  12258. this.lastNeed = 0;
  12259. this.lastTotal = 0;
  12260. this.lastChar = Buffer.allocUnsafe(nb);
  12261. }
  12262. StringDecoder.prototype.write = function (buf) {
  12263. if (buf.length === 0) return '';
  12264. var r;
  12265. var i;
  12266. if (this.lastNeed) {
  12267. r = this.fillLast(buf);
  12268. if (r === undefined) return '';
  12269. i = this.lastNeed;
  12270. this.lastNeed = 0;
  12271. } else {
  12272. i = 0;
  12273. }
  12274. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  12275. return r || '';
  12276. };
  12277. StringDecoder.prototype.end = utf8End;
  12278. // Returns only complete characters in a Buffer
  12279. StringDecoder.prototype.text = utf8Text;
  12280. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  12281. StringDecoder.prototype.fillLast = function (buf) {
  12282. if (this.lastNeed <= buf.length) {
  12283. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  12284. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  12285. }
  12286. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  12287. this.lastNeed -= buf.length;
  12288. };
  12289. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  12290. // continuation byte.
  12291. function utf8CheckByte(byte) {
  12292. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  12293. return -1;
  12294. }
  12295. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  12296. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  12297. // needed to complete the UTF-8 character (if applicable) are returned.
  12298. function utf8CheckIncomplete(self, buf, i) {
  12299. var j = buf.length - 1;
  12300. if (j < i) return 0;
  12301. var nb = utf8CheckByte(buf[j]);
  12302. if (nb >= 0) {
  12303. if (nb > 0) self.lastNeed = nb - 1;
  12304. return nb;
  12305. }
  12306. if (--j < i) return 0;
  12307. nb = utf8CheckByte(buf[j]);
  12308. if (nb >= 0) {
  12309. if (nb > 0) self.lastNeed = nb - 2;
  12310. return nb;
  12311. }
  12312. if (--j < i) return 0;
  12313. nb = utf8CheckByte(buf[j]);
  12314. if (nb >= 0) {
  12315. if (nb > 0) {
  12316. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  12317. }
  12318. return nb;
  12319. }
  12320. return 0;
  12321. }
  12322. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  12323. // needed or are available. If we see a non-continuation byte where we expect
  12324. // one, we "replace" the validated continuation bytes we've seen so far with
  12325. // UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
  12326. // behavior. The continuation byte check is included three times in the case
  12327. // where all of the continuation bytes for a character exist in the same buffer.
  12328. // It is also done this way as a slight performance increase instead of using a
  12329. // loop.
  12330. function utf8CheckExtraBytes(self, buf, p) {
  12331. if ((buf[0] & 0xC0) !== 0x80) {
  12332. self.lastNeed = 0;
  12333. return '\uFFFD'.repeat(p);
  12334. }
  12335. if (self.lastNeed > 1 && buf.length > 1) {
  12336. if ((buf[1] & 0xC0) !== 0x80) {
  12337. self.lastNeed = 1;
  12338. return '\uFFFD'.repeat(p + 1);
  12339. }
  12340. if (self.lastNeed > 2 && buf.length > 2) {
  12341. if ((buf[2] & 0xC0) !== 0x80) {
  12342. self.lastNeed = 2;
  12343. return '\uFFFD'.repeat(p + 2);
  12344. }
  12345. }
  12346. }
  12347. }
  12348. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  12349. function utf8FillLast(buf) {
  12350. var p = this.lastTotal - this.lastNeed;
  12351. var r = utf8CheckExtraBytes(this, buf, p);
  12352. if (r !== undefined) return r;
  12353. if (this.lastNeed <= buf.length) {
  12354. buf.copy(this.lastChar, p, 0, this.lastNeed);
  12355. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  12356. }
  12357. buf.copy(this.lastChar, p, 0, buf.length);
  12358. this.lastNeed -= buf.length;
  12359. }
  12360. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  12361. // partial character, the character's bytes are buffered until the required
  12362. // number of bytes are available.
  12363. function utf8Text(buf, i) {
  12364. var total = utf8CheckIncomplete(this, buf, i);
  12365. if (!this.lastNeed) return buf.toString('utf8', i);
  12366. this.lastTotal = total;
  12367. var end = buf.length - (total - this.lastNeed);
  12368. buf.copy(this.lastChar, 0, end);
  12369. return buf.toString('utf8', i, end);
  12370. }
  12371. // For UTF-8, a replacement character for each buffered byte of a (partial)
  12372. // character needs to be added to the output.
  12373. function utf8End(buf) {
  12374. var r = buf && buf.length ? this.write(buf) : '';
  12375. if (this.lastNeed) return r + '\uFFFD'.repeat(this.lastTotal - this.lastNeed);
  12376. return r;
  12377. }
  12378. // UTF-16LE typically needs two bytes per character, but even if we have an even
  12379. // number of bytes available, we need to check if we end on a leading/high
  12380. // surrogate. In that case, we need to wait for the next two bytes in order to
  12381. // decode the last character properly.
  12382. function utf16Text(buf, i) {
  12383. if ((buf.length - i) % 2 === 0) {
  12384. var r = buf.toString('utf16le', i);
  12385. if (r) {
  12386. var c = r.charCodeAt(r.length - 1);
  12387. if (c >= 0xD800 && c <= 0xDBFF) {
  12388. this.lastNeed = 2;
  12389. this.lastTotal = 4;
  12390. this.lastChar[0] = buf[buf.length - 2];
  12391. this.lastChar[1] = buf[buf.length - 1];
  12392. return r.slice(0, -1);
  12393. }
  12394. }
  12395. return r;
  12396. }
  12397. this.lastNeed = 1;
  12398. this.lastTotal = 2;
  12399. this.lastChar[0] = buf[buf.length - 1];
  12400. return buf.toString('utf16le', i, buf.length - 1);
  12401. }
  12402. // For UTF-16LE we do not explicitly append special replacement characters if we
  12403. // end on a partial character, we simply let v8 handle that.
  12404. function utf16End(buf) {
  12405. var r = buf && buf.length ? this.write(buf) : '';
  12406. if (this.lastNeed) {
  12407. var end = this.lastTotal - this.lastNeed;
  12408. return r + this.lastChar.toString('utf16le', 0, end);
  12409. }
  12410. return r;
  12411. }
  12412. function base64Text(buf, i) {
  12413. var n = (buf.length - i) % 3;
  12414. if (n === 0) return buf.toString('base64', i);
  12415. this.lastNeed = 3 - n;
  12416. this.lastTotal = 3;
  12417. if (n === 1) {
  12418. this.lastChar[0] = buf[buf.length - 1];
  12419. } else {
  12420. this.lastChar[0] = buf[buf.length - 2];
  12421. this.lastChar[1] = buf[buf.length - 1];
  12422. }
  12423. return buf.toString('base64', i, buf.length - n);
  12424. }
  12425. function base64End(buf) {
  12426. var r = buf && buf.length ? this.write(buf) : '';
  12427. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  12428. return r;
  12429. }
  12430. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  12431. function simpleWrite(buf) {
  12432. return buf.toString(this.encoding);
  12433. }
  12434. function simpleEnd(buf) {
  12435. return buf && buf.length ? this.write(buf) : '';
  12436. }
  12437. },{"safe-buffer":181}],175:[function(require,module,exports){
  12438. module.exports = require('./readable').PassThrough
  12439. },{"./readable":176}],176:[function(require,module,exports){
  12440. exports = module.exports = require('./lib/_stream_readable.js');
  12441. exports.Stream = exports;
  12442. exports.Readable = exports;
  12443. exports.Writable = require('./lib/_stream_writable.js');
  12444. exports.Duplex = require('./lib/_stream_duplex.js');
  12445. exports.Transform = require('./lib/_stream_transform.js');
  12446. exports.PassThrough = require('./lib/_stream_passthrough.js');
  12447. },{"./lib/_stream_duplex.js":165,"./lib/_stream_passthrough.js":166,"./lib/_stream_readable.js":167,"./lib/_stream_transform.js":168,"./lib/_stream_writable.js":169}],177:[function(require,module,exports){
  12448. module.exports = require('./readable').Transform
  12449. },{"./readable":176}],178:[function(require,module,exports){
  12450. module.exports = require('./lib/_stream_writable.js');
  12451. },{"./lib/_stream_writable.js":169}],179:[function(require,module,exports){
  12452. // This method of obtaining a reference to the global object needs to be
  12453. // kept identical to the way it is obtained in runtime.js
  12454. var g = (function() { return this })() || Function("return this")();
  12455. // Use `getOwnPropertyNames` because not all browsers support calling
  12456. // `hasOwnProperty` on the global `self` object in a worker. See #183.
  12457. var hadRuntime = g.regeneratorRuntime &&
  12458. Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  12459. // Save the old regeneratorRuntime in case it needs to be restored later.
  12460. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  12461. // Force reevalutation of runtime.js.
  12462. g.regeneratorRuntime = undefined;
  12463. module.exports = require("./runtime");
  12464. if (hadRuntime) {
  12465. // Restore the original runtime.
  12466. g.regeneratorRuntime = oldRuntime;
  12467. } else {
  12468. // Remove the global property added by runtime.js.
  12469. try {
  12470. delete g.regeneratorRuntime;
  12471. } catch(e) {
  12472. g.regeneratorRuntime = undefined;
  12473. }
  12474. }
  12475. },{"./runtime":180}],180:[function(require,module,exports){
  12476. /**
  12477. * Copyright (c) 2014, Facebook, Inc.
  12478. * All rights reserved.
  12479. *
  12480. * This source code is licensed under the BSD-style license found in the
  12481. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  12482. * additional grant of patent rights can be found in the PATENTS file in
  12483. * the same directory.
  12484. */
  12485. !(function(global) {
  12486. "use strict";
  12487. var Op = Object.prototype;
  12488. var hasOwn = Op.hasOwnProperty;
  12489. var undefined; // More compressible than void 0.
  12490. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  12491. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  12492. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  12493. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  12494. var inModule = typeof module === "object";
  12495. var runtime = global.regeneratorRuntime;
  12496. if (runtime) {
  12497. if (inModule) {
  12498. // If regeneratorRuntime is defined globally and we're in a module,
  12499. // make the exports object identical to regeneratorRuntime.
  12500. module.exports = runtime;
  12501. }
  12502. // Don't bother evaluating the rest of this file if the runtime was
  12503. // already defined globally.
  12504. return;
  12505. }
  12506. // Define the runtime globally (as expected by generated code) as either
  12507. // module.exports (if we're in a module) or a new, empty object.
  12508. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  12509. function wrap(innerFn, outerFn, self, tryLocsList) {
  12510. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  12511. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  12512. var generator = Object.create(protoGenerator.prototype);
  12513. var context = new Context(tryLocsList || []);
  12514. // The ._invoke method unifies the implementations of the .next,
  12515. // .throw, and .return methods.
  12516. generator._invoke = makeInvokeMethod(innerFn, self, context);
  12517. return generator;
  12518. }
  12519. runtime.wrap = wrap;
  12520. // Try/catch helper to minimize deoptimizations. Returns a completion
  12521. // record like context.tryEntries[i].completion. This interface could
  12522. // have been (and was previously) designed to take a closure to be
  12523. // invoked without arguments, but in all the cases we care about we
  12524. // already have an existing method we want to call, so there's no need
  12525. // to create a new function object. We can even get away with assuming
  12526. // the method takes exactly one argument, since that happens to be true
  12527. // in every case, so we don't have to touch the arguments object. The
  12528. // only additional allocation required is the completion record, which
  12529. // has a stable shape and so hopefully should be cheap to allocate.
  12530. function tryCatch(fn, obj, arg) {
  12531. try {
  12532. return { type: "normal", arg: fn.call(obj, arg) };
  12533. } catch (err) {
  12534. return { type: "throw", arg: err };
  12535. }
  12536. }
  12537. var GenStateSuspendedStart = "suspendedStart";
  12538. var GenStateSuspendedYield = "suspendedYield";
  12539. var GenStateExecuting = "executing";
  12540. var GenStateCompleted = "completed";
  12541. // Returning this object from the innerFn has the same effect as
  12542. // breaking out of the dispatch switch statement.
  12543. var ContinueSentinel = {};
  12544. // Dummy constructor functions that we use as the .constructor and
  12545. // .constructor.prototype properties for functions that return Generator
  12546. // objects. For full spec compliance, you may wish to configure your
  12547. // minifier not to mangle the names of these two functions.
  12548. function Generator() {}
  12549. function GeneratorFunction() {}
  12550. function GeneratorFunctionPrototype() {}
  12551. // This is a polyfill for %IteratorPrototype% for environments that
  12552. // don't natively support it.
  12553. var IteratorPrototype = {};
  12554. IteratorPrototype[iteratorSymbol] = function () {
  12555. return this;
  12556. };
  12557. var getProto = Object.getPrototypeOf;
  12558. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  12559. if (NativeIteratorPrototype &&
  12560. NativeIteratorPrototype !== Op &&
  12561. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  12562. // This environment has a native %IteratorPrototype%; use it instead
  12563. // of the polyfill.
  12564. IteratorPrototype = NativeIteratorPrototype;
  12565. }
  12566. var Gp = GeneratorFunctionPrototype.prototype =
  12567. Generator.prototype = Object.create(IteratorPrototype);
  12568. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  12569. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  12570. GeneratorFunctionPrototype[toStringTagSymbol] =
  12571. GeneratorFunction.displayName = "GeneratorFunction";
  12572. // Helper for defining the .next, .throw, and .return methods of the
  12573. // Iterator interface in terms of a single ._invoke method.
  12574. function defineIteratorMethods(prototype) {
  12575. ["next", "throw", "return"].forEach(function(method) {
  12576. prototype[method] = function(arg) {
  12577. return this._invoke(method, arg);
  12578. };
  12579. });
  12580. }
  12581. runtime.isGeneratorFunction = function(genFun) {
  12582. var ctor = typeof genFun === "function" && genFun.constructor;
  12583. return ctor
  12584. ? ctor === GeneratorFunction ||
  12585. // For the native GeneratorFunction constructor, the best we can
  12586. // do is to check its .name property.
  12587. (ctor.displayName || ctor.name) === "GeneratorFunction"
  12588. : false;
  12589. };
  12590. runtime.mark = function(genFun) {
  12591. if (Object.setPrototypeOf) {
  12592. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  12593. } else {
  12594. genFun.__proto__ = GeneratorFunctionPrototype;
  12595. if (!(toStringTagSymbol in genFun)) {
  12596. genFun[toStringTagSymbol] = "GeneratorFunction";
  12597. }
  12598. }
  12599. genFun.prototype = Object.create(Gp);
  12600. return genFun;
  12601. };
  12602. // Within the body of any async function, `await x` is transformed to
  12603. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  12604. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  12605. // meant to be awaited.
  12606. runtime.awrap = function(arg) {
  12607. return { __await: arg };
  12608. };
  12609. function AsyncIterator(generator) {
  12610. function invoke(method, arg, resolve, reject) {
  12611. var record = tryCatch(generator[method], generator, arg);
  12612. if (record.type === "throw") {
  12613. reject(record.arg);
  12614. } else {
  12615. var result = record.arg;
  12616. var value = result.value;
  12617. if (value &&
  12618. typeof value === "object" &&
  12619. hasOwn.call(value, "__await")) {
  12620. return Promise.resolve(value.__await).then(function(value) {
  12621. invoke("next", value, resolve, reject);
  12622. }, function(err) {
  12623. invoke("throw", err, resolve, reject);
  12624. });
  12625. }
  12626. return Promise.resolve(value).then(function(unwrapped) {
  12627. // When a yielded Promise is resolved, its final value becomes
  12628. // the .value of the Promise<{value,done}> result for the
  12629. // current iteration. If the Promise is rejected, however, the
  12630. // result for this iteration will be rejected with the same
  12631. // reason. Note that rejections of yielded Promises are not
  12632. // thrown back into the generator function, as is the case
  12633. // when an awaited Promise is rejected. This difference in
  12634. // behavior between yield and await is important, because it
  12635. // allows the consumer to decide what to do with the yielded
  12636. // rejection (swallow it and continue, manually .throw it back
  12637. // into the generator, abandon iteration, whatever). With
  12638. // await, by contrast, there is no opportunity to examine the
  12639. // rejection reason outside the generator function, so the
  12640. // only option is to throw it from the await expression, and
  12641. // let the generator function handle the exception.
  12642. result.value = unwrapped;
  12643. resolve(result);
  12644. }, reject);
  12645. }
  12646. }
  12647. var previousPromise;
  12648. function enqueue(method, arg) {
  12649. function callInvokeWithMethodAndArg() {
  12650. return new Promise(function(resolve, reject) {
  12651. invoke(method, arg, resolve, reject);
  12652. });
  12653. }
  12654. return previousPromise =
  12655. // If enqueue has been called before, then we want to wait until
  12656. // all previous Promises have been resolved before calling invoke,
  12657. // so that results are always delivered in the correct order. If
  12658. // enqueue has not been called before, then it is important to
  12659. // call invoke immediately, without waiting on a callback to fire,
  12660. // so that the async generator function has the opportunity to do
  12661. // any necessary setup in a predictable way. This predictability
  12662. // is why the Promise constructor synchronously invokes its
  12663. // executor callback, and why async functions synchronously
  12664. // execute code before the first await. Since we implement simple
  12665. // async functions in terms of async generators, it is especially
  12666. // important to get this right, even though it requires care.
  12667. previousPromise ? previousPromise.then(
  12668. callInvokeWithMethodAndArg,
  12669. // Avoid propagating failures to Promises returned by later
  12670. // invocations of the iterator.
  12671. callInvokeWithMethodAndArg
  12672. ) : callInvokeWithMethodAndArg();
  12673. }
  12674. // Define the unified helper method that is used to implement .next,
  12675. // .throw, and .return (see defineIteratorMethods).
  12676. this._invoke = enqueue;
  12677. }
  12678. defineIteratorMethods(AsyncIterator.prototype);
  12679. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  12680. return this;
  12681. };
  12682. runtime.AsyncIterator = AsyncIterator;
  12683. // Note that simple async functions are implemented on top of
  12684. // AsyncIterator objects; they just return a Promise for the value of
  12685. // the final result produced by the iterator.
  12686. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  12687. var iter = new AsyncIterator(
  12688. wrap(innerFn, outerFn, self, tryLocsList)
  12689. );
  12690. return runtime.isGeneratorFunction(outerFn)
  12691. ? iter // If outerFn is a generator, return the full iterator.
  12692. : iter.next().then(function(result) {
  12693. return result.done ? result.value : iter.next();
  12694. });
  12695. };
  12696. function makeInvokeMethod(innerFn, self, context) {
  12697. var state = GenStateSuspendedStart;
  12698. return function invoke(method, arg) {
  12699. if (state === GenStateExecuting) {
  12700. throw new Error("Generator is already running");
  12701. }
  12702. if (state === GenStateCompleted) {
  12703. if (method === "throw") {
  12704. throw arg;
  12705. }
  12706. // Be forgiving, per 25.3.3.3.3 of the spec:
  12707. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  12708. return doneResult();
  12709. }
  12710. context.method = method;
  12711. context.arg = arg;
  12712. while (true) {
  12713. var delegate = context.delegate;
  12714. if (delegate) {
  12715. var delegateResult = maybeInvokeDelegate(delegate, context);
  12716. if (delegateResult) {
  12717. if (delegateResult === ContinueSentinel) continue;
  12718. return delegateResult;
  12719. }
  12720. }
  12721. if (context.method === "next") {
  12722. // Setting context._sent for legacy support of Babel's
  12723. // function.sent implementation.
  12724. context.sent = context._sent = context.arg;
  12725. } else if (context.method === "throw") {
  12726. if (state === GenStateSuspendedStart) {
  12727. state = GenStateCompleted;
  12728. throw context.arg;
  12729. }
  12730. context.dispatchException(context.arg);
  12731. } else if (context.method === "return") {
  12732. context.abrupt("return", context.arg);
  12733. }
  12734. state = GenStateExecuting;
  12735. var record = tryCatch(innerFn, self, context);
  12736. if (record.type === "normal") {
  12737. // If an exception is thrown from innerFn, we leave state ===
  12738. // GenStateExecuting and loop back for another invocation.
  12739. state = context.done
  12740. ? GenStateCompleted
  12741. : GenStateSuspendedYield;
  12742. if (record.arg === ContinueSentinel) {
  12743. continue;
  12744. }
  12745. return {
  12746. value: record.arg,
  12747. done: context.done
  12748. };
  12749. } else if (record.type === "throw") {
  12750. state = GenStateCompleted;
  12751. // Dispatch the exception by looping back around to the
  12752. // context.dispatchException(context.arg) call above.
  12753. context.method = "throw";
  12754. context.arg = record.arg;
  12755. }
  12756. }
  12757. };
  12758. }
  12759. // Call delegate.iterator[context.method](context.arg) and handle the
  12760. // result, either by returning a { value, done } result from the
  12761. // delegate iterator, or by modifying context.method and context.arg,
  12762. // setting context.delegate to null, and returning the ContinueSentinel.
  12763. function maybeInvokeDelegate(delegate, context) {
  12764. var method = delegate.iterator[context.method];
  12765. if (method === undefined) {
  12766. // A .throw or .return when the delegate iterator has no .throw
  12767. // method always terminates the yield* loop.
  12768. context.delegate = null;
  12769. if (context.method === "throw") {
  12770. if (delegate.iterator.return) {
  12771. // If the delegate iterator has a return method, give it a
  12772. // chance to clean up.
  12773. context.method = "return";
  12774. context.arg = undefined;
  12775. maybeInvokeDelegate(delegate, context);
  12776. if (context.method === "throw") {
  12777. // If maybeInvokeDelegate(context) changed context.method from
  12778. // "return" to "throw", let that override the TypeError below.
  12779. return ContinueSentinel;
  12780. }
  12781. }
  12782. context.method = "throw";
  12783. context.arg = new TypeError(
  12784. "The iterator does not provide a 'throw' method");
  12785. }
  12786. return ContinueSentinel;
  12787. }
  12788. var record = tryCatch(method, delegate.iterator, context.arg);
  12789. if (record.type === "throw") {
  12790. context.method = "throw";
  12791. context.arg = record.arg;
  12792. context.delegate = null;
  12793. return ContinueSentinel;
  12794. }
  12795. var info = record.arg;
  12796. if (! info) {
  12797. context.method = "throw";
  12798. context.arg = new TypeError("iterator result is not an object");
  12799. context.delegate = null;
  12800. return ContinueSentinel;
  12801. }
  12802. if (info.done) {
  12803. // Assign the result of the finished delegate to the temporary
  12804. // variable specified by delegate.resultName (see delegateYield).
  12805. context[delegate.resultName] = info.value;
  12806. // Resume execution at the desired location (see delegateYield).
  12807. context.next = delegate.nextLoc;
  12808. // If context.method was "throw" but the delegate handled the
  12809. // exception, let the outer generator proceed normally. If
  12810. // context.method was "next", forget context.arg since it has been
  12811. // "consumed" by the delegate iterator. If context.method was
  12812. // "return", allow the original .return call to continue in the
  12813. // outer generator.
  12814. if (context.method !== "return") {
  12815. context.method = "next";
  12816. context.arg = undefined;
  12817. }
  12818. } else {
  12819. // Re-yield the result returned by the delegate method.
  12820. return info;
  12821. }
  12822. // The delegate iterator is finished, so forget it and continue with
  12823. // the outer generator.
  12824. context.delegate = null;
  12825. return ContinueSentinel;
  12826. }
  12827. // Define Generator.prototype.{next,throw,return} in terms of the
  12828. // unified ._invoke helper method.
  12829. defineIteratorMethods(Gp);
  12830. Gp[toStringTagSymbol] = "Generator";
  12831. // A Generator should always return itself as the iterator object when the
  12832. // @@iterator function is called on it. Some browsers' implementations of the
  12833. // iterator prototype chain incorrectly implement this, causing the Generator
  12834. // object to not be returned from this call. This ensures that doesn't happen.
  12835. // See https://github.com/facebook/regenerator/issues/274 for more details.
  12836. Gp[iteratorSymbol] = function() {
  12837. return this;
  12838. };
  12839. Gp.toString = function() {
  12840. return "[object Generator]";
  12841. };
  12842. function pushTryEntry(locs) {
  12843. var entry = { tryLoc: locs[0] };
  12844. if (1 in locs) {
  12845. entry.catchLoc = locs[1];
  12846. }
  12847. if (2 in locs) {
  12848. entry.finallyLoc = locs[2];
  12849. entry.afterLoc = locs[3];
  12850. }
  12851. this.tryEntries.push(entry);
  12852. }
  12853. function resetTryEntry(entry) {
  12854. var record = entry.completion || {};
  12855. record.type = "normal";
  12856. delete record.arg;
  12857. entry.completion = record;
  12858. }
  12859. function Context(tryLocsList) {
  12860. // The root entry object (effectively a try statement without a catch
  12861. // or a finally block) gives us a place to store values thrown from
  12862. // locations where there is no enclosing try statement.
  12863. this.tryEntries = [{ tryLoc: "root" }];
  12864. tryLocsList.forEach(pushTryEntry, this);
  12865. this.reset(true);
  12866. }
  12867. runtime.keys = function(object) {
  12868. var keys = [];
  12869. for (var key in object) {
  12870. keys.push(key);
  12871. }
  12872. keys.reverse();
  12873. // Rather than returning an object with a next method, we keep
  12874. // things simple and return the next function itself.
  12875. return function next() {
  12876. while (keys.length) {
  12877. var key = keys.pop();
  12878. if (key in object) {
  12879. next.value = key;
  12880. next.done = false;
  12881. return next;
  12882. }
  12883. }
  12884. // To avoid creating an additional object, we just hang the .value
  12885. // and .done properties off the next function object itself. This
  12886. // also ensures that the minifier will not anonymize the function.
  12887. next.done = true;
  12888. return next;
  12889. };
  12890. };
  12891. function values(iterable) {
  12892. if (iterable) {
  12893. var iteratorMethod = iterable[iteratorSymbol];
  12894. if (iteratorMethod) {
  12895. return iteratorMethod.call(iterable);
  12896. }
  12897. if (typeof iterable.next === "function") {
  12898. return iterable;
  12899. }
  12900. if (!isNaN(iterable.length)) {
  12901. var i = -1, next = function next() {
  12902. while (++i < iterable.length) {
  12903. if (hasOwn.call(iterable, i)) {
  12904. next.value = iterable[i];
  12905. next.done = false;
  12906. return next;
  12907. }
  12908. }
  12909. next.value = undefined;
  12910. next.done = true;
  12911. return next;
  12912. };
  12913. return next.next = next;
  12914. }
  12915. }
  12916. // Return an iterator with no values.
  12917. return { next: doneResult };
  12918. }
  12919. runtime.values = values;
  12920. function doneResult() {
  12921. return { value: undefined, done: true };
  12922. }
  12923. Context.prototype = {
  12924. constructor: Context,
  12925. reset: function(skipTempReset) {
  12926. this.prev = 0;
  12927. this.next = 0;
  12928. // Resetting context._sent for legacy support of Babel's
  12929. // function.sent implementation.
  12930. this.sent = this._sent = undefined;
  12931. this.done = false;
  12932. this.delegate = null;
  12933. this.method = "next";
  12934. this.arg = undefined;
  12935. this.tryEntries.forEach(resetTryEntry);
  12936. if (!skipTempReset) {
  12937. for (var name in this) {
  12938. // Not sure about the optimal order of these conditions:
  12939. if (name.charAt(0) === "t" &&
  12940. hasOwn.call(this, name) &&
  12941. !isNaN(+name.slice(1))) {
  12942. this[name] = undefined;
  12943. }
  12944. }
  12945. }
  12946. },
  12947. stop: function() {
  12948. this.done = true;
  12949. var rootEntry = this.tryEntries[0];
  12950. var rootRecord = rootEntry.completion;
  12951. if (rootRecord.type === "throw") {
  12952. throw rootRecord.arg;
  12953. }
  12954. return this.rval;
  12955. },
  12956. dispatchException: function(exception) {
  12957. if (this.done) {
  12958. throw exception;
  12959. }
  12960. var context = this;
  12961. function handle(loc, caught) {
  12962. record.type = "throw";
  12963. record.arg = exception;
  12964. context.next = loc;
  12965. if (caught) {
  12966. // If the dispatched exception was caught by a catch block,
  12967. // then let that catch block handle the exception normally.
  12968. context.method = "next";
  12969. context.arg = undefined;
  12970. }
  12971. return !! caught;
  12972. }
  12973. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12974. var entry = this.tryEntries[i];
  12975. var record = entry.completion;
  12976. if (entry.tryLoc === "root") {
  12977. // Exception thrown outside of any try block that could handle
  12978. // it, so set the completion value of the entire function to
  12979. // throw the exception.
  12980. return handle("end");
  12981. }
  12982. if (entry.tryLoc <= this.prev) {
  12983. var hasCatch = hasOwn.call(entry, "catchLoc");
  12984. var hasFinally = hasOwn.call(entry, "finallyLoc");
  12985. if (hasCatch && hasFinally) {
  12986. if (this.prev < entry.catchLoc) {
  12987. return handle(entry.catchLoc, true);
  12988. } else if (this.prev < entry.finallyLoc) {
  12989. return handle(entry.finallyLoc);
  12990. }
  12991. } else if (hasCatch) {
  12992. if (this.prev < entry.catchLoc) {
  12993. return handle(entry.catchLoc, true);
  12994. }
  12995. } else if (hasFinally) {
  12996. if (this.prev < entry.finallyLoc) {
  12997. return handle(entry.finallyLoc);
  12998. }
  12999. } else {
  13000. throw new Error("try statement without catch or finally");
  13001. }
  13002. }
  13003. }
  13004. },
  13005. abrupt: function(type, arg) {
  13006. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  13007. var entry = this.tryEntries[i];
  13008. if (entry.tryLoc <= this.prev &&
  13009. hasOwn.call(entry, "finallyLoc") &&
  13010. this.prev < entry.finallyLoc) {
  13011. var finallyEntry = entry;
  13012. break;
  13013. }
  13014. }
  13015. if (finallyEntry &&
  13016. (type === "break" ||
  13017. type === "continue") &&
  13018. finallyEntry.tryLoc <= arg &&
  13019. arg <= finallyEntry.finallyLoc) {
  13020. // Ignore the finally entry if control is not jumping to a
  13021. // location outside the try/catch block.
  13022. finallyEntry = null;
  13023. }
  13024. var record = finallyEntry ? finallyEntry.completion : {};
  13025. record.type = type;
  13026. record.arg = arg;
  13027. if (finallyEntry) {
  13028. this.method = "next";
  13029. this.next = finallyEntry.finallyLoc;
  13030. return ContinueSentinel;
  13031. }
  13032. return this.complete(record);
  13033. },
  13034. complete: function(record, afterLoc) {
  13035. if (record.type === "throw") {
  13036. throw record.arg;
  13037. }
  13038. if (record.type === "break" ||
  13039. record.type === "continue") {
  13040. this.next = record.arg;
  13041. } else if (record.type === "return") {
  13042. this.rval = this.arg = record.arg;
  13043. this.method = "return";
  13044. this.next = "end";
  13045. } else if (record.type === "normal" && afterLoc) {
  13046. this.next = afterLoc;
  13047. }
  13048. return ContinueSentinel;
  13049. },
  13050. finish: function(finallyLoc) {
  13051. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  13052. var entry = this.tryEntries[i];
  13053. if (entry.finallyLoc === finallyLoc) {
  13054. this.complete(entry.completion, entry.afterLoc);
  13055. resetTryEntry(entry);
  13056. return ContinueSentinel;
  13057. }
  13058. }
  13059. },
  13060. "catch": function(tryLoc) {
  13061. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  13062. var entry = this.tryEntries[i];
  13063. if (entry.tryLoc === tryLoc) {
  13064. var record = entry.completion;
  13065. if (record.type === "throw") {
  13066. var thrown = record.arg;
  13067. resetTryEntry(entry);
  13068. }
  13069. return thrown;
  13070. }
  13071. }
  13072. // The context.catch method must only be called with a location
  13073. // argument that corresponds to a known catch block.
  13074. throw new Error("illegal catch attempt");
  13075. },
  13076. delegateYield: function(iterable, resultName, nextLoc) {
  13077. this.delegate = {
  13078. iterator: values(iterable),
  13079. resultName: resultName,
  13080. nextLoc: nextLoc
  13081. };
  13082. if (this.method === "next") {
  13083. // Deliberately forget the last sent value so that we don't
  13084. // accidentally pass it on to the delegate.
  13085. this.arg = undefined;
  13086. }
  13087. return ContinueSentinel;
  13088. }
  13089. };
  13090. })(
  13091. // In sloppy mode, unbound `this` refers to the global object, fallback to
  13092. // Function constructor if we're in global strict mode. That is sadly a form
  13093. // of indirect eval which violates Content Security Policy.
  13094. (function() { return this })() || Function("return this")()
  13095. );
  13096. },{}],181:[function(require,module,exports){
  13097. /* eslint-disable node/no-deprecated-api */
  13098. var buffer = require('buffer')
  13099. var Buffer = buffer.Buffer
  13100. // alternative to using Object.keys for old browsers
  13101. function copyProps (src, dst) {
  13102. for (var key in src) {
  13103. dst[key] = src[key]
  13104. }
  13105. }
  13106. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  13107. module.exports = buffer
  13108. } else {
  13109. // Copy properties from require('buffer')
  13110. copyProps(buffer, exports)
  13111. exports.Buffer = SafeBuffer
  13112. }
  13113. function SafeBuffer (arg, encodingOrOffset, length) {
  13114. return Buffer(arg, encodingOrOffset, length)
  13115. }
  13116. // Copy static methods from Buffer
  13117. copyProps(Buffer, SafeBuffer)
  13118. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  13119. if (typeof arg === 'number') {
  13120. throw new TypeError('Argument must not be a number')
  13121. }
  13122. return Buffer(arg, encodingOrOffset, length)
  13123. }
  13124. SafeBuffer.alloc = function (size, fill, encoding) {
  13125. if (typeof size !== 'number') {
  13126. throw new TypeError('Argument must be a number')
  13127. }
  13128. var buf = Buffer(size)
  13129. if (fill !== undefined) {
  13130. if (typeof encoding === 'string') {
  13131. buf.fill(fill, encoding)
  13132. } else {
  13133. buf.fill(fill)
  13134. }
  13135. } else {
  13136. buf.fill(0)
  13137. }
  13138. return buf
  13139. }
  13140. SafeBuffer.allocUnsafe = function (size) {
  13141. if (typeof size !== 'number') {
  13142. throw new TypeError('Argument must be a number')
  13143. }
  13144. return Buffer(size)
  13145. }
  13146. SafeBuffer.allocUnsafeSlow = function (size) {
  13147. if (typeof size !== 'number') {
  13148. throw new TypeError('Argument must be a number')
  13149. }
  13150. return buffer.SlowBuffer(size)
  13151. }
  13152. },{"buffer":31}],182:[function(require,module,exports){
  13153. (function (Buffer){
  13154. 'use strict';
  13155. var _fromCodePoint = require('babel-runtime/core-js/string/from-code-point');
  13156. var _fromCodePoint2 = _interopRequireDefault(_fromCodePoint);
  13157. var _stringify = require('babel-runtime/core-js/json/stringify');
  13158. var _stringify2 = _interopRequireDefault(_stringify);
  13159. var _typeof2 = require('babel-runtime/helpers/typeof');
  13160. var _typeof3 = _interopRequireDefault(_typeof2);
  13161. var _defineProperty = require('babel-runtime/core-js/object/define-property');
  13162. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  13163. var _keys = require('babel-runtime/core-js/object/keys');
  13164. var _keys2 = _interopRequireDefault(_keys);
  13165. var _create = require('babel-runtime/core-js/object/create');
  13166. var _create2 = _interopRequireDefault(_create);
  13167. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13168. ;(function (sax) {
  13169. // wrapper for non-node envs
  13170. sax.parser = function (strict, opt) {
  13171. return new SAXParser(strict, opt);
  13172. };
  13173. sax.SAXParser = SAXParser;
  13174. sax.SAXStream = SAXStream;
  13175. sax.createStream = createStream;
  13176. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  13177. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  13178. // since that's the earliest that a buffer overrun could occur. This way, checks are
  13179. // as rare as required, but as often as necessary to ensure never crossing this bound.
  13180. // Furthermore, buffers are only tested at most once per write(), so passing a very
  13181. // large string into write() might have undesirable effects, but this is manageable by
  13182. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  13183. // edge case, result in creating at most one complete copy of the string passed in.
  13184. // Set to Infinity to have unlimited buffers.
  13185. sax.MAX_BUFFER_LENGTH = 64 * 1024;
  13186. var buffers = ['comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', 'procInstName', 'procInstBody', 'entity', 'attribName', 'attribValue', 'cdata', 'script'];
  13187. sax.EVENTS = ['text', 'processinginstruction', 'sgmldeclaration', 'doctype', 'comment', 'opentagstart', 'attribute', 'opentag', 'closetag', 'opencdata', 'cdata', 'closecdata', 'error', 'end', 'ready', 'script', 'opennamespace', 'closenamespace'];
  13188. function SAXParser(strict, opt) {
  13189. if (!(this instanceof SAXParser)) {
  13190. return new SAXParser(strict, opt);
  13191. }
  13192. var parser = this;
  13193. clearBuffers(parser);
  13194. parser.q = parser.c = '';
  13195. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
  13196. parser.opt = opt || {};
  13197. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
  13198. parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase';
  13199. parser.tags = [];
  13200. parser.closed = parser.closedRoot = parser.sawRoot = false;
  13201. parser.tag = parser.error = null;
  13202. parser.strict = !!strict;
  13203. parser.noscript = !!(strict || parser.opt.noscript);
  13204. parser.state = S.BEGIN;
  13205. parser.strictEntities = parser.opt.strictEntities;
  13206. parser.ENTITIES = parser.strictEntities ? (0, _create2.default)(sax.XML_ENTITIES) : (0, _create2.default)(sax.ENTITIES);
  13207. parser.attribList = [];
  13208. // namespaces form a prototype chain.
  13209. // it always points at the current tag,
  13210. // which protos to its parent tag.
  13211. if (parser.opt.xmlns) {
  13212. parser.ns = (0, _create2.default)(rootNS);
  13213. }
  13214. // mostly just for error reporting
  13215. parser.trackPosition = parser.opt.position !== false;
  13216. if (parser.trackPosition) {
  13217. parser.position = parser.line = parser.column = 0;
  13218. }
  13219. emit(parser, 'onready');
  13220. }
  13221. if (!_create2.default) {
  13222. Object.create = function (o) {
  13223. function F() {}
  13224. F.prototype = o;
  13225. var newf = new F();
  13226. return newf;
  13227. };
  13228. }
  13229. if (!_keys2.default) {
  13230. Object.keys = function (o) {
  13231. var a = [];
  13232. for (var i in o) {
  13233. if (o.hasOwnProperty(i)) a.push(i);
  13234. }return a;
  13235. };
  13236. }
  13237. function checkBufferLength(parser) {
  13238. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
  13239. var maxActual = 0;
  13240. for (var i = 0, l = buffers.length; i < l; i++) {
  13241. var len = parser[buffers[i]].length;
  13242. if (len > maxAllowed) {
  13243. // Text/cdata nodes can get big, and since they're buffered,
  13244. // we can get here under normal conditions.
  13245. // Avoid issues by emitting the text node now,
  13246. // so at least it won't get any bigger.
  13247. switch (buffers[i]) {
  13248. case 'textNode':
  13249. closeText(parser);
  13250. break;
  13251. case 'cdata':
  13252. emitNode(parser, 'oncdata', parser.cdata);
  13253. parser.cdata = '';
  13254. break;
  13255. case 'script':
  13256. emitNode(parser, 'onscript', parser.script);
  13257. parser.script = '';
  13258. break;
  13259. default:
  13260. error(parser, 'Max buffer length exceeded: ' + buffers[i]);
  13261. }
  13262. }
  13263. maxActual = Math.max(maxActual, len);
  13264. }
  13265. // schedule the next check for the earliest possible buffer overrun.
  13266. var m = sax.MAX_BUFFER_LENGTH - maxActual;
  13267. parser.bufferCheckPosition = m + parser.position;
  13268. }
  13269. function clearBuffers(parser) {
  13270. for (var i = 0, l = buffers.length; i < l; i++) {
  13271. parser[buffers[i]] = '';
  13272. }
  13273. }
  13274. function flushBuffers(parser) {
  13275. closeText(parser);
  13276. if (parser.cdata !== '') {
  13277. emitNode(parser, 'oncdata', parser.cdata);
  13278. parser.cdata = '';
  13279. }
  13280. if (parser.script !== '') {
  13281. emitNode(parser, 'onscript', parser.script);
  13282. parser.script = '';
  13283. }
  13284. }
  13285. SAXParser.prototype = {
  13286. end: function end() {
  13287. _end(this);
  13288. },
  13289. write: write,
  13290. resume: function resume() {
  13291. this.error = null;return this;
  13292. },
  13293. close: function close() {
  13294. return this.write(null);
  13295. },
  13296. flush: function flush() {
  13297. flushBuffers(this);
  13298. }
  13299. };
  13300. var Stream;
  13301. try {
  13302. Stream = require('stream').Stream;
  13303. } catch (ex) {
  13304. Stream = function Stream() {};
  13305. }
  13306. var streamWraps = sax.EVENTS.filter(function (ev) {
  13307. return ev !== 'error' && ev !== 'end';
  13308. });
  13309. function createStream(strict, opt) {
  13310. return new SAXStream(strict, opt);
  13311. }
  13312. function SAXStream(strict, opt) {
  13313. if (!(this instanceof SAXStream)) {
  13314. return new SAXStream(strict, opt);
  13315. }
  13316. Stream.apply(this);
  13317. this._parser = new SAXParser(strict, opt);
  13318. this.writable = true;
  13319. this.readable = true;
  13320. var me = this;
  13321. this._parser.onend = function () {
  13322. me.emit('end');
  13323. };
  13324. this._parser.onerror = function (er) {
  13325. me.emit('error', er);
  13326. // if didn't throw, then means error was handled.
  13327. // go ahead and clear error, so we can write again.
  13328. me._parser.error = null;
  13329. };
  13330. this._decoder = null;
  13331. streamWraps.forEach(function (ev) {
  13332. (0, _defineProperty2.default)(me, 'on' + ev, {
  13333. get: function get() {
  13334. return me._parser['on' + ev];
  13335. },
  13336. set: function set(h) {
  13337. if (!h) {
  13338. me.removeAllListeners(ev);
  13339. me._parser['on' + ev] = h;
  13340. return h;
  13341. }
  13342. me.on(ev, h);
  13343. },
  13344. enumerable: true,
  13345. configurable: false
  13346. });
  13347. });
  13348. }
  13349. SAXStream.prototype = (0, _create2.default)(Stream.prototype, {
  13350. constructor: {
  13351. value: SAXStream
  13352. }
  13353. });
  13354. SAXStream.prototype.write = function (data) {
  13355. if (typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function' && Buffer.isBuffer(data)) {
  13356. if (!this._decoder) {
  13357. var SD = require('string_decoder').StringDecoder;
  13358. this._decoder = new SD('utf8');
  13359. }
  13360. data = this._decoder.write(data);
  13361. }
  13362. this._parser.write(data.toString());
  13363. this.emit('data', data);
  13364. return true;
  13365. };
  13366. SAXStream.prototype.end = function (chunk) {
  13367. if (chunk && chunk.length) {
  13368. this.write(chunk);
  13369. }
  13370. this._parser.end();
  13371. return true;
  13372. };
  13373. SAXStream.prototype.on = function (ev, handler) {
  13374. var me = this;
  13375. if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
  13376. me._parser['on' + ev] = function () {
  13377. var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
  13378. args.splice(0, 0, ev);
  13379. me.emit.apply(me, args);
  13380. };
  13381. }
  13382. return Stream.prototype.on.call(me, ev, handler);
  13383. };
  13384. // this really needs to be replaced with character classes.
  13385. // XML allows all manner of ridiculous numbers and digits.
  13386. var CDATA = '[CDATA[';
  13387. var DOCTYPE = 'DOCTYPE';
  13388. var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
  13389. var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
  13390. var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE
  13391. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  13392. // This implementation works on strings, a single character at a time
  13393. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  13394. // without a significant breaking change to either this parser, or the
  13395. // JavaScript language. Implementation of an emoji-capable xml parser
  13396. // is left as an exercise for the reader.
  13397. };var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
  13398. var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
  13399. var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
  13400. var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
  13401. function isWhitespace(c) {
  13402. return c === ' ' || c === '\n' || c === '\r' || c === '\t';
  13403. }
  13404. function isQuote(c) {
  13405. return c === '"' || c === '\'';
  13406. }
  13407. function isAttribEnd(c) {
  13408. return c === '>' || isWhitespace(c);
  13409. }
  13410. function isMatch(regex, c) {
  13411. return regex.test(c);
  13412. }
  13413. function notMatch(regex, c) {
  13414. return !isMatch(regex, c);
  13415. }
  13416. var S = 0;
  13417. sax.STATE = {
  13418. BEGIN: S++, // leading byte order mark or whitespace
  13419. BEGIN_WHITESPACE: S++, // leading whitespace
  13420. TEXT: S++, // general stuff
  13421. TEXT_ENTITY: S++, // &amp and such.
  13422. OPEN_WAKA: S++, // <
  13423. SGML_DECL: S++, // <!BLARG
  13424. SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
  13425. DOCTYPE: S++, // <!DOCTYPE
  13426. DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
  13427. DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
  13428. DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
  13429. COMMENT_STARTING: S++, // <!-
  13430. COMMENT: S++, // <!--
  13431. COMMENT_ENDING: S++, // <!-- blah -
  13432. COMMENT_ENDED: S++, // <!-- blah --
  13433. CDATA: S++, // <![CDATA[ something
  13434. CDATA_ENDING: S++, // ]
  13435. CDATA_ENDING_2: S++, // ]]
  13436. PROC_INST: S++, // <?hi
  13437. PROC_INST_BODY: S++, // <?hi there
  13438. PROC_INST_ENDING: S++, // <?hi "there" ?
  13439. OPEN_TAG: S++, // <strong
  13440. OPEN_TAG_SLASH: S++, // <strong /
  13441. ATTRIB: S++, // <a
  13442. ATTRIB_NAME: S++, // <a foo
  13443. ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
  13444. ATTRIB_VALUE: S++, // <a foo=
  13445. ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
  13446. ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
  13447. ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
  13448. ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
  13449. ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
  13450. CLOSE_TAG: S++, // </a
  13451. CLOSE_TAG_SAW_WHITE: S++, // </a >
  13452. SCRIPT: S++, // <script> ...
  13453. SCRIPT_ENDING: S++ // <script> ... <
  13454. };
  13455. sax.XML_ENTITIES = {
  13456. 'amp': '&',
  13457. 'gt': '>',
  13458. 'lt': '<',
  13459. 'quot': '"',
  13460. 'apos': "'"
  13461. };
  13462. sax.ENTITIES = {
  13463. 'amp': '&',
  13464. 'gt': '>',
  13465. 'lt': '<',
  13466. 'quot': '"',
  13467. 'apos': "'",
  13468. 'AElig': 198,
  13469. 'Aacute': 193,
  13470. 'Acirc': 194,
  13471. 'Agrave': 192,
  13472. 'Aring': 197,
  13473. 'Atilde': 195,
  13474. 'Auml': 196,
  13475. 'Ccedil': 199,
  13476. 'ETH': 208,
  13477. 'Eacute': 201,
  13478. 'Ecirc': 202,
  13479. 'Egrave': 200,
  13480. 'Euml': 203,
  13481. 'Iacute': 205,
  13482. 'Icirc': 206,
  13483. 'Igrave': 204,
  13484. 'Iuml': 207,
  13485. 'Ntilde': 209,
  13486. 'Oacute': 211,
  13487. 'Ocirc': 212,
  13488. 'Ograve': 210,
  13489. 'Oslash': 216,
  13490. 'Otilde': 213,
  13491. 'Ouml': 214,
  13492. 'THORN': 222,
  13493. 'Uacute': 218,
  13494. 'Ucirc': 219,
  13495. 'Ugrave': 217,
  13496. 'Uuml': 220,
  13497. 'Yacute': 221,
  13498. 'aacute': 225,
  13499. 'acirc': 226,
  13500. 'aelig': 230,
  13501. 'agrave': 224,
  13502. 'aring': 229,
  13503. 'atilde': 227,
  13504. 'auml': 228,
  13505. 'ccedil': 231,
  13506. 'eacute': 233,
  13507. 'ecirc': 234,
  13508. 'egrave': 232,
  13509. 'eth': 240,
  13510. 'euml': 235,
  13511. 'iacute': 237,
  13512. 'icirc': 238,
  13513. 'igrave': 236,
  13514. 'iuml': 239,
  13515. 'ntilde': 241,
  13516. 'oacute': 243,
  13517. 'ocirc': 244,
  13518. 'ograve': 242,
  13519. 'oslash': 248,
  13520. 'otilde': 245,
  13521. 'ouml': 246,
  13522. 'szlig': 223,
  13523. 'thorn': 254,
  13524. 'uacute': 250,
  13525. 'ucirc': 251,
  13526. 'ugrave': 249,
  13527. 'uuml': 252,
  13528. 'yacute': 253,
  13529. 'yuml': 255,
  13530. 'copy': 169,
  13531. 'reg': 174,
  13532. 'nbsp': 160,
  13533. 'iexcl': 161,
  13534. 'cent': 162,
  13535. 'pound': 163,
  13536. 'curren': 164,
  13537. 'yen': 165,
  13538. 'brvbar': 166,
  13539. 'sect': 167,
  13540. 'uml': 168,
  13541. 'ordf': 170,
  13542. 'laquo': 171,
  13543. 'not': 172,
  13544. 'shy': 173,
  13545. 'macr': 175,
  13546. 'deg': 176,
  13547. 'plusmn': 177,
  13548. 'sup1': 185,
  13549. 'sup2': 178,
  13550. 'sup3': 179,
  13551. 'acute': 180,
  13552. 'micro': 181,
  13553. 'para': 182,
  13554. 'middot': 183,
  13555. 'cedil': 184,
  13556. 'ordm': 186,
  13557. 'raquo': 187,
  13558. 'frac14': 188,
  13559. 'frac12': 189,
  13560. 'frac34': 190,
  13561. 'iquest': 191,
  13562. 'times': 215,
  13563. 'divide': 247,
  13564. 'OElig': 338,
  13565. 'oelig': 339,
  13566. 'Scaron': 352,
  13567. 'scaron': 353,
  13568. 'Yuml': 376,
  13569. 'fnof': 402,
  13570. 'circ': 710,
  13571. 'tilde': 732,
  13572. 'Alpha': 913,
  13573. 'Beta': 914,
  13574. 'Gamma': 915,
  13575. 'Delta': 916,
  13576. 'Epsilon': 917,
  13577. 'Zeta': 918,
  13578. 'Eta': 919,
  13579. 'Theta': 920,
  13580. 'Iota': 921,
  13581. 'Kappa': 922,
  13582. 'Lambda': 923,
  13583. 'Mu': 924,
  13584. 'Nu': 925,
  13585. 'Xi': 926,
  13586. 'Omicron': 927,
  13587. 'Pi': 928,
  13588. 'Rho': 929,
  13589. 'Sigma': 931,
  13590. 'Tau': 932,
  13591. 'Upsilon': 933,
  13592. 'Phi': 934,
  13593. 'Chi': 935,
  13594. 'Psi': 936,
  13595. 'Omega': 937,
  13596. 'alpha': 945,
  13597. 'beta': 946,
  13598. 'gamma': 947,
  13599. 'delta': 948,
  13600. 'epsilon': 949,
  13601. 'zeta': 950,
  13602. 'eta': 951,
  13603. 'theta': 952,
  13604. 'iota': 953,
  13605. 'kappa': 954,
  13606. 'lambda': 955,
  13607. 'mu': 956,
  13608. 'nu': 957,
  13609. 'xi': 958,
  13610. 'omicron': 959,
  13611. 'pi': 960,
  13612. 'rho': 961,
  13613. 'sigmaf': 962,
  13614. 'sigma': 963,
  13615. 'tau': 964,
  13616. 'upsilon': 965,
  13617. 'phi': 966,
  13618. 'chi': 967,
  13619. 'psi': 968,
  13620. 'omega': 969,
  13621. 'thetasym': 977,
  13622. 'upsih': 978,
  13623. 'piv': 982,
  13624. 'ensp': 8194,
  13625. 'emsp': 8195,
  13626. 'thinsp': 8201,
  13627. 'zwnj': 8204,
  13628. 'zwj': 8205,
  13629. 'lrm': 8206,
  13630. 'rlm': 8207,
  13631. 'ndash': 8211,
  13632. 'mdash': 8212,
  13633. 'lsquo': 8216,
  13634. 'rsquo': 8217,
  13635. 'sbquo': 8218,
  13636. 'ldquo': 8220,
  13637. 'rdquo': 8221,
  13638. 'bdquo': 8222,
  13639. 'dagger': 8224,
  13640. 'Dagger': 8225,
  13641. 'bull': 8226,
  13642. 'hellip': 8230,
  13643. 'permil': 8240,
  13644. 'prime': 8242,
  13645. 'Prime': 8243,
  13646. 'lsaquo': 8249,
  13647. 'rsaquo': 8250,
  13648. 'oline': 8254,
  13649. 'frasl': 8260,
  13650. 'euro': 8364,
  13651. 'image': 8465,
  13652. 'weierp': 8472,
  13653. 'real': 8476,
  13654. 'trade': 8482,
  13655. 'alefsym': 8501,
  13656. 'larr': 8592,
  13657. 'uarr': 8593,
  13658. 'rarr': 8594,
  13659. 'darr': 8595,
  13660. 'harr': 8596,
  13661. 'crarr': 8629,
  13662. 'lArr': 8656,
  13663. 'uArr': 8657,
  13664. 'rArr': 8658,
  13665. 'dArr': 8659,
  13666. 'hArr': 8660,
  13667. 'forall': 8704,
  13668. 'part': 8706,
  13669. 'exist': 8707,
  13670. 'empty': 8709,
  13671. 'nabla': 8711,
  13672. 'isin': 8712,
  13673. 'notin': 8713,
  13674. 'ni': 8715,
  13675. 'prod': 8719,
  13676. 'sum': 8721,
  13677. 'minus': 8722,
  13678. 'lowast': 8727,
  13679. 'radic': 8730,
  13680. 'prop': 8733,
  13681. 'infin': 8734,
  13682. 'ang': 8736,
  13683. 'and': 8743,
  13684. 'or': 8744,
  13685. 'cap': 8745,
  13686. 'cup': 8746,
  13687. 'int': 8747,
  13688. 'there4': 8756,
  13689. 'sim': 8764,
  13690. 'cong': 8773,
  13691. 'asymp': 8776,
  13692. 'ne': 8800,
  13693. 'equiv': 8801,
  13694. 'le': 8804,
  13695. 'ge': 8805,
  13696. 'sub': 8834,
  13697. 'sup': 8835,
  13698. 'nsub': 8836,
  13699. 'sube': 8838,
  13700. 'supe': 8839,
  13701. 'oplus': 8853,
  13702. 'otimes': 8855,
  13703. 'perp': 8869,
  13704. 'sdot': 8901,
  13705. 'lceil': 8968,
  13706. 'rceil': 8969,
  13707. 'lfloor': 8970,
  13708. 'rfloor': 8971,
  13709. 'lang': 9001,
  13710. 'rang': 9002,
  13711. 'loz': 9674,
  13712. 'spades': 9824,
  13713. 'clubs': 9827,
  13714. 'hearts': 9829,
  13715. 'diams': 9830
  13716. };
  13717. (0, _keys2.default)(sax.ENTITIES).forEach(function (key) {
  13718. var e = sax.ENTITIES[key];
  13719. var s = typeof e === 'number' ? String.fromCharCode(e) : e;
  13720. sax.ENTITIES[key] = s;
  13721. });
  13722. for (var s in sax.STATE) {
  13723. sax.STATE[sax.STATE[s]] = s;
  13724. }
  13725. // shorthand
  13726. S = sax.STATE;
  13727. function emit(parser, event, data) {
  13728. parser[event] && parser[event](data);
  13729. }
  13730. function emitNode(parser, nodeType, data) {
  13731. if (parser.textNode) closeText(parser);
  13732. emit(parser, nodeType, data);
  13733. }
  13734. function closeText(parser) {
  13735. parser.textNode = textopts(parser.opt, parser.textNode);
  13736. if (parser.textNode) emit(parser, 'ontext', parser.textNode);
  13737. parser.textNode = '';
  13738. }
  13739. function textopts(opt, text) {
  13740. if (opt.trim) text = text.trim();
  13741. if (opt.normalize) text = text.replace(/\s+/g, ' ');
  13742. return text;
  13743. }
  13744. function error(parser, er) {
  13745. closeText(parser);
  13746. if (parser.trackPosition) {
  13747. er += '\nLine: ' + parser.line + '\nColumn: ' + parser.column + '\nChar: ' + parser.c;
  13748. }
  13749. er = new Error(er);
  13750. parser.error = er;
  13751. emit(parser, 'onerror', er);
  13752. return parser;
  13753. }
  13754. function _end(parser) {
  13755. if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag');
  13756. if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
  13757. error(parser, 'Unexpected end');
  13758. }
  13759. closeText(parser);
  13760. parser.c = '';
  13761. parser.closed = true;
  13762. emit(parser, 'onend');
  13763. SAXParser.call(parser, parser.strict, parser.opt);
  13764. return parser;
  13765. }
  13766. function strictFail(parser, message) {
  13767. if ((typeof parser === 'undefined' ? 'undefined' : (0, _typeof3.default)(parser)) !== 'object' || !(parser instanceof SAXParser)) {
  13768. throw new Error('bad call to strictFail');
  13769. }
  13770. if (parser.strict) {
  13771. error(parser, message);
  13772. }
  13773. }
  13774. function newTag(parser) {
  13775. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]();
  13776. var parent = parser.tags[parser.tags.length - 1] || parser;
  13777. var tag = parser.tag = { name: parser.tagName, attributes: {}
  13778. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  13779. };if (parser.opt.xmlns) {
  13780. tag.ns = parent.ns;
  13781. }
  13782. parser.attribList.length = 0;
  13783. emitNode(parser, 'onopentagstart', tag);
  13784. }
  13785. function qname(name, attribute) {
  13786. var i = name.indexOf(':');
  13787. var qualName = i < 0 ? ['', name] : name.split(':');
  13788. var prefix = qualName[0];
  13789. var local = qualName[1];
  13790. // <x "xmlns"="http://foo">
  13791. if (attribute && name === 'xmlns') {
  13792. prefix = 'xmlns';
  13793. local = '';
  13794. }
  13795. return { prefix: prefix, local: local };
  13796. }
  13797. function attrib(parser) {
  13798. if (!parser.strict) {
  13799. parser.attribName = parser.attribName[parser.looseCase]();
  13800. }
  13801. if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  13802. parser.attribName = parser.attribValue = '';
  13803. return;
  13804. }
  13805. if (parser.opt.xmlns) {
  13806. var qn = qname(parser.attribName, true);
  13807. var prefix = qn.prefix;
  13808. var local = qn.local;
  13809. if (prefix === 'xmlns') {
  13810. // namespace binding attribute. push the binding into scope
  13811. if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
  13812. strictFail(parser, 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
  13813. } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
  13814. strictFail(parser, 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' + 'Actual: ' + parser.attribValue);
  13815. } else {
  13816. var tag = parser.tag;
  13817. var parent = parser.tags[parser.tags.length - 1] || parser;
  13818. if (tag.ns === parent.ns) {
  13819. tag.ns = (0, _create2.default)(parent.ns);
  13820. }
  13821. tag.ns[local] = parser.attribValue;
  13822. }
  13823. }
  13824. // defer onattribute events until all attributes have been seen
  13825. // so any new bindings can take effect. preserve attribute order
  13826. // so deferred events can be emitted in document order
  13827. parser.attribList.push([parser.attribName, parser.attribValue]);
  13828. } else {
  13829. // in non-xmlns mode, we can emit the event right away
  13830. parser.tag.attributes[parser.attribName] = parser.attribValue;
  13831. emitNode(parser, 'onattribute', {
  13832. name: parser.attribName,
  13833. value: parser.attribValue
  13834. });
  13835. }
  13836. parser.attribName = parser.attribValue = '';
  13837. }
  13838. function openTag(parser, selfClosing) {
  13839. if (parser.opt.xmlns) {
  13840. // emit namespace binding events
  13841. var tag = parser.tag;
  13842. // add namespace info to tag
  13843. var qn = qname(parser.tagName);
  13844. tag.prefix = qn.prefix;
  13845. tag.local = qn.local;
  13846. tag.uri = tag.ns[qn.prefix] || '';
  13847. if (tag.prefix && !tag.uri) {
  13848. strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(parser.tagName));
  13849. tag.uri = qn.prefix;
  13850. }
  13851. var parent = parser.tags[parser.tags.length - 1] || parser;
  13852. if (tag.ns && parent.ns !== tag.ns) {
  13853. (0, _keys2.default)(tag.ns).forEach(function (p) {
  13854. emitNode(parser, 'onopennamespace', {
  13855. prefix: p,
  13856. uri: tag.ns[p]
  13857. });
  13858. });
  13859. }
  13860. // handle deferred onattribute events
  13861. // Note: do not apply default ns to attributes:
  13862. // http://www.w3.org/TR/REC-xml-names/#defaulting
  13863. for (var i = 0, l = parser.attribList.length; i < l; i++) {
  13864. var nv = parser.attribList[i];
  13865. var name = nv[0];
  13866. var value = nv[1];
  13867. var qualName = qname(name, true);
  13868. var prefix = qualName.prefix;
  13869. var local = qualName.local;
  13870. var uri = prefix === '' ? '' : tag.ns[prefix] || '';
  13871. var a = {
  13872. name: name,
  13873. value: value,
  13874. prefix: prefix,
  13875. local: local,
  13876. uri: uri
  13877. // if there's any attributes with an undefined namespace,
  13878. // then fail on them now.
  13879. };if (prefix && prefix !== 'xmlns' && !uri) {
  13880. strictFail(parser, 'Unbound namespace prefix: ' + (0, _stringify2.default)(prefix));
  13881. a.uri = prefix;
  13882. }
  13883. parser.tag.attributes[name] = a;
  13884. emitNode(parser, 'onattribute', a);
  13885. }
  13886. parser.attribList.length = 0;
  13887. }
  13888. parser.tag.isSelfClosing = !!selfClosing;
  13889. // process the tag
  13890. parser.sawRoot = true;
  13891. parser.tags.push(parser.tag);
  13892. emitNode(parser, 'onopentag', parser.tag);
  13893. if (!selfClosing) {
  13894. // special case for <script> in non-strict mode.
  13895. if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
  13896. parser.state = S.SCRIPT;
  13897. } else {
  13898. parser.state = S.TEXT;
  13899. }
  13900. parser.tag = null;
  13901. parser.tagName = '';
  13902. }
  13903. parser.attribName = parser.attribValue = '';
  13904. parser.attribList.length = 0;
  13905. }
  13906. function closeTag(parser) {
  13907. if (!parser.tagName) {
  13908. strictFail(parser, 'Weird empty close tag.');
  13909. parser.textNode += '</>';
  13910. parser.state = S.TEXT;
  13911. return;
  13912. }
  13913. if (parser.script) {
  13914. if (parser.tagName !== 'script') {
  13915. parser.script += '</' + parser.tagName + '>';
  13916. parser.tagName = '';
  13917. parser.state = S.SCRIPT;
  13918. return;
  13919. }
  13920. emitNode(parser, 'onscript', parser.script);
  13921. parser.script = '';
  13922. }
  13923. // first make sure that the closing tag actually exists.
  13924. // <a><b></c></b></a> will close everything, otherwise.
  13925. var t = parser.tags.length;
  13926. var tagName = parser.tagName;
  13927. if (!parser.strict) {
  13928. tagName = tagName[parser.looseCase]();
  13929. }
  13930. var closeTo = tagName;
  13931. while (t--) {
  13932. var close = parser.tags[t];
  13933. if (close.name !== closeTo) {
  13934. // fail the first time in strict mode
  13935. strictFail(parser, 'Unexpected close tag');
  13936. } else {
  13937. break;
  13938. }
  13939. }
  13940. // didn't find it. we already failed for strict, so just abort.
  13941. if (t < 0) {
  13942. strictFail(parser, 'Unmatched closing tag: ' + parser.tagName);
  13943. parser.textNode += '</' + parser.tagName + '>';
  13944. parser.state = S.TEXT;
  13945. return;
  13946. }
  13947. parser.tagName = tagName;
  13948. var s = parser.tags.length;
  13949. while (s-- > t) {
  13950. var tag = parser.tag = parser.tags.pop();
  13951. parser.tagName = parser.tag.name;
  13952. emitNode(parser, 'onclosetag', parser.tagName);
  13953. var x = {};
  13954. for (var i in tag.ns) {
  13955. x[i] = tag.ns[i];
  13956. }
  13957. var parent = parser.tags[parser.tags.length - 1] || parser;
  13958. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  13959. // remove namespace bindings introduced by tag
  13960. (0, _keys2.default)(tag.ns).forEach(function (p) {
  13961. var n = tag.ns[p];
  13962. emitNode(parser, 'onclosenamespace', { prefix: p, uri: n });
  13963. });
  13964. }
  13965. }
  13966. if (t === 0) parser.closedRoot = true;
  13967. parser.tagName = parser.attribValue = parser.attribName = '';
  13968. parser.attribList.length = 0;
  13969. parser.state = S.TEXT;
  13970. }
  13971. function parseEntity(parser) {
  13972. var entity = parser.entity;
  13973. var entityLC = entity.toLowerCase();
  13974. var num;
  13975. var numStr = '';
  13976. if (parser.ENTITIES[entity]) {
  13977. return parser.ENTITIES[entity];
  13978. }
  13979. if (parser.ENTITIES[entityLC]) {
  13980. return parser.ENTITIES[entityLC];
  13981. }
  13982. entity = entityLC;
  13983. if (entity.charAt(0) === '#') {
  13984. if (entity.charAt(1) === 'x') {
  13985. entity = entity.slice(2);
  13986. num = parseInt(entity, 16);
  13987. numStr = num.toString(16);
  13988. } else {
  13989. entity = entity.slice(1);
  13990. num = parseInt(entity, 10);
  13991. numStr = num.toString(10);
  13992. }
  13993. }
  13994. entity = entity.replace(/^0+/, '');
  13995. if (isNaN(num) || numStr.toLowerCase() !== entity) {
  13996. strictFail(parser, 'Invalid character entity');
  13997. return '&' + parser.entity + ';';
  13998. }
  13999. return (0, _fromCodePoint2.default)(num);
  14000. }
  14001. function beginWhiteSpace(parser, c) {
  14002. if (c === '<') {
  14003. parser.state = S.OPEN_WAKA;
  14004. parser.startTagPosition = parser.position;
  14005. } else if (!isWhitespace(c)) {
  14006. // have to process this as a text node.
  14007. // weird, but happens.
  14008. strictFail(parser, 'Non-whitespace before first tag.');
  14009. parser.textNode = c;
  14010. parser.state = S.TEXT;
  14011. }
  14012. }
  14013. function charAt(chunk, i) {
  14014. var result = '';
  14015. if (i < chunk.length) {
  14016. result = chunk.charAt(i);
  14017. }
  14018. return result;
  14019. }
  14020. function write(chunk) {
  14021. var parser = this;
  14022. if (this.error) {
  14023. throw this.error;
  14024. }
  14025. if (parser.closed) {
  14026. return error(parser, 'Cannot write after close. Assign an onready handler.');
  14027. }
  14028. if (chunk === null) {
  14029. return _end(parser);
  14030. }
  14031. if ((typeof chunk === 'undefined' ? 'undefined' : (0, _typeof3.default)(chunk)) === 'object') {
  14032. chunk = chunk.toString();
  14033. }
  14034. var i = 0;
  14035. var c = '';
  14036. while (true) {
  14037. c = charAt(chunk, i++);
  14038. parser.c = c;
  14039. if (!c) {
  14040. break;
  14041. }
  14042. if (parser.trackPosition) {
  14043. parser.position++;
  14044. if (c === '\n') {
  14045. parser.line++;
  14046. parser.column = 0;
  14047. } else {
  14048. parser.column++;
  14049. }
  14050. }
  14051. switch (parser.state) {
  14052. case S.BEGIN:
  14053. parser.state = S.BEGIN_WHITESPACE;
  14054. if (c === '\uFEFF') {
  14055. continue;
  14056. }
  14057. beginWhiteSpace(parser, c);
  14058. continue;
  14059. case S.BEGIN_WHITESPACE:
  14060. beginWhiteSpace(parser, c);
  14061. continue;
  14062. case S.TEXT:
  14063. if (parser.sawRoot && !parser.closedRoot) {
  14064. var starti = i - 1;
  14065. while (c && c !== '<' && c !== '&') {
  14066. c = charAt(chunk, i++);
  14067. if (c && parser.trackPosition) {
  14068. parser.position++;
  14069. if (c === '\n') {
  14070. parser.line++;
  14071. parser.column = 0;
  14072. } else {
  14073. parser.column++;
  14074. }
  14075. }
  14076. }
  14077. parser.textNode += chunk.substring(starti, i - 1);
  14078. }
  14079. if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
  14080. parser.state = S.OPEN_WAKA;
  14081. parser.startTagPosition = parser.position;
  14082. } else {
  14083. if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
  14084. strictFail(parser, 'Text data outside of root node.');
  14085. }
  14086. if (c === '&') {
  14087. parser.state = S.TEXT_ENTITY;
  14088. } else {
  14089. parser.textNode += c;
  14090. }
  14091. }
  14092. continue;
  14093. case S.SCRIPT:
  14094. // only non-strict
  14095. if (c === '<') {
  14096. parser.state = S.SCRIPT_ENDING;
  14097. } else {
  14098. parser.script += c;
  14099. }
  14100. continue;
  14101. case S.SCRIPT_ENDING:
  14102. if (c === '/') {
  14103. parser.state = S.CLOSE_TAG;
  14104. } else {
  14105. parser.script += '<' + c;
  14106. parser.state = S.SCRIPT;
  14107. }
  14108. continue;
  14109. case S.OPEN_WAKA:
  14110. // either a /, ?, !, or text is coming next.
  14111. if (c === '!') {
  14112. parser.state = S.SGML_DECL;
  14113. parser.sgmlDecl = '';
  14114. } else if (isWhitespace(c)) {
  14115. // wait for it...
  14116. } else if (isMatch(nameStart, c)) {
  14117. parser.state = S.OPEN_TAG;
  14118. parser.tagName = c;
  14119. } else if (c === '/') {
  14120. parser.state = S.CLOSE_TAG;
  14121. parser.tagName = '';
  14122. } else if (c === '?') {
  14123. parser.state = S.PROC_INST;
  14124. parser.procInstName = parser.procInstBody = '';
  14125. } else {
  14126. strictFail(parser, 'Unencoded <');
  14127. // if there was some whitespace, then add that in.
  14128. if (parser.startTagPosition + 1 < parser.position) {
  14129. var pad = parser.position - parser.startTagPosition;
  14130. c = new Array(pad).join(' ') + c;
  14131. }
  14132. parser.textNode += '<' + c;
  14133. parser.state = S.TEXT;
  14134. }
  14135. continue;
  14136. case S.SGML_DECL:
  14137. if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
  14138. emitNode(parser, 'onopencdata');
  14139. parser.state = S.CDATA;
  14140. parser.sgmlDecl = '';
  14141. parser.cdata = '';
  14142. } else if (parser.sgmlDecl + c === '--') {
  14143. parser.state = S.COMMENT;
  14144. parser.comment = '';
  14145. parser.sgmlDecl = '';
  14146. } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
  14147. parser.state = S.DOCTYPE;
  14148. if (parser.doctype || parser.sawRoot) {
  14149. strictFail(parser, 'Inappropriately located doctype declaration');
  14150. }
  14151. parser.doctype = '';
  14152. parser.sgmlDecl = '';
  14153. } else if (c === '>') {
  14154. emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl);
  14155. parser.sgmlDecl = '';
  14156. parser.state = S.TEXT;
  14157. } else if (isQuote(c)) {
  14158. parser.state = S.SGML_DECL_QUOTED;
  14159. parser.sgmlDecl += c;
  14160. } else {
  14161. parser.sgmlDecl += c;
  14162. }
  14163. continue;
  14164. case S.SGML_DECL_QUOTED:
  14165. if (c === parser.q) {
  14166. parser.state = S.SGML_DECL;
  14167. parser.q = '';
  14168. }
  14169. parser.sgmlDecl += c;
  14170. continue;
  14171. case S.DOCTYPE:
  14172. if (c === '>') {
  14173. parser.state = S.TEXT;
  14174. emitNode(parser, 'ondoctype', parser.doctype);
  14175. parser.doctype = true; // just remember that we saw it.
  14176. } else {
  14177. parser.doctype += c;
  14178. if (c === '[') {
  14179. parser.state = S.DOCTYPE_DTD;
  14180. } else if (isQuote(c)) {
  14181. parser.state = S.DOCTYPE_QUOTED;
  14182. parser.q = c;
  14183. }
  14184. }
  14185. continue;
  14186. case S.DOCTYPE_QUOTED:
  14187. parser.doctype += c;
  14188. if (c === parser.q) {
  14189. parser.q = '';
  14190. parser.state = S.DOCTYPE;
  14191. }
  14192. continue;
  14193. case S.DOCTYPE_DTD:
  14194. parser.doctype += c;
  14195. if (c === ']') {
  14196. parser.state = S.DOCTYPE;
  14197. } else if (isQuote(c)) {
  14198. parser.state = S.DOCTYPE_DTD_QUOTED;
  14199. parser.q = c;
  14200. }
  14201. continue;
  14202. case S.DOCTYPE_DTD_QUOTED:
  14203. parser.doctype += c;
  14204. if (c === parser.q) {
  14205. parser.state = S.DOCTYPE_DTD;
  14206. parser.q = '';
  14207. }
  14208. continue;
  14209. case S.COMMENT:
  14210. if (c === '-') {
  14211. parser.state = S.COMMENT_ENDING;
  14212. } else {
  14213. parser.comment += c;
  14214. }
  14215. continue;
  14216. case S.COMMENT_ENDING:
  14217. if (c === '-') {
  14218. parser.state = S.COMMENT_ENDED;
  14219. parser.comment = textopts(parser.opt, parser.comment);
  14220. if (parser.comment) {
  14221. emitNode(parser, 'oncomment', parser.comment);
  14222. }
  14223. parser.comment = '';
  14224. } else {
  14225. parser.comment += '-' + c;
  14226. parser.state = S.COMMENT;
  14227. }
  14228. continue;
  14229. case S.COMMENT_ENDED:
  14230. if (c !== '>') {
  14231. strictFail(parser, 'Malformed comment');
  14232. // allow <!-- blah -- bloo --> in non-strict mode,
  14233. // which is a comment of " blah -- bloo "
  14234. parser.comment += '--' + c;
  14235. parser.state = S.COMMENT;
  14236. } else {
  14237. parser.state = S.TEXT;
  14238. }
  14239. continue;
  14240. case S.CDATA:
  14241. if (c === ']') {
  14242. parser.state = S.CDATA_ENDING;
  14243. } else {
  14244. parser.cdata += c;
  14245. }
  14246. continue;
  14247. case S.CDATA_ENDING:
  14248. if (c === ']') {
  14249. parser.state = S.CDATA_ENDING_2;
  14250. } else {
  14251. parser.cdata += ']' + c;
  14252. parser.state = S.CDATA;
  14253. }
  14254. continue;
  14255. case S.CDATA_ENDING_2:
  14256. if (c === '>') {
  14257. if (parser.cdata) {
  14258. emitNode(parser, 'oncdata', parser.cdata);
  14259. }
  14260. emitNode(parser, 'onclosecdata');
  14261. parser.cdata = '';
  14262. parser.state = S.TEXT;
  14263. } else if (c === ']') {
  14264. parser.cdata += ']';
  14265. } else {
  14266. parser.cdata += ']]' + c;
  14267. parser.state = S.CDATA;
  14268. }
  14269. continue;
  14270. case S.PROC_INST:
  14271. if (c === '?') {
  14272. parser.state = S.PROC_INST_ENDING;
  14273. } else if (isWhitespace(c)) {
  14274. parser.state = S.PROC_INST_BODY;
  14275. } else {
  14276. parser.procInstName += c;
  14277. }
  14278. continue;
  14279. case S.PROC_INST_BODY:
  14280. if (!parser.procInstBody && isWhitespace(c)) {
  14281. continue;
  14282. } else if (c === '?') {
  14283. parser.state = S.PROC_INST_ENDING;
  14284. } else {
  14285. parser.procInstBody += c;
  14286. }
  14287. continue;
  14288. case S.PROC_INST_ENDING:
  14289. if (c === '>') {
  14290. emitNode(parser, 'onprocessinginstruction', {
  14291. name: parser.procInstName,
  14292. body: parser.procInstBody
  14293. });
  14294. parser.procInstName = parser.procInstBody = '';
  14295. parser.state = S.TEXT;
  14296. } else {
  14297. parser.procInstBody += '?' + c;
  14298. parser.state = S.PROC_INST_BODY;
  14299. }
  14300. continue;
  14301. case S.OPEN_TAG:
  14302. if (isMatch(nameBody, c)) {
  14303. parser.tagName += c;
  14304. } else {
  14305. newTag(parser);
  14306. if (c === '>') {
  14307. openTag(parser);
  14308. } else if (c === '/') {
  14309. parser.state = S.OPEN_TAG_SLASH;
  14310. } else {
  14311. if (!isWhitespace(c)) {
  14312. strictFail(parser, 'Invalid character in tag name');
  14313. }
  14314. parser.state = S.ATTRIB;
  14315. }
  14316. }
  14317. continue;
  14318. case S.OPEN_TAG_SLASH:
  14319. if (c === '>') {
  14320. openTag(parser, true);
  14321. closeTag(parser);
  14322. } else {
  14323. strictFail(parser, 'Forward-slash in opening tag not followed by >');
  14324. parser.state = S.ATTRIB;
  14325. }
  14326. continue;
  14327. case S.ATTRIB:
  14328. // haven't read the attribute name yet.
  14329. if (isWhitespace(c)) {
  14330. continue;
  14331. } else if (c === '>') {
  14332. openTag(parser);
  14333. } else if (c === '/') {
  14334. parser.state = S.OPEN_TAG_SLASH;
  14335. } else if (isMatch(nameStart, c)) {
  14336. parser.attribName = c;
  14337. parser.attribValue = '';
  14338. parser.state = S.ATTRIB_NAME;
  14339. } else {
  14340. strictFail(parser, 'Invalid attribute name');
  14341. }
  14342. continue;
  14343. case S.ATTRIB_NAME:
  14344. if (c === '=') {
  14345. parser.state = S.ATTRIB_VALUE;
  14346. } else if (c === '>') {
  14347. strictFail(parser, 'Attribute without value');
  14348. parser.attribValue = parser.attribName;
  14349. attrib(parser);
  14350. openTag(parser);
  14351. } else if (isWhitespace(c)) {
  14352. parser.state = S.ATTRIB_NAME_SAW_WHITE;
  14353. } else if (isMatch(nameBody, c)) {
  14354. parser.attribName += c;
  14355. } else {
  14356. strictFail(parser, 'Invalid attribute name');
  14357. }
  14358. continue;
  14359. case S.ATTRIB_NAME_SAW_WHITE:
  14360. if (c === '=') {
  14361. parser.state = S.ATTRIB_VALUE;
  14362. } else if (isWhitespace(c)) {
  14363. continue;
  14364. } else {
  14365. strictFail(parser, 'Attribute without value');
  14366. parser.tag.attributes[parser.attribName] = '';
  14367. parser.attribValue = '';
  14368. emitNode(parser, 'onattribute', {
  14369. name: parser.attribName,
  14370. value: ''
  14371. });
  14372. parser.attribName = '';
  14373. if (c === '>') {
  14374. openTag(parser);
  14375. } else if (isMatch(nameStart, c)) {
  14376. parser.attribName = c;
  14377. parser.state = S.ATTRIB_NAME;
  14378. } else {
  14379. strictFail(parser, 'Invalid attribute name');
  14380. parser.state = S.ATTRIB;
  14381. }
  14382. }
  14383. continue;
  14384. case S.ATTRIB_VALUE:
  14385. if (isWhitespace(c)) {
  14386. continue;
  14387. } else if (isQuote(c)) {
  14388. parser.q = c;
  14389. parser.state = S.ATTRIB_VALUE_QUOTED;
  14390. } else {
  14391. strictFail(parser, 'Unquoted attribute value');
  14392. parser.state = S.ATTRIB_VALUE_UNQUOTED;
  14393. parser.attribValue = c;
  14394. }
  14395. continue;
  14396. case S.ATTRIB_VALUE_QUOTED:
  14397. if (c !== parser.q) {
  14398. if (c === '&') {
  14399. parser.state = S.ATTRIB_VALUE_ENTITY_Q;
  14400. } else {
  14401. parser.attribValue += c;
  14402. }
  14403. continue;
  14404. }
  14405. attrib(parser);
  14406. parser.q = '';
  14407. parser.state = S.ATTRIB_VALUE_CLOSED;
  14408. continue;
  14409. case S.ATTRIB_VALUE_CLOSED:
  14410. if (isWhitespace(c)) {
  14411. parser.state = S.ATTRIB;
  14412. } else if (c === '>') {
  14413. openTag(parser);
  14414. } else if (c === '/') {
  14415. parser.state = S.OPEN_TAG_SLASH;
  14416. } else if (isMatch(nameStart, c)) {
  14417. strictFail(parser, 'No whitespace between attributes');
  14418. parser.attribName = c;
  14419. parser.attribValue = '';
  14420. parser.state = S.ATTRIB_NAME;
  14421. } else {
  14422. strictFail(parser, 'Invalid attribute name');
  14423. }
  14424. continue;
  14425. case S.ATTRIB_VALUE_UNQUOTED:
  14426. if (!isAttribEnd(c)) {
  14427. if (c === '&') {
  14428. parser.state = S.ATTRIB_VALUE_ENTITY_U;
  14429. } else {
  14430. parser.attribValue += c;
  14431. }
  14432. continue;
  14433. }
  14434. attrib(parser);
  14435. if (c === '>') {
  14436. openTag(parser);
  14437. } else {
  14438. parser.state = S.ATTRIB;
  14439. }
  14440. continue;
  14441. case S.CLOSE_TAG:
  14442. if (!parser.tagName) {
  14443. if (isWhitespace(c)) {
  14444. continue;
  14445. } else if (notMatch(nameStart, c)) {
  14446. if (parser.script) {
  14447. parser.script += '</' + c;
  14448. parser.state = S.SCRIPT;
  14449. } else {
  14450. strictFail(parser, 'Invalid tagname in closing tag.');
  14451. }
  14452. } else {
  14453. parser.tagName = c;
  14454. }
  14455. } else if (c === '>') {
  14456. closeTag(parser);
  14457. } else if (isMatch(nameBody, c)) {
  14458. parser.tagName += c;
  14459. } else if (parser.script) {
  14460. parser.script += '</' + parser.tagName;
  14461. parser.tagName = '';
  14462. parser.state = S.SCRIPT;
  14463. } else {
  14464. if (!isWhitespace(c)) {
  14465. strictFail(parser, 'Invalid tagname in closing tag');
  14466. }
  14467. parser.state = S.CLOSE_TAG_SAW_WHITE;
  14468. }
  14469. continue;
  14470. case S.CLOSE_TAG_SAW_WHITE:
  14471. if (isWhitespace(c)) {
  14472. continue;
  14473. }
  14474. if (c === '>') {
  14475. closeTag(parser);
  14476. } else {
  14477. strictFail(parser, 'Invalid characters in closing tag');
  14478. }
  14479. continue;
  14480. case S.TEXT_ENTITY:
  14481. case S.ATTRIB_VALUE_ENTITY_Q:
  14482. case S.ATTRIB_VALUE_ENTITY_U:
  14483. var returnState;
  14484. var buffer;
  14485. switch (parser.state) {
  14486. case S.TEXT_ENTITY:
  14487. returnState = S.TEXT;
  14488. buffer = 'textNode';
  14489. break;
  14490. case S.ATTRIB_VALUE_ENTITY_Q:
  14491. returnState = S.ATTRIB_VALUE_QUOTED;
  14492. buffer = 'attribValue';
  14493. break;
  14494. case S.ATTRIB_VALUE_ENTITY_U:
  14495. returnState = S.ATTRIB_VALUE_UNQUOTED;
  14496. buffer = 'attribValue';
  14497. break;
  14498. }
  14499. if (c === ';') {
  14500. parser[buffer] += parseEntity(parser);
  14501. parser.entity = '';
  14502. parser.state = returnState;
  14503. } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
  14504. parser.entity += c;
  14505. } else {
  14506. strictFail(parser, 'Invalid character in entity name');
  14507. parser[buffer] += '&' + parser.entity + c;
  14508. parser.entity = '';
  14509. parser.state = returnState;
  14510. }
  14511. continue;
  14512. default:
  14513. throw new Error(parser, 'Unknown state: ' + parser.state);
  14514. }
  14515. } // while
  14516. if (parser.position >= parser.bufferCheckPosition) {
  14517. checkBufferLength(parser);
  14518. }
  14519. return parser;
  14520. }
  14521. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  14522. /* istanbul ignore next */
  14523. if (!_fromCodePoint2.default) {
  14524. (function () {
  14525. var stringFromCharCode = String.fromCharCode;
  14526. var floor = Math.floor;
  14527. var fromCodePoint = function fromCodePoint() {
  14528. var MAX_SIZE = 0x4000;
  14529. var codeUnits = [];
  14530. var highSurrogate;
  14531. var lowSurrogate;
  14532. var index = -1;
  14533. var length = arguments.length;
  14534. if (!length) {
  14535. return '';
  14536. }
  14537. var result = '';
  14538. while (++index < length) {
  14539. var codePoint = Number(arguments[index]);
  14540. if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  14541. codePoint < 0 || // not a valid Unicode code point
  14542. codePoint > 0x10FFFF || // not a valid Unicode code point
  14543. floor(codePoint) !== codePoint // not an integer
  14544. ) {
  14545. throw RangeError('Invalid code point: ' + codePoint);
  14546. }
  14547. if (codePoint <= 0xFFFF) {
  14548. // BMP code point
  14549. codeUnits.push(codePoint);
  14550. } else {
  14551. // Astral code point; split in surrogate halves
  14552. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  14553. codePoint -= 0x10000;
  14554. highSurrogate = (codePoint >> 10) + 0xD800;
  14555. lowSurrogate = codePoint % 0x400 + 0xDC00;
  14556. codeUnits.push(highSurrogate, lowSurrogate);
  14557. }
  14558. if (index + 1 === length || codeUnits.length > MAX_SIZE) {
  14559. result += stringFromCharCode.apply(null, codeUnits);
  14560. codeUnits.length = 0;
  14561. }
  14562. }
  14563. return result;
  14564. };
  14565. /* istanbul ignore next */
  14566. if (_defineProperty2.default) {
  14567. Object.defineProperty(String, 'fromCodePoint', {
  14568. value: fromCodePoint,
  14569. configurable: true,
  14570. writable: true
  14571. });
  14572. } else {
  14573. String.fromCodePoint = fromCodePoint;
  14574. }
  14575. })();
  14576. }
  14577. })(typeof exports === 'undefined' ? undefined.sax = {} : exports);
  14578. }).call(this,require("buffer").Buffer)
  14579. },{"babel-runtime/core-js/json/stringify":12,"babel-runtime/core-js/object/create":14,"babel-runtime/core-js/object/define-property":15,"babel-runtime/core-js/object/keys":18,"babel-runtime/core-js/string/from-code-point":20,"babel-runtime/helpers/typeof":26,"buffer":31,"stream":183,"string_decoder":188}],183:[function(require,module,exports){
  14580. // Copyright Joyent, Inc. and other Node contributors.
  14581. //
  14582. // Permission is hereby granted, free of charge, to any person obtaining a
  14583. // copy of this software and associated documentation files (the
  14584. // "Software"), to deal in the Software without restriction, including
  14585. // without limitation the rights to use, copy, modify, merge, publish,
  14586. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14587. // persons to whom the Software is furnished to do so, subject to the
  14588. // following conditions:
  14589. //
  14590. // The above copyright notice and this permission notice shall be included
  14591. // in all copies or substantial portions of the Software.
  14592. //
  14593. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14594. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14595. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14596. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14597. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14598. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14599. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14600. module.exports = Stream;
  14601. var EE = require('events').EventEmitter;
  14602. var inherits = require('inherits');
  14603. inherits(Stream, EE);
  14604. Stream.Readable = require('readable-stream/readable.js');
  14605. Stream.Writable = require('readable-stream/writable.js');
  14606. Stream.Duplex = require('readable-stream/duplex.js');
  14607. Stream.Transform = require('readable-stream/transform.js');
  14608. Stream.PassThrough = require('readable-stream/passthrough.js');
  14609. // Backwards-compat with node 0.4.x
  14610. Stream.Stream = Stream;
  14611. // old-style streams. Note that the pipe method (the only relevant
  14612. // part of this class) is overridden in the Readable class.
  14613. function Stream() {
  14614. EE.call(this);
  14615. }
  14616. Stream.prototype.pipe = function(dest, options) {
  14617. var source = this;
  14618. function ondata(chunk) {
  14619. if (dest.writable) {
  14620. if (false === dest.write(chunk) && source.pause) {
  14621. source.pause();
  14622. }
  14623. }
  14624. }
  14625. source.on('data', ondata);
  14626. function ondrain() {
  14627. if (source.readable && source.resume) {
  14628. source.resume();
  14629. }
  14630. }
  14631. dest.on('drain', ondrain);
  14632. // If the 'end' option is not supplied, dest.end() will be called when
  14633. // source gets the 'end' or 'close' events. Only dest.end() once.
  14634. if (!dest._isStdio && (!options || options.end !== false)) {
  14635. source.on('end', onend);
  14636. source.on('close', onclose);
  14637. }
  14638. var didOnEnd = false;
  14639. function onend() {
  14640. if (didOnEnd) return;
  14641. didOnEnd = true;
  14642. dest.end();
  14643. }
  14644. function onclose() {
  14645. if (didOnEnd) return;
  14646. didOnEnd = true;
  14647. if (typeof dest.destroy === 'function') dest.destroy();
  14648. }
  14649. // don't leave dangling pipes when there are errors.
  14650. function onerror(er) {
  14651. cleanup();
  14652. if (EE.listenerCount(this, 'error') === 0) {
  14653. throw er; // Unhandled stream error in pipe.
  14654. }
  14655. }
  14656. source.on('error', onerror);
  14657. dest.on('error', onerror);
  14658. // remove all the event listeners that were added.
  14659. function cleanup() {
  14660. source.removeListener('data', ondata);
  14661. dest.removeListener('drain', ondrain);
  14662. source.removeListener('end', onend);
  14663. source.removeListener('close', onclose);
  14664. source.removeListener('error', onerror);
  14665. dest.removeListener('error', onerror);
  14666. source.removeListener('end', cleanup);
  14667. source.removeListener('close', cleanup);
  14668. dest.removeListener('close', cleanup);
  14669. }
  14670. source.on('end', cleanup);
  14671. source.on('close', cleanup);
  14672. dest.on('close', cleanup);
  14673. dest.emit('pipe', source);
  14674. // Allow for unix-like usage: A.pipe(B).pipe(C)
  14675. return dest;
  14676. };
  14677. },{"events":145,"inherits":149,"readable-stream/duplex.js":164,"readable-stream/passthrough.js":175,"readable-stream/readable.js":176,"readable-stream/transform.js":177,"readable-stream/writable.js":178}],184:[function(require,module,exports){
  14678. (function (global){
  14679. var ClientRequest = require('./lib/request')
  14680. var extend = require('xtend')
  14681. var statusCodes = require('builtin-status-codes')
  14682. var url = require('url')
  14683. var http = exports
  14684. http.request = function (opts, cb) {
  14685. if (typeof opts === 'string')
  14686. opts = url.parse(opts)
  14687. else
  14688. opts = extend(opts)
  14689. // Normally, the page is loaded from http or https, so not specifying a protocol
  14690. // will result in a (valid) protocol-relative url. However, this won't work if
  14691. // the protocol is something else, like 'file:'
  14692. var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
  14693. var protocol = opts.protocol || defaultProtocol
  14694. var host = opts.hostname || opts.host
  14695. var port = opts.port
  14696. var path = opts.path || '/'
  14697. // Necessary for IPv6 addresses
  14698. if (host && host.indexOf(':') !== -1)
  14699. host = '[' + host + ']'
  14700. // This may be a relative url. The browser should always be able to interpret it correctly.
  14701. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
  14702. opts.method = (opts.method || 'GET').toUpperCase()
  14703. opts.headers = opts.headers || {}
  14704. // Also valid opts.auth, opts.mode
  14705. var req = new ClientRequest(opts)
  14706. if (cb)
  14707. req.on('response', cb)
  14708. return req
  14709. }
  14710. http.get = function get (opts, cb) {
  14711. var req = http.request(opts, cb)
  14712. req.end()
  14713. return req
  14714. }
  14715. http.Agent = function () {}
  14716. http.Agent.defaultMaxSockets = 4
  14717. http.STATUS_CODES = statusCodes
  14718. http.METHODS = [
  14719. 'CHECKOUT',
  14720. 'CONNECT',
  14721. 'COPY',
  14722. 'DELETE',
  14723. 'GET',
  14724. 'HEAD',
  14725. 'LOCK',
  14726. 'M-SEARCH',
  14727. 'MERGE',
  14728. 'MKACTIVITY',
  14729. 'MKCOL',
  14730. 'MOVE',
  14731. 'NOTIFY',
  14732. 'OPTIONS',
  14733. 'PATCH',
  14734. 'POST',
  14735. 'PROPFIND',
  14736. 'PROPPATCH',
  14737. 'PURGE',
  14738. 'PUT',
  14739. 'REPORT',
  14740. 'SEARCH',
  14741. 'SUBSCRIBE',
  14742. 'TRACE',
  14743. 'UNLOCK',
  14744. 'UNSUBSCRIBE'
  14745. ]
  14746. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  14747. },{"./lib/request":186,"builtin-status-codes":33,"url":191,"xtend":225}],185:[function(require,module,exports){
  14748. (function (global){
  14749. 'use strict';
  14750. exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream);
  14751. exports.blobConstructor = false;
  14752. try {
  14753. new Blob([new ArrayBuffer(1)]);
  14754. exports.blobConstructor = true;
  14755. } catch (e) {}
  14756. // The xhr request to example.com may violate some restrictive CSP configurations,
  14757. // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
  14758. // and assume support for certain features below.
  14759. var xhr;
  14760. function getXHR() {
  14761. // Cache the xhr value
  14762. if (xhr !== undefined) return xhr;
  14763. if (global.XMLHttpRequest) {
  14764. xhr = new global.XMLHttpRequest();
  14765. // If XDomainRequest is available (ie only, where xhr might not work
  14766. // cross domain), use the page location. Otherwise use example.com
  14767. // Note: this doesn't actually make an http request.
  14768. try {
  14769. xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com');
  14770. } catch (e) {
  14771. xhr = null;
  14772. }
  14773. } else {
  14774. // Service workers don't have XHR
  14775. xhr = null;
  14776. }
  14777. return xhr;
  14778. }
  14779. function checkTypeSupport(type) {
  14780. var xhr = getXHR();
  14781. if (!xhr) return false;
  14782. try {
  14783. xhr.responseType = type;
  14784. return xhr.responseType === type;
  14785. } catch (e) {}
  14786. return false;
  14787. }
  14788. // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
  14789. // Safari 7.1 appears to have fixed this bug.
  14790. var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined';
  14791. var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice);
  14792. // If fetch is supported, then arraybuffer will be supported too. Skip calling
  14793. // checkTypeSupport(), since that calls getXHR().
  14794. exports.arraybuffer = exports.fetch || haveArrayBuffer && checkTypeSupport('arraybuffer');
  14795. // These next two tests unavoidably show warnings in Chrome. Since fetch will always
  14796. // be used if it's available, just return false for these to avoid the warnings.
  14797. exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream');
  14798. exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer');
  14799. // If fetch is supported, then overrideMimeType will be supported too. Skip calling
  14800. // getXHR().
  14801. exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
  14802. exports.vbArray = isFunction(global.VBArray);
  14803. function isFunction(value) {
  14804. return typeof value === 'function';
  14805. }
  14806. xhr = null; // Help gc
  14807. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  14808. },{}],186:[function(require,module,exports){
  14809. (function (process,global,Buffer){
  14810. 'use strict';
  14811. var _keys = require('babel-runtime/core-js/object/keys');
  14812. var _keys2 = _interopRequireDefault(_keys);
  14813. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14814. var capability = require('./capability');
  14815. var inherits = require('inherits');
  14816. var response = require('./response');
  14817. var stream = require('readable-stream');
  14818. var toArrayBuffer = require('to-arraybuffer');
  14819. var IncomingMessage = response.IncomingMessage;
  14820. var rStates = response.readyStates;
  14821. function decideMode(preferBinary, useFetch) {
  14822. if (capability.fetch && useFetch) {
  14823. return 'fetch';
  14824. } else if (capability.mozchunkedarraybuffer) {
  14825. return 'moz-chunked-arraybuffer';
  14826. } else if (capability.msstream) {
  14827. return 'ms-stream';
  14828. } else if (capability.arraybuffer && preferBinary) {
  14829. return 'arraybuffer';
  14830. } else if (capability.vbArray && preferBinary) {
  14831. return 'text:vbarray';
  14832. } else {
  14833. return 'text';
  14834. }
  14835. }
  14836. var ClientRequest = module.exports = function (opts) {
  14837. var self = this;
  14838. stream.Writable.call(self);
  14839. self._opts = opts;
  14840. self._body = [];
  14841. self._headers = {};
  14842. if (opts.auth) self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'));
  14843. (0, _keys2.default)(opts.headers).forEach(function (name) {
  14844. self.setHeader(name, opts.headers[name]);
  14845. });
  14846. var preferBinary;
  14847. var useFetch = true;
  14848. if (opts.mode === 'disable-fetch' || 'timeout' in opts) {
  14849. // If the use of XHR should be preferred and includes preserving the 'content-type' header.
  14850. // Force XHR to be used since the Fetch API does not yet support timeouts.
  14851. useFetch = false;
  14852. preferBinary = true;
  14853. } else if (opts.mode === 'prefer-streaming') {
  14854. // If streaming is a high priority but binary compatibility and
  14855. // the accuracy of the 'content-type' header aren't
  14856. preferBinary = false;
  14857. } else if (opts.mode === 'allow-wrong-content-type') {
  14858. // If streaming is more important than preserving the 'content-type' header
  14859. preferBinary = !capability.overrideMimeType;
  14860. } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
  14861. // Use binary if text streaming may corrupt data or the content-type header, or for speed
  14862. preferBinary = true;
  14863. } else {
  14864. throw new Error('Invalid value for opts.mode');
  14865. }
  14866. self._mode = decideMode(preferBinary, useFetch);
  14867. self.on('finish', function () {
  14868. self._onFinish();
  14869. });
  14870. };
  14871. inherits(ClientRequest, stream.Writable);
  14872. ClientRequest.prototype.setHeader = function (name, value) {
  14873. var self = this;
  14874. var lowerName = name.toLowerCase();
  14875. // This check is not necessary, but it prevents warnings from browsers about setting unsafe
  14876. // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
  14877. // http-browserify did it, so I will too.
  14878. if (unsafeHeaders.indexOf(lowerName) !== -1) return;
  14879. self._headers[lowerName] = {
  14880. name: name,
  14881. value: value
  14882. };
  14883. };
  14884. ClientRequest.prototype.getHeader = function (name) {
  14885. var header = this._headers[name.toLowerCase()];
  14886. if (header) return header.value;
  14887. return null;
  14888. };
  14889. ClientRequest.prototype.removeHeader = function (name) {
  14890. var self = this;
  14891. delete self._headers[name.toLowerCase()];
  14892. };
  14893. ClientRequest.prototype._onFinish = function () {
  14894. var self = this;
  14895. if (self._destroyed) return;
  14896. var opts = self._opts;
  14897. var headersObj = self._headers;
  14898. var body = null;
  14899. if (opts.method !== 'GET' && opts.method !== 'HEAD') {
  14900. if (capability.blobConstructor) {
  14901. body = new global.Blob(self._body.map(function (buffer) {
  14902. return toArrayBuffer(buffer);
  14903. }), {
  14904. type: (headersObj['content-type'] || {}).value || ''
  14905. });
  14906. } else {
  14907. // get utf8 string
  14908. body = Buffer.concat(self._body).toString();
  14909. }
  14910. }
  14911. // create flattened list of headers
  14912. var headersList = [];
  14913. (0, _keys2.default)(headersObj).forEach(function (keyName) {
  14914. var name = headersObj[keyName].name;
  14915. var value = headersObj[keyName].value;
  14916. if (Array.isArray(value)) {
  14917. value.forEach(function (v) {
  14918. headersList.push([name, v]);
  14919. });
  14920. } else {
  14921. headersList.push([name, value]);
  14922. }
  14923. });
  14924. if (self._mode === 'fetch') {
  14925. global.fetch(self._opts.url, {
  14926. method: self._opts.method,
  14927. headers: headersList,
  14928. body: body || undefined,
  14929. mode: 'cors',
  14930. credentials: opts.withCredentials ? 'include' : 'same-origin'
  14931. }).then(function (response) {
  14932. self._fetchResponse = response;
  14933. self._connect();
  14934. }, function (reason) {
  14935. self.emit('error', reason);
  14936. });
  14937. } else {
  14938. var xhr = self._xhr = new global.XMLHttpRequest();
  14939. try {
  14940. xhr.open(self._opts.method, self._opts.url, true);
  14941. } catch (err) {
  14942. process.nextTick(function () {
  14943. self.emit('error', err);
  14944. });
  14945. return;
  14946. }
  14947. // Can't set responseType on really old browsers
  14948. if ('responseType' in xhr) xhr.responseType = self._mode.split(':')[0];
  14949. if ('withCredentials' in xhr) xhr.withCredentials = !!opts.withCredentials;
  14950. if (self._mode === 'text' && 'overrideMimeType' in xhr) xhr.overrideMimeType('text/plain; charset=x-user-defined');
  14951. if ('timeout' in opts) {
  14952. xhr.timeout = opts.timeout;
  14953. xhr.ontimeout = function () {
  14954. self.emit('timeout');
  14955. };
  14956. }
  14957. headersList.forEach(function (header) {
  14958. xhr.setRequestHeader(header[0], header[1]);
  14959. });
  14960. self._response = null;
  14961. xhr.onreadystatechange = function () {
  14962. switch (xhr.readyState) {
  14963. case rStates.LOADING:
  14964. case rStates.DONE:
  14965. self._onXHRProgress();
  14966. break;
  14967. }
  14968. };
  14969. // Necessary for streaming in Firefox, since xhr.response is ONLY defined
  14970. // in onprogress, not in onreadystatechange with xhr.readyState = 3
  14971. if (self._mode === 'moz-chunked-arraybuffer') {
  14972. xhr.onprogress = function () {
  14973. self._onXHRProgress();
  14974. };
  14975. }
  14976. xhr.onerror = function () {
  14977. if (self._destroyed) return;
  14978. self.emit('error', new Error('XHR error'));
  14979. };
  14980. try {
  14981. xhr.send(body);
  14982. } catch (err) {
  14983. process.nextTick(function () {
  14984. self.emit('error', err);
  14985. });
  14986. return;
  14987. }
  14988. }
  14989. };
  14990. /**
  14991. * Checks if xhr.status is readable and non-zero, indicating no error.
  14992. * Even though the spec says it should be available in readyState 3,
  14993. * accessing it throws an exception in IE8
  14994. */
  14995. function statusValid(xhr) {
  14996. try {
  14997. var status = xhr.status;
  14998. return status !== null && status !== 0;
  14999. } catch (e) {
  15000. return false;
  15001. }
  15002. }
  15003. ClientRequest.prototype._onXHRProgress = function () {
  15004. var self = this;
  15005. if (!statusValid(self._xhr) || self._destroyed) return;
  15006. if (!self._response) self._connect();
  15007. self._response._onXHRProgress();
  15008. };
  15009. ClientRequest.prototype._connect = function () {
  15010. var self = this;
  15011. if (self._destroyed) return;
  15012. self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode);
  15013. self._response.on('error', function (err) {
  15014. self.emit('error', err);
  15015. });
  15016. self.emit('response', self._response);
  15017. };
  15018. ClientRequest.prototype._write = function (chunk, encoding, cb) {
  15019. var self = this;
  15020. self._body.push(chunk);
  15021. cb();
  15022. };
  15023. ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
  15024. var self = this;
  15025. self._destroyed = true;
  15026. if (self._response) self._response._destroyed = true;
  15027. if (self._xhr) self._xhr.abort();
  15028. // Currently, there isn't a way to truly abort a fetch.
  15029. // If you like bikeshedding, see https://github.com/whatwg/fetch/issues/27
  15030. };
  15031. ClientRequest.prototype.end = function (data, encoding, cb) {
  15032. var self = this;
  15033. if (typeof data === 'function') {
  15034. cb = data;
  15035. data = undefined;
  15036. }
  15037. stream.Writable.prototype.end.call(self, data, encoding, cb);
  15038. };
  15039. ClientRequest.prototype.flushHeaders = function () {};
  15040. ClientRequest.prototype.setTimeout = function () {};
  15041. ClientRequest.prototype.setNoDelay = function () {};
  15042. ClientRequest.prototype.setSocketKeepAlive = function () {};
  15043. // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
  15044. 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'];
  15045. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
  15046. },{"./capability":185,"./response":187,"_process":159,"babel-runtime/core-js/object/keys":18,"buffer":31,"inherits":149,"readable-stream":176,"to-arraybuffer":190}],187:[function(require,module,exports){
  15047. (function (process,global,Buffer){
  15048. 'use strict';
  15049. var capability = require('./capability');
  15050. var inherits = require('inherits');
  15051. var stream = require('readable-stream');
  15052. var rStates = exports.readyStates = {
  15053. UNSENT: 0,
  15054. OPENED: 1,
  15055. HEADERS_RECEIVED: 2,
  15056. LOADING: 3,
  15057. DONE: 4
  15058. };
  15059. var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) {
  15060. var self = this;
  15061. stream.Readable.call(self);
  15062. self._mode = mode;
  15063. self.headers = {};
  15064. self.rawHeaders = [];
  15065. self.trailers = {};
  15066. self.rawTrailers = [];
  15067. // Fake the 'close' event, but only once 'end' fires
  15068. self.on('end', function () {
  15069. // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
  15070. process.nextTick(function () {
  15071. self.emit('close');
  15072. });
  15073. });
  15074. if (mode === 'fetch') {
  15075. var read = function read() {
  15076. reader.read().then(function (result) {
  15077. if (self._destroyed) return;
  15078. if (result.done) {
  15079. self.push(null);
  15080. return;
  15081. }
  15082. self.push(new Buffer(result.value));
  15083. read();
  15084. }).catch(function (err) {
  15085. self.emit('error', err);
  15086. });
  15087. };
  15088. self._fetchResponse = response;
  15089. self.url = response.url;
  15090. self.statusCode = response.status;
  15091. self.statusMessage = response.statusText;
  15092. response.headers.forEach(function (header, key) {
  15093. self.headers[key.toLowerCase()] = header;
  15094. self.rawHeaders.push(key, header);
  15095. });
  15096. // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed
  15097. var reader = response.body.getReader();
  15098. read();
  15099. } else {
  15100. self._xhr = xhr;
  15101. self._pos = 0;
  15102. self.url = xhr.responseURL;
  15103. self.statusCode = xhr.status;
  15104. self.statusMessage = xhr.statusText;
  15105. var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
  15106. headers.forEach(function (header) {
  15107. var matches = header.match(/^([^:]+):\s*(.*)/);
  15108. if (matches) {
  15109. var key = matches[1].toLowerCase();
  15110. if (key === 'set-cookie') {
  15111. if (self.headers[key] === undefined) {
  15112. self.headers[key] = [];
  15113. }
  15114. self.headers[key].push(matches[2]);
  15115. } else if (self.headers[key] !== undefined) {
  15116. self.headers[key] += ', ' + matches[2];
  15117. } else {
  15118. self.headers[key] = matches[2];
  15119. }
  15120. self.rawHeaders.push(matches[1], matches[2]);
  15121. }
  15122. });
  15123. self._charset = 'x-user-defined';
  15124. if (!capability.overrideMimeType) {
  15125. var mimeType = self.rawHeaders['mime-type'];
  15126. if (mimeType) {
  15127. var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
  15128. if (charsetMatch) {
  15129. self._charset = charsetMatch[1].toLowerCase();
  15130. }
  15131. }
  15132. if (!self._charset) self._charset = 'utf-8'; // best guess
  15133. }
  15134. }
  15135. };
  15136. inherits(IncomingMessage, stream.Readable);
  15137. IncomingMessage.prototype._read = function () {};
  15138. IncomingMessage.prototype._onXHRProgress = function () {
  15139. var self = this;
  15140. var xhr = self._xhr;
  15141. var response = null;
  15142. switch (self._mode) {
  15143. case 'text:vbarray':
  15144. // For IE9
  15145. if (xhr.readyState !== rStates.DONE) break;
  15146. try {
  15147. // This fails in IE8
  15148. response = new global.VBArray(xhr.responseBody).toArray();
  15149. } catch (e) {}
  15150. if (response !== null) {
  15151. self.push(new Buffer(response));
  15152. break;
  15153. }
  15154. // Falls through in IE8
  15155. case 'text':
  15156. try {
  15157. // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
  15158. response = xhr.responseText;
  15159. } catch (e) {
  15160. self._mode = 'text:vbarray';
  15161. break;
  15162. }
  15163. if (response.length > self._pos) {
  15164. var newData = response.substr(self._pos);
  15165. if (self._charset === 'x-user-defined') {
  15166. var buffer = new Buffer(newData.length);
  15167. for (var i = 0; i < newData.length; i++) {
  15168. buffer[i] = newData.charCodeAt(i) & 0xff;
  15169. }self.push(buffer);
  15170. } else {
  15171. self.push(newData, self._charset);
  15172. }
  15173. self._pos = response.length;
  15174. }
  15175. break;
  15176. case 'arraybuffer':
  15177. if (xhr.readyState !== rStates.DONE || !xhr.response) break;
  15178. response = xhr.response;
  15179. self.push(new Buffer(new Uint8Array(response)));
  15180. break;
  15181. case 'moz-chunked-arraybuffer':
  15182. // take whole
  15183. response = xhr.response;
  15184. if (xhr.readyState !== rStates.LOADING || !response) break;
  15185. self.push(new Buffer(new Uint8Array(response)));
  15186. break;
  15187. case 'ms-stream':
  15188. response = xhr.response;
  15189. if (xhr.readyState !== rStates.LOADING) break;
  15190. var reader = new global.MSStreamReader();
  15191. reader.onprogress = function () {
  15192. if (reader.result.byteLength > self._pos) {
  15193. self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))));
  15194. self._pos = reader.result.byteLength;
  15195. }
  15196. };
  15197. reader.onload = function () {
  15198. self.push(null);
  15199. };
  15200. // reader.onerror = ??? // TODO: this
  15201. reader.readAsArrayBuffer(response);
  15202. break;
  15203. }
  15204. // The ms-stream case handles end separately in reader.onload()
  15205. if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
  15206. self.push(null);
  15207. }
  15208. };
  15209. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
  15210. },{"./capability":185,"_process":159,"buffer":31,"inherits":149,"readable-stream":176}],188:[function(require,module,exports){
  15211. // Copyright Joyent, Inc. and other Node contributors.
  15212. //
  15213. // Permission is hereby granted, free of charge, to any person obtaining a
  15214. // copy of this software and associated documentation files (the
  15215. // "Software"), to deal in the Software without restriction, including
  15216. // without limitation the rights to use, copy, modify, merge, publish,
  15217. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15218. // persons to whom the Software is furnished to do so, subject to the
  15219. // following conditions:
  15220. //
  15221. // The above copyright notice and this permission notice shall be included
  15222. // in all copies or substantial portions of the Software.
  15223. //
  15224. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15225. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15226. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15227. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15228. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15229. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15230. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15231. var Buffer = require('buffer').Buffer;
  15232. var isBufferEncoding = Buffer.isEncoding
  15233. || function(encoding) {
  15234. switch (encoding && encoding.toLowerCase()) {
  15235. 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;
  15236. default: return false;
  15237. }
  15238. }
  15239. function assertEncoding(encoding) {
  15240. if (encoding && !isBufferEncoding(encoding)) {
  15241. throw new Error('Unknown encoding: ' + encoding);
  15242. }
  15243. }
  15244. // StringDecoder provides an interface for efficiently splitting a series of
  15245. // buffers into a series of JS strings without breaking apart multi-byte
  15246. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  15247. //
  15248. // @TODO Handling all encodings inside a single object makes it very difficult
  15249. // to reason about this code, so it should be split up in the future.
  15250. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  15251. // points as used by CESU-8.
  15252. var StringDecoder = exports.StringDecoder = function(encoding) {
  15253. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  15254. assertEncoding(encoding);
  15255. switch (this.encoding) {
  15256. case 'utf8':
  15257. // CESU-8 represents each of Surrogate Pair by 3-bytes
  15258. this.surrogateSize = 3;
  15259. break;
  15260. case 'ucs2':
  15261. case 'utf16le':
  15262. // UTF-16 represents each of Surrogate Pair by 2-bytes
  15263. this.surrogateSize = 2;
  15264. this.detectIncompleteChar = utf16DetectIncompleteChar;
  15265. break;
  15266. case 'base64':
  15267. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  15268. this.surrogateSize = 3;
  15269. this.detectIncompleteChar = base64DetectIncompleteChar;
  15270. break;
  15271. default:
  15272. this.write = passThroughWrite;
  15273. return;
  15274. }
  15275. // Enough space to store all bytes of a single character. UTF-8 needs 4
  15276. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  15277. this.charBuffer = new Buffer(6);
  15278. // Number of bytes received for the current incomplete multi-byte character.
  15279. this.charReceived = 0;
  15280. // Number of bytes expected for the current incomplete multi-byte character.
  15281. this.charLength = 0;
  15282. };
  15283. // write decodes the given buffer and returns it as JS string that is
  15284. // guaranteed to not contain any partial multi-byte characters. Any partial
  15285. // character found at the end of the buffer is buffered up, and will be
  15286. // returned when calling write again with the remaining bytes.
  15287. //
  15288. // Note: Converting a Buffer containing an orphan surrogate to a String
  15289. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  15290. // Buffer#write) will replace incomplete surrogates with the unicode
  15291. // replacement character. See https://codereview.chromium.org/121173009/ .
  15292. StringDecoder.prototype.write = function(buffer) {
  15293. var charStr = '';
  15294. // if our last write ended with an incomplete multibyte character
  15295. while (this.charLength) {
  15296. // determine how many remaining bytes this buffer has to offer for this char
  15297. var available = (buffer.length >= this.charLength - this.charReceived) ?
  15298. this.charLength - this.charReceived :
  15299. buffer.length;
  15300. // add the new bytes to the char buffer
  15301. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  15302. this.charReceived += available;
  15303. if (this.charReceived < this.charLength) {
  15304. // still not enough chars in this buffer? wait for more ...
  15305. return '';
  15306. }
  15307. // remove bytes belonging to the current character from the buffer
  15308. buffer = buffer.slice(available, buffer.length);
  15309. // get the character that was split
  15310. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  15311. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  15312. var charCode = charStr.charCodeAt(charStr.length - 1);
  15313. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  15314. this.charLength += this.surrogateSize;
  15315. charStr = '';
  15316. continue;
  15317. }
  15318. this.charReceived = this.charLength = 0;
  15319. // if there are no more bytes in this buffer, just emit our char
  15320. if (buffer.length === 0) {
  15321. return charStr;
  15322. }
  15323. break;
  15324. }
  15325. // determine and set charLength / charReceived
  15326. this.detectIncompleteChar(buffer);
  15327. var end = buffer.length;
  15328. if (this.charLength) {
  15329. // buffer the incomplete character bytes we got
  15330. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  15331. end -= this.charReceived;
  15332. }
  15333. charStr += buffer.toString(this.encoding, 0, end);
  15334. var end = charStr.length - 1;
  15335. var charCode = charStr.charCodeAt(end);
  15336. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  15337. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  15338. var size = this.surrogateSize;
  15339. this.charLength += size;
  15340. this.charReceived += size;
  15341. this.charBuffer.copy(this.charBuffer, size, 0, size);
  15342. buffer.copy(this.charBuffer, 0, 0, size);
  15343. return charStr.substring(0, end);
  15344. }
  15345. // or just emit the charStr
  15346. return charStr;
  15347. };
  15348. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  15349. // the end of the given buffer. If so, it sets this.charLength to the byte
  15350. // length that character, and sets this.charReceived to the number of bytes
  15351. // that are available for this character.
  15352. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  15353. // determine how many bytes we have to check at the end of this buffer
  15354. var i = (buffer.length >= 3) ? 3 : buffer.length;
  15355. // Figure out if one of the last i bytes of our buffer announces an
  15356. // incomplete char.
  15357. for (; i > 0; i--) {
  15358. var c = buffer[buffer.length - i];
  15359. // See http://en.wikipedia.org/wiki/UTF-8#Description
  15360. // 110XXXXX
  15361. if (i == 1 && c >> 5 == 0x06) {
  15362. this.charLength = 2;
  15363. break;
  15364. }
  15365. // 1110XXXX
  15366. if (i <= 2 && c >> 4 == 0x0E) {
  15367. this.charLength = 3;
  15368. break;
  15369. }
  15370. // 11110XXX
  15371. if (i <= 3 && c >> 3 == 0x1E) {
  15372. this.charLength = 4;
  15373. break;
  15374. }
  15375. }
  15376. this.charReceived = i;
  15377. };
  15378. StringDecoder.prototype.end = function(buffer) {
  15379. var res = '';
  15380. if (buffer && buffer.length)
  15381. res = this.write(buffer);
  15382. if (this.charReceived) {
  15383. var cr = this.charReceived;
  15384. var buf = this.charBuffer;
  15385. var enc = this.encoding;
  15386. res += buf.slice(0, cr).toString(enc);
  15387. }
  15388. return res;
  15389. };
  15390. function passThroughWrite(buffer) {
  15391. return buffer.toString(this.encoding);
  15392. }
  15393. function utf16DetectIncompleteChar(buffer) {
  15394. this.charReceived = buffer.length % 2;
  15395. this.charLength = this.charReceived ? 2 : 0;
  15396. }
  15397. function base64DetectIncompleteChar(buffer) {
  15398. this.charReceived = buffer.length % 3;
  15399. this.charLength = this.charReceived ? 3 : 0;
  15400. }
  15401. },{"buffer":31}],189:[function(require,module,exports){
  15402. var nextTick = require('process/browser.js').nextTick;
  15403. var apply = Function.prototype.apply;
  15404. var slice = Array.prototype.slice;
  15405. var immediateIds = {};
  15406. var nextImmediateId = 0;
  15407. // DOM APIs, for completeness
  15408. exports.setTimeout = function() {
  15409. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  15410. };
  15411. exports.setInterval = function() {
  15412. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  15413. };
  15414. exports.clearTimeout =
  15415. exports.clearInterval = function(timeout) { timeout.close(); };
  15416. function Timeout(id, clearFn) {
  15417. this._id = id;
  15418. this._clearFn = clearFn;
  15419. }
  15420. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  15421. Timeout.prototype.close = function() {
  15422. this._clearFn.call(window, this._id);
  15423. };
  15424. // Does not start the time, just sets up the members needed.
  15425. exports.enroll = function(item, msecs) {
  15426. clearTimeout(item._idleTimeoutId);
  15427. item._idleTimeout = msecs;
  15428. };
  15429. exports.unenroll = function(item) {
  15430. clearTimeout(item._idleTimeoutId);
  15431. item._idleTimeout = -1;
  15432. };
  15433. exports._unrefActive = exports.active = function(item) {
  15434. clearTimeout(item._idleTimeoutId);
  15435. var msecs = item._idleTimeout;
  15436. if (msecs >= 0) {
  15437. item._idleTimeoutId = setTimeout(function onTimeout() {
  15438. if (item._onTimeout)
  15439. item._onTimeout();
  15440. }, msecs);
  15441. }
  15442. };
  15443. // That's not how node.js implements it but the exposed api is the same.
  15444. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  15445. var id = nextImmediateId++;
  15446. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  15447. immediateIds[id] = true;
  15448. nextTick(function onNextTick() {
  15449. if (immediateIds[id]) {
  15450. // fn.call() is faster so we optimize for the common use-case
  15451. // @see http://jsperf.com/call-apply-segu
  15452. if (args) {
  15453. fn.apply(null, args);
  15454. } else {
  15455. fn.call(null);
  15456. }
  15457. // Prevent ids from leaking
  15458. exports.clearImmediate(id);
  15459. }
  15460. });
  15461. return id;
  15462. };
  15463. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  15464. delete immediateIds[id];
  15465. };
  15466. },{"process/browser.js":159}],190:[function(require,module,exports){
  15467. var Buffer = require('buffer').Buffer
  15468. module.exports = function (buf) {
  15469. // If the buffer is backed by a Uint8Array, a faster version will work
  15470. if (buf instanceof Uint8Array) {
  15471. // If the buffer isn't a subarray, return the underlying ArrayBuffer
  15472. if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
  15473. return buf.buffer
  15474. } else if (typeof buf.buffer.slice === 'function') {
  15475. // Otherwise we need to get a proper copy
  15476. return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
  15477. }
  15478. }
  15479. if (Buffer.isBuffer(buf)) {
  15480. // This is the slow version that will work with any Buffer
  15481. // implementation (even in old browsers)
  15482. var arrayCopy = new Uint8Array(buf.length)
  15483. var len = buf.length
  15484. for (var i = 0; i < len; i++) {
  15485. arrayCopy[i] = buf[i]
  15486. }
  15487. return arrayCopy.buffer
  15488. } else {
  15489. throw new Error('Argument must be a Buffer')
  15490. }
  15491. }
  15492. },{"buffer":31}],191:[function(require,module,exports){
  15493. // Copyright Joyent, Inc. and other Node contributors.
  15494. //
  15495. // Permission is hereby granted, free of charge, to any person obtaining a
  15496. // copy of this software and associated documentation files (the
  15497. // "Software"), to deal in the Software without restriction, including
  15498. // without limitation the rights to use, copy, modify, merge, publish,
  15499. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15500. // persons to whom the Software is furnished to do so, subject to the
  15501. // following conditions:
  15502. //
  15503. // The above copyright notice and this permission notice shall be included
  15504. // in all copies or substantial portions of the Software.
  15505. //
  15506. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15507. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15508. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15509. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15510. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15511. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15512. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15513. 'use strict';
  15514. var punycode = require('punycode');
  15515. var util = require('./util');
  15516. exports.parse = urlParse;
  15517. exports.resolve = urlResolve;
  15518. exports.resolveObject = urlResolveObject;
  15519. exports.format = urlFormat;
  15520. exports.Url = Url;
  15521. function Url() {
  15522. this.protocol = null;
  15523. this.slashes = null;
  15524. this.auth = null;
  15525. this.host = null;
  15526. this.port = null;
  15527. this.hostname = null;
  15528. this.hash = null;
  15529. this.search = null;
  15530. this.query = null;
  15531. this.pathname = null;
  15532. this.path = null;
  15533. this.href = null;
  15534. }
  15535. // Reference: RFC 3986, RFC 1808, RFC 2396
  15536. // define these here so at least they only have to be
  15537. // compiled once on the first module load.
  15538. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  15539. portPattern = /:[0-9]*$/,
  15540. // Special case for a simple path URL
  15541. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  15542. // RFC 2396: characters reserved for delimiting URLs.
  15543. // We actually just auto-escape these.
  15544. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  15545. // RFC 2396: characters not allowed for various reasons.
  15546. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  15547. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  15548. autoEscape = ['\''].concat(unwise),
  15549. // Characters that are never ever allowed in a hostname.
  15550. // Note that any invalid chars are also handled, but these
  15551. // are the ones that are *expected* to be seen, so we fast-path
  15552. // them.
  15553. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  15554. hostEndingChars = ['/', '?', '#'],
  15555. hostnameMaxLen = 255,
  15556. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  15557. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  15558. // protocols that can allow "unsafe" and "unwise" chars.
  15559. unsafeProtocol = {
  15560. 'javascript': true,
  15561. 'javascript:': true
  15562. },
  15563. // protocols that never have a hostname.
  15564. hostlessProtocol = {
  15565. 'javascript': true,
  15566. 'javascript:': true
  15567. },
  15568. // protocols that always contain a // bit.
  15569. slashedProtocol = {
  15570. 'http': true,
  15571. 'https': true,
  15572. 'ftp': true,
  15573. 'gopher': true,
  15574. 'file': true,
  15575. 'http:': true,
  15576. 'https:': true,
  15577. 'ftp:': true,
  15578. 'gopher:': true,
  15579. 'file:': true
  15580. },
  15581. querystring = require('querystring');
  15582. function urlParse(url, parseQueryString, slashesDenoteHost) {
  15583. if (url && util.isObject(url) && url instanceof Url) return url;
  15584. var u = new Url;
  15585. u.parse(url, parseQueryString, slashesDenoteHost);
  15586. return u;
  15587. }
  15588. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  15589. if (!util.isString(url)) {
  15590. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  15591. }
  15592. // Copy chrome, IE, opera backslash-handling behavior.
  15593. // Back slashes before the query string get converted to forward slashes
  15594. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  15595. var queryIndex = url.indexOf('?'),
  15596. splitter =
  15597. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  15598. uSplit = url.split(splitter),
  15599. slashRegex = /\\/g;
  15600. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  15601. url = uSplit.join(splitter);
  15602. var rest = url;
  15603. // trim before proceeding.
  15604. // This is to support parse stuff like " http://foo.com \n"
  15605. rest = rest.trim();
  15606. if (!slashesDenoteHost && url.split('#').length === 1) {
  15607. // Try fast path regexp
  15608. var simplePath = simplePathPattern.exec(rest);
  15609. if (simplePath) {
  15610. this.path = rest;
  15611. this.href = rest;
  15612. this.pathname = simplePath[1];
  15613. if (simplePath[2]) {
  15614. this.search = simplePath[2];
  15615. if (parseQueryString) {
  15616. this.query = querystring.parse(this.search.substr(1));
  15617. } else {
  15618. this.query = this.search.substr(1);
  15619. }
  15620. } else if (parseQueryString) {
  15621. this.search = '';
  15622. this.query = {};
  15623. }
  15624. return this;
  15625. }
  15626. }
  15627. var proto = protocolPattern.exec(rest);
  15628. if (proto) {
  15629. proto = proto[0];
  15630. var lowerProto = proto.toLowerCase();
  15631. this.protocol = lowerProto;
  15632. rest = rest.substr(proto.length);
  15633. }
  15634. // figure out if it's got a host
  15635. // user@server is *always* interpreted as a hostname, and url
  15636. // resolution will treat //foo/bar as host=foo,path=bar because that's
  15637. // how the browser resolves relative URLs.
  15638. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  15639. var slashes = rest.substr(0, 2) === '//';
  15640. if (slashes && !(proto && hostlessProtocol[proto])) {
  15641. rest = rest.substr(2);
  15642. this.slashes = true;
  15643. }
  15644. }
  15645. if (!hostlessProtocol[proto] &&
  15646. (slashes || (proto && !slashedProtocol[proto]))) {
  15647. // there's a hostname.
  15648. // the first instance of /, ?, ;, or # ends the host.
  15649. //
  15650. // If there is an @ in the hostname, then non-host chars *are* allowed
  15651. // to the left of the last @ sign, unless some host-ending character
  15652. // comes *before* the @-sign.
  15653. // URLs are obnoxious.
  15654. //
  15655. // ex:
  15656. // http://a@b@c/ => user:a@b host:c
  15657. // http://a@b?@c => user:a host:c path:/?@c
  15658. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  15659. // Review our test case against browsers more comprehensively.
  15660. // find the first instance of any hostEndingChars
  15661. var hostEnd = -1;
  15662. for (var i = 0; i < hostEndingChars.length; i++) {
  15663. var hec = rest.indexOf(hostEndingChars[i]);
  15664. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  15665. hostEnd = hec;
  15666. }
  15667. // at this point, either we have an explicit point where the
  15668. // auth portion cannot go past, or the last @ char is the decider.
  15669. var auth, atSign;
  15670. if (hostEnd === -1) {
  15671. // atSign can be anywhere.
  15672. atSign = rest.lastIndexOf('@');
  15673. } else {
  15674. // atSign must be in auth portion.
  15675. // http://a@b/c@d => host:b auth:a path:/c@d
  15676. atSign = rest.lastIndexOf('@', hostEnd);
  15677. }
  15678. // Now we have a portion which is definitely the auth.
  15679. // Pull that off.
  15680. if (atSign !== -1) {
  15681. auth = rest.slice(0, atSign);
  15682. rest = rest.slice(atSign + 1);
  15683. this.auth = decodeURIComponent(auth);
  15684. }
  15685. // the host is the remaining to the left of the first non-host char
  15686. hostEnd = -1;
  15687. for (var i = 0; i < nonHostChars.length; i++) {
  15688. var hec = rest.indexOf(nonHostChars[i]);
  15689. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  15690. hostEnd = hec;
  15691. }
  15692. // if we still have not hit it, then the entire thing is a host.
  15693. if (hostEnd === -1)
  15694. hostEnd = rest.length;
  15695. this.host = rest.slice(0, hostEnd);
  15696. rest = rest.slice(hostEnd);
  15697. // pull out port.
  15698. this.parseHost();
  15699. // we've indicated that there is a hostname,
  15700. // so even if it's empty, it has to be present.
  15701. this.hostname = this.hostname || '';
  15702. // if hostname begins with [ and ends with ]
  15703. // assume that it's an IPv6 address.
  15704. var ipv6Hostname = this.hostname[0] === '[' &&
  15705. this.hostname[this.hostname.length - 1] === ']';
  15706. // validate a little.
  15707. if (!ipv6Hostname) {
  15708. var hostparts = this.hostname.split(/\./);
  15709. for (var i = 0, l = hostparts.length; i < l; i++) {
  15710. var part = hostparts[i];
  15711. if (!part) continue;
  15712. if (!part.match(hostnamePartPattern)) {
  15713. var newpart = '';
  15714. for (var j = 0, k = part.length; j < k; j++) {
  15715. if (part.charCodeAt(j) > 127) {
  15716. // we replace non-ASCII char with a temporary placeholder
  15717. // we need this to make sure size of hostname is not
  15718. // broken by replacing non-ASCII by nothing
  15719. newpart += 'x';
  15720. } else {
  15721. newpart += part[j];
  15722. }
  15723. }
  15724. // we test again with ASCII char only
  15725. if (!newpart.match(hostnamePartPattern)) {
  15726. var validParts = hostparts.slice(0, i);
  15727. var notHost = hostparts.slice(i + 1);
  15728. var bit = part.match(hostnamePartStart);
  15729. if (bit) {
  15730. validParts.push(bit[1]);
  15731. notHost.unshift(bit[2]);
  15732. }
  15733. if (notHost.length) {
  15734. rest = '/' + notHost.join('.') + rest;
  15735. }
  15736. this.hostname = validParts.join('.');
  15737. break;
  15738. }
  15739. }
  15740. }
  15741. }
  15742. if (this.hostname.length > hostnameMaxLen) {
  15743. this.hostname = '';
  15744. } else {
  15745. // hostnames are always lower case.
  15746. this.hostname = this.hostname.toLowerCase();
  15747. }
  15748. if (!ipv6Hostname) {
  15749. // IDNA Support: Returns a punycoded representation of "domain".
  15750. // It only converts parts of the domain name that
  15751. // have non-ASCII characters, i.e. it doesn't matter if
  15752. // you call it with a domain that already is ASCII-only.
  15753. this.hostname = punycode.toASCII(this.hostname);
  15754. }
  15755. var p = this.port ? ':' + this.port : '';
  15756. var h = this.hostname || '';
  15757. this.host = h + p;
  15758. this.href += this.host;
  15759. // strip [ and ] from the hostname
  15760. // the host field still retains them, though
  15761. if (ipv6Hostname) {
  15762. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  15763. if (rest[0] !== '/') {
  15764. rest = '/' + rest;
  15765. }
  15766. }
  15767. }
  15768. // now rest is set to the post-host stuff.
  15769. // chop off any delim chars.
  15770. if (!unsafeProtocol[lowerProto]) {
  15771. // First, make 100% sure that any "autoEscape" chars get
  15772. // escaped, even if encodeURIComponent doesn't think they
  15773. // need to be.
  15774. for (var i = 0, l = autoEscape.length; i < l; i++) {
  15775. var ae = autoEscape[i];
  15776. if (rest.indexOf(ae) === -1)
  15777. continue;
  15778. var esc = encodeURIComponent(ae);
  15779. if (esc === ae) {
  15780. esc = escape(ae);
  15781. }
  15782. rest = rest.split(ae).join(esc);
  15783. }
  15784. }
  15785. // chop off from the tail first.
  15786. var hash = rest.indexOf('#');
  15787. if (hash !== -1) {
  15788. // got a fragment string.
  15789. this.hash = rest.substr(hash);
  15790. rest = rest.slice(0, hash);
  15791. }
  15792. var qm = rest.indexOf('?');
  15793. if (qm !== -1) {
  15794. this.search = rest.substr(qm);
  15795. this.query = rest.substr(qm + 1);
  15796. if (parseQueryString) {
  15797. this.query = querystring.parse(this.query);
  15798. }
  15799. rest = rest.slice(0, qm);
  15800. } else if (parseQueryString) {
  15801. // no query string, but parseQueryString still requested
  15802. this.search = '';
  15803. this.query = {};
  15804. }
  15805. if (rest) this.pathname = rest;
  15806. if (slashedProtocol[lowerProto] &&
  15807. this.hostname && !this.pathname) {
  15808. this.pathname = '/';
  15809. }
  15810. //to support http.request
  15811. if (this.pathname || this.search) {
  15812. var p = this.pathname || '';
  15813. var s = this.search || '';
  15814. this.path = p + s;
  15815. }
  15816. // finally, reconstruct the href based on what has been validated.
  15817. this.href = this.format();
  15818. return this;
  15819. };
  15820. // format a parsed object into a url string
  15821. function urlFormat(obj) {
  15822. // ensure it's an object, and not a string url.
  15823. // If it's an obj, this is a no-op.
  15824. // this way, you can call url_format() on strings
  15825. // to clean up potentially wonky urls.
  15826. if (util.isString(obj)) obj = urlParse(obj);
  15827. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  15828. return obj.format();
  15829. }
  15830. Url.prototype.format = function() {
  15831. var auth = this.auth || '';
  15832. if (auth) {
  15833. auth = encodeURIComponent(auth);
  15834. auth = auth.replace(/%3A/i, ':');
  15835. auth += '@';
  15836. }
  15837. var protocol = this.protocol || '',
  15838. pathname = this.pathname || '',
  15839. hash = this.hash || '',
  15840. host = false,
  15841. query = '';
  15842. if (this.host) {
  15843. host = auth + this.host;
  15844. } else if (this.hostname) {
  15845. host = auth + (this.hostname.indexOf(':') === -1 ?
  15846. this.hostname :
  15847. '[' + this.hostname + ']');
  15848. if (this.port) {
  15849. host += ':' + this.port;
  15850. }
  15851. }
  15852. if (this.query &&
  15853. util.isObject(this.query) &&
  15854. Object.keys(this.query).length) {
  15855. query = querystring.stringify(this.query);
  15856. }
  15857. var search = this.search || (query && ('?' + query)) || '';
  15858. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  15859. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  15860. // unless they had them to begin with.
  15861. if (this.slashes ||
  15862. (!protocol || slashedProtocol[protocol]) && host !== false) {
  15863. host = '//' + (host || '');
  15864. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  15865. } else if (!host) {
  15866. host = '';
  15867. }
  15868. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  15869. if (search && search.charAt(0) !== '?') search = '?' + search;
  15870. pathname = pathname.replace(/[?#]/g, function(match) {
  15871. return encodeURIComponent(match);
  15872. });
  15873. search = search.replace('#', '%23');
  15874. return protocol + host + pathname + search + hash;
  15875. };
  15876. function urlResolve(source, relative) {
  15877. return urlParse(source, false, true).resolve(relative);
  15878. }
  15879. Url.prototype.resolve = function(relative) {
  15880. return this.resolveObject(urlParse(relative, false, true)).format();
  15881. };
  15882. function urlResolveObject(source, relative) {
  15883. if (!source) return relative;
  15884. return urlParse(source, false, true).resolveObject(relative);
  15885. }
  15886. Url.prototype.resolveObject = function(relative) {
  15887. if (util.isString(relative)) {
  15888. var rel = new Url();
  15889. rel.parse(relative, false, true);
  15890. relative = rel;
  15891. }
  15892. var result = new Url();
  15893. var tkeys = Object.keys(this);
  15894. for (var tk = 0; tk < tkeys.length; tk++) {
  15895. var tkey = tkeys[tk];
  15896. result[tkey] = this[tkey];
  15897. }
  15898. // hash is always overridden, no matter what.
  15899. // even href="" will remove it.
  15900. result.hash = relative.hash;
  15901. // if the relative url is empty, then there's nothing left to do here.
  15902. if (relative.href === '') {
  15903. result.href = result.format();
  15904. return result;
  15905. }
  15906. // hrefs like //foo/bar always cut to the protocol.
  15907. if (relative.slashes && !relative.protocol) {
  15908. // take everything except the protocol from relative
  15909. var rkeys = Object.keys(relative);
  15910. for (var rk = 0; rk < rkeys.length; rk++) {
  15911. var rkey = rkeys[rk];
  15912. if (rkey !== 'protocol')
  15913. result[rkey] = relative[rkey];
  15914. }
  15915. //urlParse appends trailing / to urls like http://www.example.com
  15916. if (slashedProtocol[result.protocol] &&
  15917. result.hostname && !result.pathname) {
  15918. result.path = result.pathname = '/';
  15919. }
  15920. result.href = result.format();
  15921. return result;
  15922. }
  15923. if (relative.protocol && relative.protocol !== result.protocol) {
  15924. // if it's a known url protocol, then changing
  15925. // the protocol does weird things
  15926. // first, if it's not file:, then we MUST have a host,
  15927. // and if there was a path
  15928. // to begin with, then we MUST have a path.
  15929. // if it is file:, then the host is dropped,
  15930. // because that's known to be hostless.
  15931. // anything else is assumed to be absolute.
  15932. if (!slashedProtocol[relative.protocol]) {
  15933. var keys = Object.keys(relative);
  15934. for (var v = 0; v < keys.length; v++) {
  15935. var k = keys[v];
  15936. result[k] = relative[k];
  15937. }
  15938. result.href = result.format();
  15939. return result;
  15940. }
  15941. result.protocol = relative.protocol;
  15942. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  15943. var relPath = (relative.pathname || '').split('/');
  15944. while (relPath.length && !(relative.host = relPath.shift()));
  15945. if (!relative.host) relative.host = '';
  15946. if (!relative.hostname) relative.hostname = '';
  15947. if (relPath[0] !== '') relPath.unshift('');
  15948. if (relPath.length < 2) relPath.unshift('');
  15949. result.pathname = relPath.join('/');
  15950. } else {
  15951. result.pathname = relative.pathname;
  15952. }
  15953. result.search = relative.search;
  15954. result.query = relative.query;
  15955. result.host = relative.host || '';
  15956. result.auth = relative.auth;
  15957. result.hostname = relative.hostname || relative.host;
  15958. result.port = relative.port;
  15959. // to support http.request
  15960. if (result.pathname || result.search) {
  15961. var p = result.pathname || '';
  15962. var s = result.search || '';
  15963. result.path = p + s;
  15964. }
  15965. result.slashes = result.slashes || relative.slashes;
  15966. result.href = result.format();
  15967. return result;
  15968. }
  15969. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  15970. isRelAbs = (
  15971. relative.host ||
  15972. relative.pathname && relative.pathname.charAt(0) === '/'
  15973. ),
  15974. mustEndAbs = (isRelAbs || isSourceAbs ||
  15975. (result.host && relative.pathname)),
  15976. removeAllDots = mustEndAbs,
  15977. srcPath = result.pathname && result.pathname.split('/') || [],
  15978. relPath = relative.pathname && relative.pathname.split('/') || [],
  15979. psychotic = result.protocol && !slashedProtocol[result.protocol];
  15980. // if the url is a non-slashed url, then relative
  15981. // links like ../.. should be able
  15982. // to crawl up to the hostname, as well. This is strange.
  15983. // result.protocol has already been set by now.
  15984. // Later on, put the first path part into the host field.
  15985. if (psychotic) {
  15986. result.hostname = '';
  15987. result.port = null;
  15988. if (result.host) {
  15989. if (srcPath[0] === '') srcPath[0] = result.host;
  15990. else srcPath.unshift(result.host);
  15991. }
  15992. result.host = '';
  15993. if (relative.protocol) {
  15994. relative.hostname = null;
  15995. relative.port = null;
  15996. if (relative.host) {
  15997. if (relPath[0] === '') relPath[0] = relative.host;
  15998. else relPath.unshift(relative.host);
  15999. }
  16000. relative.host = null;
  16001. }
  16002. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  16003. }
  16004. if (isRelAbs) {
  16005. // it's absolute.
  16006. result.host = (relative.host || relative.host === '') ?
  16007. relative.host : result.host;
  16008. result.hostname = (relative.hostname || relative.hostname === '') ?
  16009. relative.hostname : result.hostname;
  16010. result.search = relative.search;
  16011. result.query = relative.query;
  16012. srcPath = relPath;
  16013. // fall through to the dot-handling below.
  16014. } else if (relPath.length) {
  16015. // it's relative
  16016. // throw away the existing file, and take the new path instead.
  16017. if (!srcPath) srcPath = [];
  16018. srcPath.pop();
  16019. srcPath = srcPath.concat(relPath);
  16020. result.search = relative.search;
  16021. result.query = relative.query;
  16022. } else if (!util.isNullOrUndefined(relative.search)) {
  16023. // just pull out the search.
  16024. // like href='?foo'.
  16025. // Put this after the other two cases because it simplifies the booleans
  16026. if (psychotic) {
  16027. result.hostname = result.host = srcPath.shift();
  16028. //occationaly the auth can get stuck only in host
  16029. //this especially happens in cases like
  16030. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  16031. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  16032. result.host.split('@') : false;
  16033. if (authInHost) {
  16034. result.auth = authInHost.shift();
  16035. result.host = result.hostname = authInHost.shift();
  16036. }
  16037. }
  16038. result.search = relative.search;
  16039. result.query = relative.query;
  16040. //to support http.request
  16041. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  16042. result.path = (result.pathname ? result.pathname : '') +
  16043. (result.search ? result.search : '');
  16044. }
  16045. result.href = result.format();
  16046. return result;
  16047. }
  16048. if (!srcPath.length) {
  16049. // no path at all. easy.
  16050. // we've already handled the other stuff above.
  16051. result.pathname = null;
  16052. //to support http.request
  16053. if (result.search) {
  16054. result.path = '/' + result.search;
  16055. } else {
  16056. result.path = null;
  16057. }
  16058. result.href = result.format();
  16059. return result;
  16060. }
  16061. // if a url ENDs in . or .., then it must get a trailing slash.
  16062. // however, if it ends in anything else non-slashy,
  16063. // then it must NOT get a trailing slash.
  16064. var last = srcPath.slice(-1)[0];
  16065. var hasTrailingSlash = (
  16066. (result.host || relative.host || srcPath.length > 1) &&
  16067. (last === '.' || last === '..') || last === '');
  16068. // strip single dots, resolve double dots to parent dir
  16069. // if the path tries to go above the root, `up` ends up > 0
  16070. var up = 0;
  16071. for (var i = srcPath.length; i >= 0; i--) {
  16072. last = srcPath[i];
  16073. if (last === '.') {
  16074. srcPath.splice(i, 1);
  16075. } else if (last === '..') {
  16076. srcPath.splice(i, 1);
  16077. up++;
  16078. } else if (up) {
  16079. srcPath.splice(i, 1);
  16080. up--;
  16081. }
  16082. }
  16083. // if the path is allowed to go above the root, restore leading ..s
  16084. if (!mustEndAbs && !removeAllDots) {
  16085. for (; up--; up) {
  16086. srcPath.unshift('..');
  16087. }
  16088. }
  16089. if (mustEndAbs && srcPath[0] !== '' &&
  16090. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  16091. srcPath.unshift('');
  16092. }
  16093. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  16094. srcPath.push('');
  16095. }
  16096. var isAbsolute = srcPath[0] === '' ||
  16097. (srcPath[0] && srcPath[0].charAt(0) === '/');
  16098. // put the host back
  16099. if (psychotic) {
  16100. result.hostname = result.host = isAbsolute ? '' :
  16101. srcPath.length ? srcPath.shift() : '';
  16102. //occationaly the auth can get stuck only in host
  16103. //this especially happens in cases like
  16104. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  16105. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  16106. result.host.split('@') : false;
  16107. if (authInHost) {
  16108. result.auth = authInHost.shift();
  16109. result.host = result.hostname = authInHost.shift();
  16110. }
  16111. }
  16112. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  16113. if (mustEndAbs && !isAbsolute) {
  16114. srcPath.unshift('');
  16115. }
  16116. if (!srcPath.length) {
  16117. result.pathname = null;
  16118. result.path = null;
  16119. } else {
  16120. result.pathname = srcPath.join('/');
  16121. }
  16122. //to support request.http
  16123. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  16124. result.path = (result.pathname ? result.pathname : '') +
  16125. (result.search ? result.search : '');
  16126. }
  16127. result.auth = relative.auth || result.auth;
  16128. result.slashes = result.slashes || relative.slashes;
  16129. result.href = result.format();
  16130. return result;
  16131. };
  16132. Url.prototype.parseHost = function() {
  16133. var host = this.host;
  16134. var port = portPattern.exec(host);
  16135. if (port) {
  16136. port = port[0];
  16137. if (port !== ':') {
  16138. this.port = port.substr(1);
  16139. }
  16140. host = host.substr(0, host.length - port.length);
  16141. }
  16142. if (host) this.hostname = host;
  16143. };
  16144. },{"./util":192,"punycode":160,"querystring":163}],192:[function(require,module,exports){
  16145. 'use strict';
  16146. module.exports = {
  16147. isString: function(arg) {
  16148. return typeof(arg) === 'string';
  16149. },
  16150. isObject: function(arg) {
  16151. return typeof(arg) === 'object' && arg !== null;
  16152. },
  16153. isNull: function(arg) {
  16154. return arg === null;
  16155. },
  16156. isNullOrUndefined: function(arg) {
  16157. return arg == null;
  16158. }
  16159. };
  16160. },{}],193:[function(require,module,exports){
  16161. (function (global){
  16162. /**
  16163. * Module exports.
  16164. */
  16165. module.exports = deprecate;
  16166. /**
  16167. * Mark that a method should not be used.
  16168. * Returns a modified function which warns once by default.
  16169. *
  16170. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  16171. *
  16172. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  16173. * will throw an Error when invoked.
  16174. *
  16175. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  16176. * will invoke `console.trace()` instead of `console.error()`.
  16177. *
  16178. * @param {Function} fn - the function to deprecate
  16179. * @param {String} msg - the string to print to the console when `fn` is invoked
  16180. * @returns {Function} a new "deprecated" version of `fn`
  16181. * @api public
  16182. */
  16183. function deprecate (fn, msg) {
  16184. if (config('noDeprecation')) {
  16185. return fn;
  16186. }
  16187. var warned = false;
  16188. function deprecated() {
  16189. if (!warned) {
  16190. if (config('throwDeprecation')) {
  16191. throw new Error(msg);
  16192. } else if (config('traceDeprecation')) {
  16193. console.trace(msg);
  16194. } else {
  16195. console.warn(msg);
  16196. }
  16197. warned = true;
  16198. }
  16199. return fn.apply(this, arguments);
  16200. }
  16201. return deprecated;
  16202. }
  16203. /**
  16204. * Checks `localStorage` for boolean values for the given `name`.
  16205. *
  16206. * @param {String} name
  16207. * @returns {Boolean}
  16208. * @api private
  16209. */
  16210. function config (name) {
  16211. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  16212. try {
  16213. if (!global.localStorage) return false;
  16214. } catch (_) {
  16215. return false;
  16216. }
  16217. var val = global.localStorage[name];
  16218. if (null == val) return false;
  16219. return String(val).toLowerCase() === 'true';
  16220. }
  16221. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  16222. },{}],194:[function(require,module,exports){
  16223. arguments[4][149][0].apply(exports,arguments)
  16224. },{"dup":149}],195:[function(require,module,exports){
  16225. module.exports = function isBuffer(arg) {
  16226. return arg && typeof arg === 'object'
  16227. && typeof arg.copy === 'function'
  16228. && typeof arg.fill === 'function'
  16229. && typeof arg.readUInt8 === 'function';
  16230. }
  16231. },{}],196:[function(require,module,exports){
  16232. (function (process,global){
  16233. // Copyright Joyent, Inc. and other Node contributors.
  16234. //
  16235. // Permission is hereby granted, free of charge, to any person obtaining a
  16236. // copy of this software and associated documentation files (the
  16237. // "Software"), to deal in the Software without restriction, including
  16238. // without limitation the rights to use, copy, modify, merge, publish,
  16239. // distribute, sublicense, and/or sell copies of the Software, and to permit
  16240. // persons to whom the Software is furnished to do so, subject to the
  16241. // following conditions:
  16242. //
  16243. // The above copyright notice and this permission notice shall be included
  16244. // in all copies or substantial portions of the Software.
  16245. //
  16246. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  16247. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16248. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  16249. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  16250. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16251. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  16252. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  16253. var formatRegExp = /%[sdj%]/g;
  16254. exports.format = function(f) {
  16255. if (!isString(f)) {
  16256. var objects = [];
  16257. for (var i = 0; i < arguments.length; i++) {
  16258. objects.push(inspect(arguments[i]));
  16259. }
  16260. return objects.join(' ');
  16261. }
  16262. var i = 1;
  16263. var args = arguments;
  16264. var len = args.length;
  16265. var str = String(f).replace(formatRegExp, function(x) {
  16266. if (x === '%%') return '%';
  16267. if (i >= len) return x;
  16268. switch (x) {
  16269. case '%s': return String(args[i++]);
  16270. case '%d': return Number(args[i++]);
  16271. case '%j':
  16272. try {
  16273. return JSON.stringify(args[i++]);
  16274. } catch (_) {
  16275. return '[Circular]';
  16276. }
  16277. default:
  16278. return x;
  16279. }
  16280. });
  16281. for (var x = args[i]; i < len; x = args[++i]) {
  16282. if (isNull(x) || !isObject(x)) {
  16283. str += ' ' + x;
  16284. } else {
  16285. str += ' ' + inspect(x);
  16286. }
  16287. }
  16288. return str;
  16289. };
  16290. // Mark that a method should not be used.
  16291. // Returns a modified function which warns once by default.
  16292. // If --no-deprecation is set, then it is a no-op.
  16293. exports.deprecate = function(fn, msg) {
  16294. // Allow for deprecating things in the process of starting up.
  16295. if (isUndefined(global.process)) {
  16296. return function() {
  16297. return exports.deprecate(fn, msg).apply(this, arguments);
  16298. };
  16299. }
  16300. if (process.noDeprecation === true) {
  16301. return fn;
  16302. }
  16303. var warned = false;
  16304. function deprecated() {
  16305. if (!warned) {
  16306. if (process.throwDeprecation) {
  16307. throw new Error(msg);
  16308. } else if (process.traceDeprecation) {
  16309. console.trace(msg);
  16310. } else {
  16311. console.error(msg);
  16312. }
  16313. warned = true;
  16314. }
  16315. return fn.apply(this, arguments);
  16316. }
  16317. return deprecated;
  16318. };
  16319. var debugs = {};
  16320. var debugEnviron;
  16321. exports.debuglog = function(set) {
  16322. if (isUndefined(debugEnviron))
  16323. debugEnviron = process.env.NODE_DEBUG || '';
  16324. set = set.toUpperCase();
  16325. if (!debugs[set]) {
  16326. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  16327. var pid = process.pid;
  16328. debugs[set] = function() {
  16329. var msg = exports.format.apply(exports, arguments);
  16330. console.error('%s %d: %s', set, pid, msg);
  16331. };
  16332. } else {
  16333. debugs[set] = function() {};
  16334. }
  16335. }
  16336. return debugs[set];
  16337. };
  16338. /**
  16339. * Echos the value of a value. Trys to print the value out
  16340. * in the best way possible given the different types.
  16341. *
  16342. * @param {Object} obj The object to print out.
  16343. * @param {Object} opts Optional options object that alters the output.
  16344. */
  16345. /* legacy: obj, showHidden, depth, colors*/
  16346. function inspect(obj, opts) {
  16347. // default options
  16348. var ctx = {
  16349. seen: [],
  16350. stylize: stylizeNoColor
  16351. };
  16352. // legacy...
  16353. if (arguments.length >= 3) ctx.depth = arguments[2];
  16354. if (arguments.length >= 4) ctx.colors = arguments[3];
  16355. if (isBoolean(opts)) {
  16356. // legacy...
  16357. ctx.showHidden = opts;
  16358. } else if (opts) {
  16359. // got an "options" object
  16360. exports._extend(ctx, opts);
  16361. }
  16362. // set default options
  16363. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  16364. if (isUndefined(ctx.depth)) ctx.depth = 2;
  16365. if (isUndefined(ctx.colors)) ctx.colors = false;
  16366. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  16367. if (ctx.colors) ctx.stylize = stylizeWithColor;
  16368. return formatValue(ctx, obj, ctx.depth);
  16369. }
  16370. exports.inspect = inspect;
  16371. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  16372. inspect.colors = {
  16373. 'bold' : [1, 22],
  16374. 'italic' : [3, 23],
  16375. 'underline' : [4, 24],
  16376. 'inverse' : [7, 27],
  16377. 'white' : [37, 39],
  16378. 'grey' : [90, 39],
  16379. 'black' : [30, 39],
  16380. 'blue' : [34, 39],
  16381. 'cyan' : [36, 39],
  16382. 'green' : [32, 39],
  16383. 'magenta' : [35, 39],
  16384. 'red' : [31, 39],
  16385. 'yellow' : [33, 39]
  16386. };
  16387. // Don't use 'blue' not visible on cmd.exe
  16388. inspect.styles = {
  16389. 'special': 'cyan',
  16390. 'number': 'yellow',
  16391. 'boolean': 'yellow',
  16392. 'undefined': 'grey',
  16393. 'null': 'bold',
  16394. 'string': 'green',
  16395. 'date': 'magenta',
  16396. // "name": intentionally not styling
  16397. 'regexp': 'red'
  16398. };
  16399. function stylizeWithColor(str, styleType) {
  16400. var style = inspect.styles[styleType];
  16401. if (style) {
  16402. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  16403. '\u001b[' + inspect.colors[style][1] + 'm';
  16404. } else {
  16405. return str;
  16406. }
  16407. }
  16408. function stylizeNoColor(str, styleType) {
  16409. return str;
  16410. }
  16411. function arrayToHash(array) {
  16412. var hash = {};
  16413. array.forEach(function(val, idx) {
  16414. hash[val] = true;
  16415. });
  16416. return hash;
  16417. }
  16418. function formatValue(ctx, value, recurseTimes) {
  16419. // Provide a hook for user-specified inspect functions.
  16420. // Check that value is an object with an inspect function on it
  16421. if (ctx.customInspect &&
  16422. value &&
  16423. isFunction(value.inspect) &&
  16424. // Filter out the util module, it's inspect function is special
  16425. value.inspect !== exports.inspect &&
  16426. // Also filter out any prototype objects using the circular check.
  16427. !(value.constructor && value.constructor.prototype === value)) {
  16428. var ret = value.inspect(recurseTimes, ctx);
  16429. if (!isString(ret)) {
  16430. ret = formatValue(ctx, ret, recurseTimes);
  16431. }
  16432. return ret;
  16433. }
  16434. // Primitive types cannot have properties
  16435. var primitive = formatPrimitive(ctx, value);
  16436. if (primitive) {
  16437. return primitive;
  16438. }
  16439. // Look up the keys of the object.
  16440. var keys = Object.keys(value);
  16441. var visibleKeys = arrayToHash(keys);
  16442. if (ctx.showHidden) {
  16443. keys = Object.getOwnPropertyNames(value);
  16444. }
  16445. // IE doesn't make error fields non-enumerable
  16446. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  16447. if (isError(value)
  16448. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  16449. return formatError(value);
  16450. }
  16451. // Some type of object without properties can be shortcutted.
  16452. if (keys.length === 0) {
  16453. if (isFunction(value)) {
  16454. var name = value.name ? ': ' + value.name : '';
  16455. return ctx.stylize('[Function' + name + ']', 'special');
  16456. }
  16457. if (isRegExp(value)) {
  16458. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  16459. }
  16460. if (isDate(value)) {
  16461. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  16462. }
  16463. if (isError(value)) {
  16464. return formatError(value);
  16465. }
  16466. }
  16467. var base = '', array = false, braces = ['{', '}'];
  16468. // Make Array say that they are Array
  16469. if (isArray(value)) {
  16470. array = true;
  16471. braces = ['[', ']'];
  16472. }
  16473. // Make functions say that they are functions
  16474. if (isFunction(value)) {
  16475. var n = value.name ? ': ' + value.name : '';
  16476. base = ' [Function' + n + ']';
  16477. }
  16478. // Make RegExps say that they are RegExps
  16479. if (isRegExp(value)) {
  16480. base = ' ' + RegExp.prototype.toString.call(value);
  16481. }
  16482. // Make dates with properties first say the date
  16483. if (isDate(value)) {
  16484. base = ' ' + Date.prototype.toUTCString.call(value);
  16485. }
  16486. // Make error with message first say the error
  16487. if (isError(value)) {
  16488. base = ' ' + formatError(value);
  16489. }
  16490. if (keys.length === 0 && (!array || value.length == 0)) {
  16491. return braces[0] + base + braces[1];
  16492. }
  16493. if (recurseTimes < 0) {
  16494. if (isRegExp(value)) {
  16495. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  16496. } else {
  16497. return ctx.stylize('[Object]', 'special');
  16498. }
  16499. }
  16500. ctx.seen.push(value);
  16501. var output;
  16502. if (array) {
  16503. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  16504. } else {
  16505. output = keys.map(function(key) {
  16506. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  16507. });
  16508. }
  16509. ctx.seen.pop();
  16510. return reduceToSingleString(output, base, braces);
  16511. }
  16512. function formatPrimitive(ctx, value) {
  16513. if (isUndefined(value))
  16514. return ctx.stylize('undefined', 'undefined');
  16515. if (isString(value)) {
  16516. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  16517. .replace(/'/g, "\\'")
  16518. .replace(/\\"/g, '"') + '\'';
  16519. return ctx.stylize(simple, 'string');
  16520. }
  16521. if (isNumber(value))
  16522. return ctx.stylize('' + value, 'number');
  16523. if (isBoolean(value))
  16524. return ctx.stylize('' + value, 'boolean');
  16525. // For some reason typeof null is "object", so special case here.
  16526. if (isNull(value))
  16527. return ctx.stylize('null', 'null');
  16528. }
  16529. function formatError(value) {
  16530. return '[' + Error.prototype.toString.call(value) + ']';
  16531. }
  16532. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  16533. var output = [];
  16534. for (var i = 0, l = value.length; i < l; ++i) {
  16535. if (hasOwnProperty(value, String(i))) {
  16536. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  16537. String(i), true));
  16538. } else {
  16539. output.push('');
  16540. }
  16541. }
  16542. keys.forEach(function(key) {
  16543. if (!key.match(/^\d+$/)) {
  16544. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  16545. key, true));
  16546. }
  16547. });
  16548. return output;
  16549. }
  16550. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  16551. var name, str, desc;
  16552. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  16553. if (desc.get) {
  16554. if (desc.set) {
  16555. str = ctx.stylize('[Getter/Setter]', 'special');
  16556. } else {
  16557. str = ctx.stylize('[Getter]', 'special');
  16558. }
  16559. } else {
  16560. if (desc.set) {
  16561. str = ctx.stylize('[Setter]', 'special');
  16562. }
  16563. }
  16564. if (!hasOwnProperty(visibleKeys, key)) {
  16565. name = '[' + key + ']';
  16566. }
  16567. if (!str) {
  16568. if (ctx.seen.indexOf(desc.value) < 0) {
  16569. if (isNull(recurseTimes)) {
  16570. str = formatValue(ctx, desc.value, null);
  16571. } else {
  16572. str = formatValue(ctx, desc.value, recurseTimes - 1);
  16573. }
  16574. if (str.indexOf('\n') > -1) {
  16575. if (array) {
  16576. str = str.split('\n').map(function(line) {
  16577. return ' ' + line;
  16578. }).join('\n').substr(2);
  16579. } else {
  16580. str = '\n' + str.split('\n').map(function(line) {
  16581. return ' ' + line;
  16582. }).join('\n');
  16583. }
  16584. }
  16585. } else {
  16586. str = ctx.stylize('[Circular]', 'special');
  16587. }
  16588. }
  16589. if (isUndefined(name)) {
  16590. if (array && key.match(/^\d+$/)) {
  16591. return str;
  16592. }
  16593. name = JSON.stringify('' + key);
  16594. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  16595. name = name.substr(1, name.length - 2);
  16596. name = ctx.stylize(name, 'name');
  16597. } else {
  16598. name = name.replace(/'/g, "\\'")
  16599. .replace(/\\"/g, '"')
  16600. .replace(/(^"|"$)/g, "'");
  16601. name = ctx.stylize(name, 'string');
  16602. }
  16603. }
  16604. return name + ': ' + str;
  16605. }
  16606. function reduceToSingleString(output, base, braces) {
  16607. var numLinesEst = 0;
  16608. var length = output.reduce(function(prev, cur) {
  16609. numLinesEst++;
  16610. if (cur.indexOf('\n') >= 0) numLinesEst++;
  16611. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  16612. }, 0);
  16613. if (length > 60) {
  16614. return braces[0] +
  16615. (base === '' ? '' : base + '\n ') +
  16616. ' ' +
  16617. output.join(',\n ') +
  16618. ' ' +
  16619. braces[1];
  16620. }
  16621. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  16622. }
  16623. // NOTE: These type checking functions intentionally don't use `instanceof`
  16624. // because it is fragile and can be easily faked with `Object.create()`.
  16625. function isArray(ar) {
  16626. return Array.isArray(ar);
  16627. }
  16628. exports.isArray = isArray;
  16629. function isBoolean(arg) {
  16630. return typeof arg === 'boolean';
  16631. }
  16632. exports.isBoolean = isBoolean;
  16633. function isNull(arg) {
  16634. return arg === null;
  16635. }
  16636. exports.isNull = isNull;
  16637. function isNullOrUndefined(arg) {
  16638. return arg == null;
  16639. }
  16640. exports.isNullOrUndefined = isNullOrUndefined;
  16641. function isNumber(arg) {
  16642. return typeof arg === 'number';
  16643. }
  16644. exports.isNumber = isNumber;
  16645. function isString(arg) {
  16646. return typeof arg === 'string';
  16647. }
  16648. exports.isString = isString;
  16649. function isSymbol(arg) {
  16650. return typeof arg === 'symbol';
  16651. }
  16652. exports.isSymbol = isSymbol;
  16653. function isUndefined(arg) {
  16654. return arg === void 0;
  16655. }
  16656. exports.isUndefined = isUndefined;
  16657. function isRegExp(re) {
  16658. return isObject(re) && objectToString(re) === '[object RegExp]';
  16659. }
  16660. exports.isRegExp = isRegExp;
  16661. function isObject(arg) {
  16662. return typeof arg === 'object' && arg !== null;
  16663. }
  16664. exports.isObject = isObject;
  16665. function isDate(d) {
  16666. return isObject(d) && objectToString(d) === '[object Date]';
  16667. }
  16668. exports.isDate = isDate;
  16669. function isError(e) {
  16670. return isObject(e) &&
  16671. (objectToString(e) === '[object Error]' || e instanceof Error);
  16672. }
  16673. exports.isError = isError;
  16674. function isFunction(arg) {
  16675. return typeof arg === 'function';
  16676. }
  16677. exports.isFunction = isFunction;
  16678. function isPrimitive(arg) {
  16679. return arg === null ||
  16680. typeof arg === 'boolean' ||
  16681. typeof arg === 'number' ||
  16682. typeof arg === 'string' ||
  16683. typeof arg === 'symbol' || // ES6 symbol
  16684. typeof arg === 'undefined';
  16685. }
  16686. exports.isPrimitive = isPrimitive;
  16687. exports.isBuffer = require('./support/isBuffer');
  16688. function objectToString(o) {
  16689. return Object.prototype.toString.call(o);
  16690. }
  16691. function pad(n) {
  16692. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  16693. }
  16694. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  16695. 'Oct', 'Nov', 'Dec'];
  16696. // 26 Feb 16:19:34
  16697. function timestamp() {
  16698. var d = new Date();
  16699. var time = [pad(d.getHours()),
  16700. pad(d.getMinutes()),
  16701. pad(d.getSeconds())].join(':');
  16702. return [d.getDate(), months[d.getMonth()], time].join(' ');
  16703. }
  16704. // log is just a thin wrapper to console.log that prepends a timestamp
  16705. exports.log = function() {
  16706. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  16707. };
  16708. /**
  16709. * Inherit the prototype methods from one constructor into another.
  16710. *
  16711. * The Function.prototype.inherits from lang.js rewritten as a standalone
  16712. * function (not on Function.prototype). NOTE: If this file is to be loaded
  16713. * during bootstrapping this function needs to be rewritten using some native
  16714. * functions as prototype setup using normal JavaScript does not work as
  16715. * expected during bootstrapping (see mirror.js in r114903).
  16716. *
  16717. * @param {function} ctor Constructor function which needs to inherit the
  16718. * prototype.
  16719. * @param {function} superCtor Constructor function to inherit prototype from.
  16720. */
  16721. exports.inherits = require('inherits');
  16722. exports._extend = function(origin, add) {
  16723. // Don't do anything if add isn't an object
  16724. if (!add || !isObject(add)) return origin;
  16725. var keys = Object.keys(add);
  16726. var i = keys.length;
  16727. while (i--) {
  16728. origin[keys[i]] = add[keys[i]];
  16729. }
  16730. return origin;
  16731. };
  16732. function hasOwnProperty(obj, prop) {
  16733. return Object.prototype.hasOwnProperty.call(obj, prop);
  16734. }
  16735. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  16736. },{"./support/isBuffer":195,"_process":159,"inherits":194}],197:[function(require,module,exports){
  16737. "use strict";
  16738. // Generated by CoffeeScript 1.12.7
  16739. (function () {
  16740. "use strict";
  16741. exports.stripBOM = function (str) {
  16742. if (str[0] === "\uFEFF") {
  16743. return str.substring(1);
  16744. } else {
  16745. return str;
  16746. }
  16747. };
  16748. }).call(undefined);
  16749. },{}],198:[function(require,module,exports){
  16750. 'use strict';
  16751. var _typeof2 = require('babel-runtime/helpers/typeof');
  16752. var _typeof3 = _interopRequireDefault(_typeof2);
  16753. var _keys = require('babel-runtime/core-js/object/keys');
  16754. var _keys2 = _interopRequireDefault(_keys);
  16755. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16756. // Generated by CoffeeScript 1.12.7
  16757. (function () {
  16758. "use strict";
  16759. var builder,
  16760. defaults,
  16761. escapeCDATA,
  16762. requiresCDATA,
  16763. wrapCDATA,
  16764. hasProp = {}.hasOwnProperty;
  16765. builder = require('xmlbuilder');
  16766. defaults = require('./defaults').defaults;
  16767. requiresCDATA = function requiresCDATA(entry) {
  16768. return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
  16769. };
  16770. wrapCDATA = function wrapCDATA(entry) {
  16771. return "<![CDATA[" + escapeCDATA(entry) + "]]>";
  16772. };
  16773. escapeCDATA = function escapeCDATA(entry) {
  16774. return entry.replace(']]>', ']]]]><![CDATA[>');
  16775. };
  16776. exports.Builder = function () {
  16777. function Builder(opts) {
  16778. var key, ref, value;
  16779. this.options = {};
  16780. ref = defaults["0.2"];
  16781. for (key in ref) {
  16782. if (!hasProp.call(ref, key)) continue;
  16783. value = ref[key];
  16784. this.options[key] = value;
  16785. }
  16786. for (key in opts) {
  16787. if (!hasProp.call(opts, key)) continue;
  16788. value = opts[key];
  16789. this.options[key] = value;
  16790. }
  16791. }
  16792. Builder.prototype.buildObject = function (rootObj) {
  16793. var attrkey, charkey, render, rootElement, rootName;
  16794. attrkey = this.options.attrkey;
  16795. charkey = this.options.charkey;
  16796. if ((0, _keys2.default)(rootObj).length === 1 && this.options.rootName === defaults['0.2'].rootName) {
  16797. rootName = (0, _keys2.default)(rootObj)[0];
  16798. rootObj = rootObj[rootName];
  16799. } else {
  16800. rootName = this.options.rootName;
  16801. }
  16802. render = function (_this) {
  16803. return function (element, obj) {
  16804. var attr, child, entry, index, key, value;
  16805. if ((typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) !== 'object') {
  16806. if (_this.options.cdata && requiresCDATA(obj)) {
  16807. element.raw(wrapCDATA(obj));
  16808. } else {
  16809. element.txt(obj);
  16810. }
  16811. } else if (Array.isArray(obj)) {
  16812. for (index in obj) {
  16813. if (!hasProp.call(obj, index)) continue;
  16814. child = obj[index];
  16815. for (key in child) {
  16816. entry = child[key];
  16817. element = render(element.ele(key), entry).up();
  16818. }
  16819. }
  16820. } else {
  16821. for (key in obj) {
  16822. if (!hasProp.call(obj, key)) continue;
  16823. child = obj[key];
  16824. if (key === attrkey) {
  16825. if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
  16826. for (attr in child) {
  16827. value = child[attr];
  16828. element = element.att(attr, value);
  16829. }
  16830. }
  16831. } else if (key === charkey) {
  16832. if (_this.options.cdata && requiresCDATA(child)) {
  16833. element = element.raw(wrapCDATA(child));
  16834. } else {
  16835. element = element.txt(child);
  16836. }
  16837. } else if (Array.isArray(child)) {
  16838. for (index in child) {
  16839. if (!hasProp.call(child, index)) continue;
  16840. entry = child[index];
  16841. if (typeof entry === 'string') {
  16842. if (_this.options.cdata && requiresCDATA(entry)) {
  16843. element = element.ele(key).raw(wrapCDATA(entry)).up();
  16844. } else {
  16845. element = element.ele(key, entry).up();
  16846. }
  16847. } else {
  16848. element = render(element.ele(key), entry).up();
  16849. }
  16850. }
  16851. } else if ((typeof child === 'undefined' ? 'undefined' : (0, _typeof3.default)(child)) === "object") {
  16852. element = render(element.ele(key), child).up();
  16853. } else {
  16854. if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
  16855. element = element.ele(key).raw(wrapCDATA(child)).up();
  16856. } else {
  16857. if (child == null) {
  16858. child = '';
  16859. }
  16860. element = element.ele(key, child.toString()).up();
  16861. }
  16862. }
  16863. }
  16864. }
  16865. return element;
  16866. };
  16867. }(this);
  16868. rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
  16869. headless: this.options.headless,
  16870. allowSurrogateChars: this.options.allowSurrogateChars
  16871. });
  16872. return render(rootElement, rootObj).end(this.options.renderOpts);
  16873. };
  16874. return Builder;
  16875. }();
  16876. }).call(undefined);
  16877. },{"./defaults":199,"babel-runtime/core-js/object/keys":18,"babel-runtime/helpers/typeof":26,"xmlbuilder":224}],199:[function(require,module,exports){
  16878. "use strict";
  16879. // Generated by CoffeeScript 1.12.7
  16880. (function () {
  16881. exports.defaults = {
  16882. "0.1": {
  16883. explicitCharkey: false,
  16884. trim: true,
  16885. normalize: true,
  16886. normalizeTags: false,
  16887. attrkey: "@",
  16888. charkey: "#",
  16889. explicitArray: false,
  16890. ignoreAttrs: false,
  16891. mergeAttrs: false,
  16892. explicitRoot: false,
  16893. validator: null,
  16894. xmlns: false,
  16895. explicitChildren: false,
  16896. childkey: '@@',
  16897. charsAsChildren: false,
  16898. includeWhiteChars: false,
  16899. async: false,
  16900. strict: true,
  16901. attrNameProcessors: null,
  16902. attrValueProcessors: null,
  16903. tagNameProcessors: null,
  16904. valueProcessors: null,
  16905. emptyTag: ''
  16906. },
  16907. "0.2": {
  16908. explicitCharkey: false,
  16909. trim: false,
  16910. normalize: false,
  16911. normalizeTags: false,
  16912. attrkey: "$",
  16913. charkey: "_",
  16914. explicitArray: true,
  16915. ignoreAttrs: false,
  16916. mergeAttrs: false,
  16917. explicitRoot: true,
  16918. validator: null,
  16919. xmlns: false,
  16920. explicitChildren: false,
  16921. preserveChildrenOrder: false,
  16922. childkey: '$$',
  16923. charsAsChildren: false,
  16924. includeWhiteChars: false,
  16925. async: false,
  16926. strict: true,
  16927. attrNameProcessors: null,
  16928. attrValueProcessors: null,
  16929. tagNameProcessors: null,
  16930. valueProcessors: null,
  16931. rootName: 'root',
  16932. xmldec: {
  16933. 'version': '1.0',
  16934. 'encoding': 'UTF-8',
  16935. 'standalone': true
  16936. },
  16937. doctype: null,
  16938. renderOpts: {
  16939. 'pretty': true,
  16940. 'indent': ' ',
  16941. 'newline': '\n'
  16942. },
  16943. headless: false,
  16944. chunkSize: 10000,
  16945. emptyTag: '',
  16946. cdata: false
  16947. }
  16948. };
  16949. }).call(undefined);
  16950. },{}],200:[function(require,module,exports){
  16951. 'use strict';
  16952. var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
  16953. var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
  16954. var _keys = require('babel-runtime/core-js/object/keys');
  16955. var _keys2 = _interopRequireDefault(_keys);
  16956. var _typeof2 = require('babel-runtime/helpers/typeof');
  16957. var _typeof3 = _interopRequireDefault(_typeof2);
  16958. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16959. // Generated by CoffeeScript 1.12.7
  16960. (function () {
  16961. "use strict";
  16962. var bom,
  16963. defaults,
  16964. events,
  16965. isEmpty,
  16966. processItem,
  16967. processors,
  16968. sax,
  16969. setImmediate,
  16970. bind = function bind(fn, me) {
  16971. return function () {
  16972. return fn.apply(me, arguments);
  16973. };
  16974. },
  16975. extend = function extend(child, parent) {
  16976. for (var key in parent) {
  16977. if (hasProp.call(parent, key)) child[key] = parent[key];
  16978. }function ctor() {
  16979. this.constructor = child;
  16980. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  16981. },
  16982. hasProp = {}.hasOwnProperty;
  16983. sax = require('sax');
  16984. events = require('events');
  16985. bom = require('./bom');
  16986. processors = require('./processors');
  16987. setImmediate = require('timers').setImmediate;
  16988. defaults = require('./defaults').defaults;
  16989. isEmpty = function isEmpty(thing) {
  16990. return (typeof thing === 'undefined' ? 'undefined' : (0, _typeof3.default)(thing)) === "object" && thing != null && (0, _keys2.default)(thing).length === 0;
  16991. };
  16992. processItem = function processItem(processors, item, key) {
  16993. var i, len, process;
  16994. for (i = 0, len = processors.length; i < len; i++) {
  16995. process = processors[i];
  16996. item = process(item, key);
  16997. }
  16998. return item;
  16999. };
  17000. exports.Parser = function (superClass) {
  17001. extend(Parser, superClass);
  17002. function Parser(opts) {
  17003. this.parseString = bind(this.parseString, this);
  17004. this.reset = bind(this.reset, this);
  17005. this.assignOrPush = bind(this.assignOrPush, this);
  17006. this.processAsync = bind(this.processAsync, this);
  17007. var key, ref, value;
  17008. if (!(this instanceof exports.Parser)) {
  17009. return new exports.Parser(opts);
  17010. }
  17011. this.options = {};
  17012. ref = defaults["0.2"];
  17013. for (key in ref) {
  17014. if (!hasProp.call(ref, key)) continue;
  17015. value = ref[key];
  17016. this.options[key] = value;
  17017. }
  17018. for (key in opts) {
  17019. if (!hasProp.call(opts, key)) continue;
  17020. value = opts[key];
  17021. this.options[key] = value;
  17022. }
  17023. if (this.options.xmlns) {
  17024. this.options.xmlnskey = this.options.attrkey + "ns";
  17025. }
  17026. if (this.options.normalizeTags) {
  17027. if (!this.options.tagNameProcessors) {
  17028. this.options.tagNameProcessors = [];
  17029. }
  17030. this.options.tagNameProcessors.unshift(processors.normalize);
  17031. }
  17032. this.reset();
  17033. }
  17034. Parser.prototype.processAsync = function () {
  17035. var chunk, err;
  17036. try {
  17037. if (this.remaining.length <= this.options.chunkSize) {
  17038. chunk = this.remaining;
  17039. this.remaining = '';
  17040. this.saxParser = this.saxParser.write(chunk);
  17041. return this.saxParser.close();
  17042. } else {
  17043. chunk = this.remaining.substr(0, this.options.chunkSize);
  17044. this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
  17045. this.saxParser = this.saxParser.write(chunk);
  17046. return setImmediate(this.processAsync);
  17047. }
  17048. } catch (error1) {
  17049. err = error1;
  17050. if (!this.saxParser.errThrown) {
  17051. this.saxParser.errThrown = true;
  17052. return this.emit(err);
  17053. }
  17054. }
  17055. };
  17056. Parser.prototype.assignOrPush = function (obj, key, newValue) {
  17057. if (!(key in obj)) {
  17058. if (!this.options.explicitArray) {
  17059. return obj[key] = newValue;
  17060. } else {
  17061. return obj[key] = [newValue];
  17062. }
  17063. } else {
  17064. if (!(obj[key] instanceof Array)) {
  17065. obj[key] = [obj[key]];
  17066. }
  17067. return obj[key].push(newValue);
  17068. }
  17069. };
  17070. Parser.prototype.reset = function () {
  17071. var attrkey, charkey, ontext, stack;
  17072. this.removeAllListeners();
  17073. this.saxParser = sax.parser(this.options.strict, {
  17074. trim: false,
  17075. normalize: false,
  17076. xmlns: this.options.xmlns
  17077. });
  17078. this.saxParser.errThrown = false;
  17079. this.saxParser.onerror = function (_this) {
  17080. return function (error) {
  17081. _this.saxParser.resume();
  17082. if (!_this.saxParser.errThrown) {
  17083. _this.saxParser.errThrown = true;
  17084. return _this.emit("error", error);
  17085. }
  17086. };
  17087. }(this);
  17088. this.saxParser.onend = function (_this) {
  17089. return function () {
  17090. if (!_this.saxParser.ended) {
  17091. _this.saxParser.ended = true;
  17092. return _this.emit("end", _this.resultObject);
  17093. }
  17094. };
  17095. }(this);
  17096. this.saxParser.ended = false;
  17097. this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
  17098. this.resultObject = null;
  17099. stack = [];
  17100. attrkey = this.options.attrkey;
  17101. charkey = this.options.charkey;
  17102. this.saxParser.onopentag = function (_this) {
  17103. return function (node) {
  17104. var key, newValue, obj, processedKey, ref;
  17105. obj = {};
  17106. obj[charkey] = "";
  17107. if (!_this.options.ignoreAttrs) {
  17108. ref = node.attributes;
  17109. for (key in ref) {
  17110. if (!hasProp.call(ref, key)) continue;
  17111. if (!(attrkey in obj) && !_this.options.mergeAttrs) {
  17112. obj[attrkey] = {};
  17113. }
  17114. newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
  17115. processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
  17116. if (_this.options.mergeAttrs) {
  17117. _this.assignOrPush(obj, processedKey, newValue);
  17118. } else {
  17119. obj[attrkey][processedKey] = newValue;
  17120. }
  17121. }
  17122. }
  17123. obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
  17124. if (_this.options.xmlns) {
  17125. obj[_this.options.xmlnskey] = {
  17126. uri: node.uri,
  17127. local: node.local
  17128. };
  17129. }
  17130. return stack.push(obj);
  17131. };
  17132. }(this);
  17133. this.saxParser.onclosetag = function (_this) {
  17134. return function () {
  17135. var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
  17136. obj = stack.pop();
  17137. nodeName = obj["#name"];
  17138. if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
  17139. delete obj["#name"];
  17140. }
  17141. if (obj.cdata === true) {
  17142. cdata = obj.cdata;
  17143. delete obj.cdata;
  17144. }
  17145. s = stack[stack.length - 1];
  17146. if (obj[charkey].match(/^\s*$/) && !cdata) {
  17147. emptyStr = obj[charkey];
  17148. delete obj[charkey];
  17149. } else {
  17150. if (_this.options.trim) {
  17151. obj[charkey] = obj[charkey].trim();
  17152. }
  17153. if (_this.options.normalize) {
  17154. obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
  17155. }
  17156. obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
  17157. if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  17158. obj = obj[charkey];
  17159. }
  17160. }
  17161. if (isEmpty(obj)) {
  17162. obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
  17163. }
  17164. if (_this.options.validator != null) {
  17165. xpath = "/" + function () {
  17166. var i, len, results;
  17167. results = [];
  17168. for (i = 0, len = stack.length; i < len; i++) {
  17169. node = stack[i];
  17170. results.push(node["#name"]);
  17171. }
  17172. return results;
  17173. }().concat(nodeName).join("/");
  17174. (function () {
  17175. var err;
  17176. try {
  17177. return obj = _this.options.validator(xpath, s && s[nodeName], obj);
  17178. } catch (error1) {
  17179. err = error1;
  17180. return _this.emit("error", err);
  17181. }
  17182. })();
  17183. }
  17184. if (_this.options.explicitChildren && !_this.options.mergeAttrs && (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) === 'object') {
  17185. if (!_this.options.preserveChildrenOrder) {
  17186. node = {};
  17187. if (_this.options.attrkey in obj) {
  17188. node[_this.options.attrkey] = obj[_this.options.attrkey];
  17189. delete obj[_this.options.attrkey];
  17190. }
  17191. if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
  17192. node[_this.options.charkey] = obj[_this.options.charkey];
  17193. delete obj[_this.options.charkey];
  17194. }
  17195. if ((0, _getOwnPropertyNames2.default)(obj).length > 0) {
  17196. node[_this.options.childkey] = obj;
  17197. }
  17198. obj = node;
  17199. } else if (s) {
  17200. s[_this.options.childkey] = s[_this.options.childkey] || [];
  17201. objClone = {};
  17202. for (key in obj) {
  17203. if (!hasProp.call(obj, key)) continue;
  17204. objClone[key] = obj[key];
  17205. }
  17206. s[_this.options.childkey].push(objClone);
  17207. delete obj["#name"];
  17208. if ((0, _keys2.default)(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  17209. obj = obj[charkey];
  17210. }
  17211. }
  17212. }
  17213. if (stack.length > 0) {
  17214. return _this.assignOrPush(s, nodeName, obj);
  17215. } else {
  17216. if (_this.options.explicitRoot) {
  17217. old = obj;
  17218. obj = {};
  17219. obj[nodeName] = old;
  17220. }
  17221. _this.resultObject = obj;
  17222. _this.saxParser.ended = true;
  17223. return _this.emit("end", _this.resultObject);
  17224. }
  17225. };
  17226. }(this);
  17227. ontext = function (_this) {
  17228. return function (text) {
  17229. var charChild, s;
  17230. s = stack[stack.length - 1];
  17231. if (s) {
  17232. s[charkey] += text;
  17233. if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
  17234. s[_this.options.childkey] = s[_this.options.childkey] || [];
  17235. charChild = {
  17236. '#name': '__text__'
  17237. };
  17238. charChild[charkey] = text;
  17239. if (_this.options.normalize) {
  17240. charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
  17241. }
  17242. s[_this.options.childkey].push(charChild);
  17243. }
  17244. return s;
  17245. }
  17246. };
  17247. }(this);
  17248. this.saxParser.ontext = ontext;
  17249. return this.saxParser.oncdata = function (_this) {
  17250. return function (text) {
  17251. var s;
  17252. s = ontext(text);
  17253. if (s) {
  17254. return s.cdata = true;
  17255. }
  17256. };
  17257. }(this);
  17258. };
  17259. Parser.prototype.parseString = function (str, cb) {
  17260. var err;
  17261. if (cb != null && typeof cb === "function") {
  17262. this.on("end", function (result) {
  17263. this.reset();
  17264. return cb(null, result);
  17265. });
  17266. this.on("error", function (err) {
  17267. this.reset();
  17268. return cb(err);
  17269. });
  17270. }
  17271. try {
  17272. str = str.toString();
  17273. if (str.trim() === '') {
  17274. this.emit("end", null);
  17275. return true;
  17276. }
  17277. str = bom.stripBOM(str);
  17278. if (this.options.async) {
  17279. this.remaining = str;
  17280. setImmediate(this.processAsync);
  17281. return this.saxParser;
  17282. }
  17283. return this.saxParser.write(str).close();
  17284. } catch (error1) {
  17285. err = error1;
  17286. if (!(this.saxParser.errThrown || this.saxParser.ended)) {
  17287. this.emit('error', err);
  17288. return this.saxParser.errThrown = true;
  17289. } else if (this.saxParser.ended) {
  17290. throw err;
  17291. }
  17292. }
  17293. };
  17294. return Parser;
  17295. }(events.EventEmitter);
  17296. exports.parseString = function (str, a, b) {
  17297. var cb, options, parser;
  17298. if (b != null) {
  17299. if (typeof b === 'function') {
  17300. cb = b;
  17301. }
  17302. if ((typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) === 'object') {
  17303. options = a;
  17304. }
  17305. } else {
  17306. if (typeof a === 'function') {
  17307. cb = a;
  17308. }
  17309. options = {};
  17310. }
  17311. parser = new exports.Parser(options);
  17312. return parser.parseString(str, cb);
  17313. };
  17314. }).call(undefined);
  17315. },{"./bom":197,"./defaults":199,"./processors":201,"babel-runtime/core-js/object/get-own-property-names":16,"babel-runtime/core-js/object/keys":18,"babel-runtime/helpers/typeof":26,"events":145,"sax":182,"timers":189}],201:[function(require,module,exports){
  17316. 'use strict';
  17317. // Generated by CoffeeScript 1.12.7
  17318. (function () {
  17319. "use strict";
  17320. var prefixMatch;
  17321. prefixMatch = new RegExp(/(?!xmlns)^.*:/);
  17322. exports.normalize = function (str) {
  17323. return str.toLowerCase();
  17324. };
  17325. exports.firstCharLowerCase = function (str) {
  17326. return str.charAt(0).toLowerCase() + str.slice(1);
  17327. };
  17328. exports.stripPrefix = function (str) {
  17329. return str.replace(prefixMatch, '');
  17330. };
  17331. exports.parseNumbers = function (str) {
  17332. if (!isNaN(str)) {
  17333. str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
  17334. }
  17335. return str;
  17336. };
  17337. exports.parseBooleans = function (str) {
  17338. if (/^(?:true|false)$/i.test(str)) {
  17339. str = str.toLowerCase() === 'true';
  17340. }
  17341. return str;
  17342. };
  17343. }).call(undefined);
  17344. },{}],202:[function(require,module,exports){
  17345. 'use strict';
  17346. // Generated by CoffeeScript 1.12.7
  17347. (function () {
  17348. "use strict";
  17349. var builder,
  17350. defaults,
  17351. parser,
  17352. processors,
  17353. extend = function extend(child, parent) {
  17354. for (var key in parent) {
  17355. if (hasProp.call(parent, key)) child[key] = parent[key];
  17356. }function ctor() {
  17357. this.constructor = child;
  17358. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17359. },
  17360. hasProp = {}.hasOwnProperty;
  17361. defaults = require('./defaults');
  17362. builder = require('./builder');
  17363. parser = require('./parser');
  17364. processors = require('./processors');
  17365. exports.defaults = defaults.defaults;
  17366. exports.processors = processors;
  17367. exports.ValidationError = function (superClass) {
  17368. extend(ValidationError, superClass);
  17369. function ValidationError(message) {
  17370. this.message = message;
  17371. }
  17372. return ValidationError;
  17373. }(Error);
  17374. exports.Builder = builder.Builder;
  17375. exports.Parser = parser.Parser;
  17376. exports.parseString = parser.parseString;
  17377. }).call(undefined);
  17378. },{"./builder":198,"./defaults":199,"./parser":200,"./processors":201}],203:[function(require,module,exports){
  17379. 'use strict';
  17380. var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  17381. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  17382. var _typeof2 = require('babel-runtime/helpers/typeof');
  17383. var _typeof3 = _interopRequireDefault(_typeof2);
  17384. var _assign = require('babel-runtime/core-js/object/assign');
  17385. var _assign2 = _interopRequireDefault(_assign);
  17386. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17387. // Generated by CoffeeScript 1.12.6
  17388. (function () {
  17389. var assign,
  17390. isArray,
  17391. isEmpty,
  17392. isFunction,
  17393. isObject,
  17394. isPlainObject,
  17395. slice = [].slice,
  17396. hasProp = {}.hasOwnProperty;
  17397. assign = function assign() {
  17398. var i, key, len, source, sources, target;
  17399. target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  17400. if (isFunction(_assign2.default)) {
  17401. _assign2.default.apply(null, arguments);
  17402. } else {
  17403. for (i = 0, len = sources.length; i < len; i++) {
  17404. source = sources[i];
  17405. if (source != null) {
  17406. for (key in source) {
  17407. if (!hasProp.call(source, key)) continue;
  17408. target[key] = source[key];
  17409. }
  17410. }
  17411. }
  17412. }
  17413. return target;
  17414. };
  17415. isFunction = function isFunction(val) {
  17416. return !!val && Object.prototype.toString.call(val) === '[object Function]';
  17417. };
  17418. isObject = function isObject(val) {
  17419. var ref;
  17420. return !!val && ((ref = typeof val === 'undefined' ? 'undefined' : (0, _typeof3.default)(val)) === 'function' || ref === 'object');
  17421. };
  17422. isArray = function isArray(val) {
  17423. if (isFunction(Array.isArray)) {
  17424. return Array.isArray(val);
  17425. } else {
  17426. return Object.prototype.toString.call(val) === '[object Array]';
  17427. }
  17428. };
  17429. isEmpty = function isEmpty(val) {
  17430. var key;
  17431. if (isArray(val)) {
  17432. return !val.length;
  17433. } else {
  17434. for (key in val) {
  17435. if (!hasProp.call(val, key)) continue;
  17436. return false;
  17437. }
  17438. return true;
  17439. }
  17440. };
  17441. isPlainObject = function isPlainObject(val) {
  17442. var ctor, proto;
  17443. return isObject(val) && (proto = (0, _getPrototypeOf2.default)(val)) && (ctor = proto.constructor) && typeof ctor === 'function' && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
  17444. };
  17445. module.exports.assign = assign;
  17446. module.exports.isFunction = isFunction;
  17447. module.exports.isObject = isObject;
  17448. module.exports.isArray = isArray;
  17449. module.exports.isEmpty = isEmpty;
  17450. module.exports.isPlainObject = isPlainObject;
  17451. }).call(undefined);
  17452. },{"babel-runtime/core-js/object/assign":13,"babel-runtime/core-js/object/get-prototype-of":17,"babel-runtime/helpers/typeof":26}],204:[function(require,module,exports){
  17453. "use strict";
  17454. var _create = require("babel-runtime/core-js/object/create");
  17455. var _create2 = _interopRequireDefault(_create);
  17456. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17457. // Generated by CoffeeScript 1.12.6
  17458. (function () {
  17459. var XMLAttribute;
  17460. module.exports = XMLAttribute = function () {
  17461. function XMLAttribute(parent, name, value) {
  17462. this.options = parent.options;
  17463. this.stringify = parent.stringify;
  17464. if (name == null) {
  17465. throw new Error("Missing attribute name of element " + parent.name);
  17466. }
  17467. if (value == null) {
  17468. throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
  17469. }
  17470. this.name = this.stringify.attName(name);
  17471. this.value = this.stringify.attValue(value);
  17472. }
  17473. XMLAttribute.prototype.clone = function () {
  17474. return (0, _create2.default)(this);
  17475. };
  17476. XMLAttribute.prototype.toString = function (options) {
  17477. return this.options.writer.set(options).attribute(this);
  17478. };
  17479. return XMLAttribute;
  17480. }();
  17481. }).call(undefined);
  17482. },{"babel-runtime/core-js/object/create":14}],205:[function(require,module,exports){
  17483. "use strict";
  17484. var _create = require("babel-runtime/core-js/object/create");
  17485. var _create2 = _interopRequireDefault(_create);
  17486. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17487. // Generated by CoffeeScript 1.12.6
  17488. (function () {
  17489. var XMLCData,
  17490. XMLNode,
  17491. extend = function extend(child, parent) {
  17492. for (var key in parent) {
  17493. if (hasProp.call(parent, key)) child[key] = parent[key];
  17494. }function ctor() {
  17495. this.constructor = child;
  17496. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17497. },
  17498. hasProp = {}.hasOwnProperty;
  17499. XMLNode = require('./XMLNode');
  17500. module.exports = XMLCData = function (superClass) {
  17501. extend(XMLCData, superClass);
  17502. function XMLCData(parent, text) {
  17503. XMLCData.__super__.constructor.call(this, parent);
  17504. if (text == null) {
  17505. throw new Error("Missing CDATA text");
  17506. }
  17507. this.text = this.stringify.cdata(text);
  17508. }
  17509. XMLCData.prototype.clone = function () {
  17510. return (0, _create2.default)(this);
  17511. };
  17512. XMLCData.prototype.toString = function (options) {
  17513. return this.options.writer.set(options).cdata(this);
  17514. };
  17515. return XMLCData;
  17516. }(XMLNode);
  17517. }).call(undefined);
  17518. },{"./XMLNode":216,"babel-runtime/core-js/object/create":14}],206:[function(require,module,exports){
  17519. "use strict";
  17520. var _create = require("babel-runtime/core-js/object/create");
  17521. var _create2 = _interopRequireDefault(_create);
  17522. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17523. // Generated by CoffeeScript 1.12.6
  17524. (function () {
  17525. var XMLComment,
  17526. XMLNode,
  17527. extend = function extend(child, parent) {
  17528. for (var key in parent) {
  17529. if (hasProp.call(parent, key)) child[key] = parent[key];
  17530. }function ctor() {
  17531. this.constructor = child;
  17532. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17533. },
  17534. hasProp = {}.hasOwnProperty;
  17535. XMLNode = require('./XMLNode');
  17536. module.exports = XMLComment = function (superClass) {
  17537. extend(XMLComment, superClass);
  17538. function XMLComment(parent, text) {
  17539. XMLComment.__super__.constructor.call(this, parent);
  17540. if (text == null) {
  17541. throw new Error("Missing comment text");
  17542. }
  17543. this.text = this.stringify.comment(text);
  17544. }
  17545. XMLComment.prototype.clone = function () {
  17546. return (0, _create2.default)(this);
  17547. };
  17548. XMLComment.prototype.toString = function (options) {
  17549. return this.options.writer.set(options).comment(this);
  17550. };
  17551. return XMLComment;
  17552. }(XMLNode);
  17553. }).call(undefined);
  17554. },{"./XMLNode":216,"babel-runtime/core-js/object/create":14}],207:[function(require,module,exports){
  17555. "use strict";
  17556. // Generated by CoffeeScript 1.12.6
  17557. (function () {
  17558. var XMLDTDAttList,
  17559. XMLNode,
  17560. extend = function extend(child, parent) {
  17561. for (var key in parent) {
  17562. if (hasProp.call(parent, key)) child[key] = parent[key];
  17563. }function ctor() {
  17564. this.constructor = child;
  17565. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17566. },
  17567. hasProp = {}.hasOwnProperty;
  17568. XMLNode = require('./XMLNode');
  17569. module.exports = XMLDTDAttList = function (superClass) {
  17570. extend(XMLDTDAttList, superClass);
  17571. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  17572. XMLDTDAttList.__super__.constructor.call(this, parent);
  17573. if (elementName == null) {
  17574. throw new Error("Missing DTD element name");
  17575. }
  17576. if (attributeName == null) {
  17577. throw new Error("Missing DTD attribute name");
  17578. }
  17579. if (!attributeType) {
  17580. throw new Error("Missing DTD attribute type");
  17581. }
  17582. if (!defaultValueType) {
  17583. throw new Error("Missing DTD attribute default");
  17584. }
  17585. if (defaultValueType.indexOf('#') !== 0) {
  17586. defaultValueType = '#' + defaultValueType;
  17587. }
  17588. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  17589. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
  17590. }
  17591. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  17592. throw new Error("Default value only applies to #FIXED or #DEFAULT");
  17593. }
  17594. this.elementName = this.stringify.eleName(elementName);
  17595. this.attributeName = this.stringify.attName(attributeName);
  17596. this.attributeType = this.stringify.dtdAttType(attributeType);
  17597. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  17598. this.defaultValueType = defaultValueType;
  17599. }
  17600. XMLDTDAttList.prototype.toString = function (options) {
  17601. return this.options.writer.set(options).dtdAttList(this);
  17602. };
  17603. return XMLDTDAttList;
  17604. }(XMLNode);
  17605. }).call(undefined);
  17606. },{"./XMLNode":216}],208:[function(require,module,exports){
  17607. 'use strict';
  17608. // Generated by CoffeeScript 1.12.6
  17609. (function () {
  17610. var XMLDTDElement,
  17611. XMLNode,
  17612. extend = function extend(child, parent) {
  17613. for (var key in parent) {
  17614. if (hasProp.call(parent, key)) child[key] = parent[key];
  17615. }function ctor() {
  17616. this.constructor = child;
  17617. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17618. },
  17619. hasProp = {}.hasOwnProperty;
  17620. XMLNode = require('./XMLNode');
  17621. module.exports = XMLDTDElement = function (superClass) {
  17622. extend(XMLDTDElement, superClass);
  17623. function XMLDTDElement(parent, name, value) {
  17624. XMLDTDElement.__super__.constructor.call(this, parent);
  17625. if (name == null) {
  17626. throw new Error("Missing DTD element name");
  17627. }
  17628. if (!value) {
  17629. value = '(#PCDATA)';
  17630. }
  17631. if (Array.isArray(value)) {
  17632. value = '(' + value.join(',') + ')';
  17633. }
  17634. this.name = this.stringify.eleName(name);
  17635. this.value = this.stringify.dtdElementValue(value);
  17636. }
  17637. XMLDTDElement.prototype.toString = function (options) {
  17638. return this.options.writer.set(options).dtdElement(this);
  17639. };
  17640. return XMLDTDElement;
  17641. }(XMLNode);
  17642. }).call(undefined);
  17643. },{"./XMLNode":216}],209:[function(require,module,exports){
  17644. 'use strict';
  17645. // Generated by CoffeeScript 1.12.6
  17646. (function () {
  17647. var XMLDTDEntity,
  17648. XMLNode,
  17649. isObject,
  17650. extend = function extend(child, parent) {
  17651. for (var key in parent) {
  17652. if (hasProp.call(parent, key)) child[key] = parent[key];
  17653. }function ctor() {
  17654. this.constructor = child;
  17655. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17656. },
  17657. hasProp = {}.hasOwnProperty;
  17658. isObject = require('./Utility').isObject;
  17659. XMLNode = require('./XMLNode');
  17660. module.exports = XMLDTDEntity = function (superClass) {
  17661. extend(XMLDTDEntity, superClass);
  17662. function XMLDTDEntity(parent, pe, name, value) {
  17663. XMLDTDEntity.__super__.constructor.call(this, parent);
  17664. if (name == null) {
  17665. throw new Error("Missing entity name");
  17666. }
  17667. if (value == null) {
  17668. throw new Error("Missing entity value");
  17669. }
  17670. this.pe = !!pe;
  17671. this.name = this.stringify.eleName(name);
  17672. if (!isObject(value)) {
  17673. this.value = this.stringify.dtdEntityValue(value);
  17674. } else {
  17675. if (!value.pubID && !value.sysID) {
  17676. throw new Error("Public and/or system identifiers are required for an external entity");
  17677. }
  17678. if (value.pubID && !value.sysID) {
  17679. throw new Error("System identifier is required for a public external entity");
  17680. }
  17681. if (value.pubID != null) {
  17682. this.pubID = this.stringify.dtdPubID(value.pubID);
  17683. }
  17684. if (value.sysID != null) {
  17685. this.sysID = this.stringify.dtdSysID(value.sysID);
  17686. }
  17687. if (value.nData != null) {
  17688. this.nData = this.stringify.dtdNData(value.nData);
  17689. }
  17690. if (this.pe && this.nData) {
  17691. throw new Error("Notation declaration is not allowed in a parameter entity");
  17692. }
  17693. }
  17694. }
  17695. XMLDTDEntity.prototype.toString = function (options) {
  17696. return this.options.writer.set(options).dtdEntity(this);
  17697. };
  17698. return XMLDTDEntity;
  17699. }(XMLNode);
  17700. }).call(undefined);
  17701. },{"./Utility":203,"./XMLNode":216}],210:[function(require,module,exports){
  17702. "use strict";
  17703. // Generated by CoffeeScript 1.12.6
  17704. (function () {
  17705. var XMLDTDNotation,
  17706. XMLNode,
  17707. extend = function extend(child, parent) {
  17708. for (var key in parent) {
  17709. if (hasProp.call(parent, key)) child[key] = parent[key];
  17710. }function ctor() {
  17711. this.constructor = child;
  17712. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17713. },
  17714. hasProp = {}.hasOwnProperty;
  17715. XMLNode = require('./XMLNode');
  17716. module.exports = XMLDTDNotation = function (superClass) {
  17717. extend(XMLDTDNotation, superClass);
  17718. function XMLDTDNotation(parent, name, value) {
  17719. XMLDTDNotation.__super__.constructor.call(this, parent);
  17720. if (name == null) {
  17721. throw new Error("Missing notation name");
  17722. }
  17723. if (!value.pubID && !value.sysID) {
  17724. throw new Error("Public or system identifiers are required for an external entity");
  17725. }
  17726. this.name = this.stringify.eleName(name);
  17727. if (value.pubID != null) {
  17728. this.pubID = this.stringify.dtdPubID(value.pubID);
  17729. }
  17730. if (value.sysID != null) {
  17731. this.sysID = this.stringify.dtdSysID(value.sysID);
  17732. }
  17733. }
  17734. XMLDTDNotation.prototype.toString = function (options) {
  17735. return this.options.writer.set(options).dtdNotation(this);
  17736. };
  17737. return XMLDTDNotation;
  17738. }(XMLNode);
  17739. }).call(undefined);
  17740. },{"./XMLNode":216}],211:[function(require,module,exports){
  17741. 'use strict';
  17742. // Generated by CoffeeScript 1.12.6
  17743. (function () {
  17744. var XMLDeclaration,
  17745. XMLNode,
  17746. isObject,
  17747. extend = function extend(child, parent) {
  17748. for (var key in parent) {
  17749. if (hasProp.call(parent, key)) child[key] = parent[key];
  17750. }function ctor() {
  17751. this.constructor = child;
  17752. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17753. },
  17754. hasProp = {}.hasOwnProperty;
  17755. isObject = require('./Utility').isObject;
  17756. XMLNode = require('./XMLNode');
  17757. module.exports = XMLDeclaration = function (superClass) {
  17758. extend(XMLDeclaration, superClass);
  17759. function XMLDeclaration(parent, version, encoding, standalone) {
  17760. var ref;
  17761. XMLDeclaration.__super__.constructor.call(this, parent);
  17762. if (isObject(version)) {
  17763. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  17764. }
  17765. if (!version) {
  17766. version = '1.0';
  17767. }
  17768. this.version = this.stringify.xmlVersion(version);
  17769. if (encoding != null) {
  17770. this.encoding = this.stringify.xmlEncoding(encoding);
  17771. }
  17772. if (standalone != null) {
  17773. this.standalone = this.stringify.xmlStandalone(standalone);
  17774. }
  17775. }
  17776. XMLDeclaration.prototype.toString = function (options) {
  17777. return this.options.writer.set(options).declaration(this);
  17778. };
  17779. return XMLDeclaration;
  17780. }(XMLNode);
  17781. }).call(undefined);
  17782. },{"./Utility":203,"./XMLNode":216}],212:[function(require,module,exports){
  17783. 'use strict';
  17784. // Generated by CoffeeScript 1.12.6
  17785. (function () {
  17786. var XMLDTDAttList,
  17787. XMLDTDElement,
  17788. XMLDTDEntity,
  17789. XMLDTDNotation,
  17790. XMLDocType,
  17791. XMLNode,
  17792. isObject,
  17793. extend = function extend(child, parent) {
  17794. for (var key in parent) {
  17795. if (hasProp.call(parent, key)) child[key] = parent[key];
  17796. }function ctor() {
  17797. this.constructor = child;
  17798. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17799. },
  17800. hasProp = {}.hasOwnProperty;
  17801. isObject = require('./Utility').isObject;
  17802. XMLNode = require('./XMLNode');
  17803. XMLDTDAttList = require('./XMLDTDAttList');
  17804. XMLDTDEntity = require('./XMLDTDEntity');
  17805. XMLDTDElement = require('./XMLDTDElement');
  17806. XMLDTDNotation = require('./XMLDTDNotation');
  17807. module.exports = XMLDocType = function (superClass) {
  17808. extend(XMLDocType, superClass);
  17809. function XMLDocType(parent, pubID, sysID) {
  17810. var ref, ref1;
  17811. XMLDocType.__super__.constructor.call(this, parent);
  17812. this.documentObject = parent;
  17813. if (isObject(pubID)) {
  17814. ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
  17815. }
  17816. if (sysID == null) {
  17817. ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
  17818. }
  17819. if (pubID != null) {
  17820. this.pubID = this.stringify.dtdPubID(pubID);
  17821. }
  17822. if (sysID != null) {
  17823. this.sysID = this.stringify.dtdSysID(sysID);
  17824. }
  17825. }
  17826. XMLDocType.prototype.element = function (name, value) {
  17827. var child;
  17828. child = new XMLDTDElement(this, name, value);
  17829. this.children.push(child);
  17830. return this;
  17831. };
  17832. XMLDocType.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  17833. var child;
  17834. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  17835. this.children.push(child);
  17836. return this;
  17837. };
  17838. XMLDocType.prototype.entity = function (name, value) {
  17839. var child;
  17840. child = new XMLDTDEntity(this, false, name, value);
  17841. this.children.push(child);
  17842. return this;
  17843. };
  17844. XMLDocType.prototype.pEntity = function (name, value) {
  17845. var child;
  17846. child = new XMLDTDEntity(this, true, name, value);
  17847. this.children.push(child);
  17848. return this;
  17849. };
  17850. XMLDocType.prototype.notation = function (name, value) {
  17851. var child;
  17852. child = new XMLDTDNotation(this, name, value);
  17853. this.children.push(child);
  17854. return this;
  17855. };
  17856. XMLDocType.prototype.toString = function (options) {
  17857. return this.options.writer.set(options).docType(this);
  17858. };
  17859. XMLDocType.prototype.ele = function (name, value) {
  17860. return this.element(name, value);
  17861. };
  17862. XMLDocType.prototype.att = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  17863. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  17864. };
  17865. XMLDocType.prototype.ent = function (name, value) {
  17866. return this.entity(name, value);
  17867. };
  17868. XMLDocType.prototype.pent = function (name, value) {
  17869. return this.pEntity(name, value);
  17870. };
  17871. XMLDocType.prototype.not = function (name, value) {
  17872. return this.notation(name, value);
  17873. };
  17874. XMLDocType.prototype.up = function () {
  17875. return this.root() || this.documentObject;
  17876. };
  17877. return XMLDocType;
  17878. }(XMLNode);
  17879. }).call(undefined);
  17880. },{"./Utility":203,"./XMLDTDAttList":207,"./XMLDTDElement":208,"./XMLDTDEntity":209,"./XMLDTDNotation":210,"./XMLNode":216}],213:[function(require,module,exports){
  17881. 'use strict';
  17882. // Generated by CoffeeScript 1.12.6
  17883. (function () {
  17884. var XMLDocument,
  17885. XMLNode,
  17886. XMLStringWriter,
  17887. XMLStringifier,
  17888. isPlainObject,
  17889. extend = function extend(child, parent) {
  17890. for (var key in parent) {
  17891. if (hasProp.call(parent, key)) child[key] = parent[key];
  17892. }function ctor() {
  17893. this.constructor = child;
  17894. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  17895. },
  17896. hasProp = {}.hasOwnProperty;
  17897. isPlainObject = require('./Utility').isPlainObject;
  17898. XMLNode = require('./XMLNode');
  17899. XMLStringifier = require('./XMLStringifier');
  17900. XMLStringWriter = require('./XMLStringWriter');
  17901. module.exports = XMLDocument = function (superClass) {
  17902. extend(XMLDocument, superClass);
  17903. function XMLDocument(options) {
  17904. XMLDocument.__super__.constructor.call(this, null);
  17905. options || (options = {});
  17906. if (!options.writer) {
  17907. options.writer = new XMLStringWriter();
  17908. }
  17909. this.options = options;
  17910. this.stringify = new XMLStringifier(options);
  17911. this.isDocument = true;
  17912. }
  17913. XMLDocument.prototype.end = function (writer) {
  17914. var writerOptions;
  17915. if (!writer) {
  17916. writer = this.options.writer;
  17917. } else if (isPlainObject(writer)) {
  17918. writerOptions = writer;
  17919. writer = this.options.writer.set(writerOptions);
  17920. }
  17921. return writer.document(this);
  17922. };
  17923. XMLDocument.prototype.toString = function (options) {
  17924. return this.options.writer.set(options).document(this);
  17925. };
  17926. return XMLDocument;
  17927. }(XMLNode);
  17928. }).call(undefined);
  17929. },{"./Utility":203,"./XMLNode":216,"./XMLStringWriter":220,"./XMLStringifier":221}],214:[function(require,module,exports){
  17930. 'use strict';
  17931. // Generated by CoffeeScript 1.12.6
  17932. (function () {
  17933. var XMLAttribute,
  17934. XMLCData,
  17935. XMLComment,
  17936. XMLDTDAttList,
  17937. XMLDTDElement,
  17938. XMLDTDEntity,
  17939. XMLDTDNotation,
  17940. XMLDeclaration,
  17941. XMLDocType,
  17942. XMLDocumentCB,
  17943. XMLElement,
  17944. XMLProcessingInstruction,
  17945. XMLRaw,
  17946. XMLStringWriter,
  17947. XMLStringifier,
  17948. XMLText,
  17949. isFunction,
  17950. isObject,
  17951. isPlainObject,
  17952. ref,
  17953. hasProp = {}.hasOwnProperty;
  17954. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
  17955. XMLElement = require('./XMLElement');
  17956. XMLCData = require('./XMLCData');
  17957. XMLComment = require('./XMLComment');
  17958. XMLRaw = require('./XMLRaw');
  17959. XMLText = require('./XMLText');
  17960. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  17961. XMLDeclaration = require('./XMLDeclaration');
  17962. XMLDocType = require('./XMLDocType');
  17963. XMLDTDAttList = require('./XMLDTDAttList');
  17964. XMLDTDEntity = require('./XMLDTDEntity');
  17965. XMLDTDElement = require('./XMLDTDElement');
  17966. XMLDTDNotation = require('./XMLDTDNotation');
  17967. XMLAttribute = require('./XMLAttribute');
  17968. XMLStringifier = require('./XMLStringifier');
  17969. XMLStringWriter = require('./XMLStringWriter');
  17970. module.exports = XMLDocumentCB = function () {
  17971. function XMLDocumentCB(options, onData, onEnd) {
  17972. var writerOptions;
  17973. options || (options = {});
  17974. if (!options.writer) {
  17975. options.writer = new XMLStringWriter(options);
  17976. } else if (isPlainObject(options.writer)) {
  17977. writerOptions = options.writer;
  17978. options.writer = new XMLStringWriter(writerOptions);
  17979. }
  17980. this.options = options;
  17981. this.writer = options.writer;
  17982. this.stringify = new XMLStringifier(options);
  17983. this.onDataCallback = onData || function () {};
  17984. this.onEndCallback = onEnd || function () {};
  17985. this.currentNode = null;
  17986. this.currentLevel = -1;
  17987. this.openTags = {};
  17988. this.documentStarted = false;
  17989. this.documentCompleted = false;
  17990. this.root = null;
  17991. }
  17992. XMLDocumentCB.prototype.node = function (name, attributes, text) {
  17993. var ref1;
  17994. if (name == null) {
  17995. throw new Error("Missing node name");
  17996. }
  17997. if (this.root && this.currentLevel === -1) {
  17998. throw new Error("Document can only have one root node");
  17999. }
  18000. this.openCurrent();
  18001. name = name.valueOf();
  18002. if (attributes == null) {
  18003. attributes = {};
  18004. }
  18005. attributes = attributes.valueOf();
  18006. if (!isObject(attributes)) {
  18007. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  18008. }
  18009. this.currentNode = new XMLElement(this, name, attributes);
  18010. this.currentNode.children = false;
  18011. this.currentLevel++;
  18012. this.openTags[this.currentLevel] = this.currentNode;
  18013. if (text != null) {
  18014. this.text(text);
  18015. }
  18016. return this;
  18017. };
  18018. XMLDocumentCB.prototype.element = function (name, attributes, text) {
  18019. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  18020. return this.dtdElement.apply(this, arguments);
  18021. } else {
  18022. return this.node(name, attributes, text);
  18023. }
  18024. };
  18025. XMLDocumentCB.prototype.attribute = function (name, value) {
  18026. var attName, attValue;
  18027. if (!this.currentNode || this.currentNode.children) {
  18028. throw new Error("att() can only be used immediately after an ele() call in callback mode");
  18029. }
  18030. if (name != null) {
  18031. name = name.valueOf();
  18032. }
  18033. if (isObject(name)) {
  18034. for (attName in name) {
  18035. if (!hasProp.call(name, attName)) continue;
  18036. attValue = name[attName];
  18037. this.attribute(attName, attValue);
  18038. }
  18039. } else {
  18040. if (isFunction(value)) {
  18041. value = value.apply();
  18042. }
  18043. if (!this.options.skipNullAttributes || value != null) {
  18044. this.currentNode.attributes[name] = new XMLAttribute(this, name, value);
  18045. }
  18046. }
  18047. return this;
  18048. };
  18049. XMLDocumentCB.prototype.text = function (value) {
  18050. var node;
  18051. this.openCurrent();
  18052. node = new XMLText(this, value);
  18053. this.onData(this.writer.text(node, this.currentLevel + 1));
  18054. return this;
  18055. };
  18056. XMLDocumentCB.prototype.cdata = function (value) {
  18057. var node;
  18058. this.openCurrent();
  18059. node = new XMLCData(this, value);
  18060. this.onData(this.writer.cdata(node, this.currentLevel + 1));
  18061. return this;
  18062. };
  18063. XMLDocumentCB.prototype.comment = function (value) {
  18064. var node;
  18065. this.openCurrent();
  18066. node = new XMLComment(this, value);
  18067. this.onData(this.writer.comment(node, this.currentLevel + 1));
  18068. return this;
  18069. };
  18070. XMLDocumentCB.prototype.raw = function (value) {
  18071. var node;
  18072. this.openCurrent();
  18073. node = new XMLRaw(this, value);
  18074. this.onData(this.writer.raw(node, this.currentLevel + 1));
  18075. return this;
  18076. };
  18077. XMLDocumentCB.prototype.instruction = function (target, value) {
  18078. var i, insTarget, insValue, len, node;
  18079. this.openCurrent();
  18080. if (target != null) {
  18081. target = target.valueOf();
  18082. }
  18083. if (value != null) {
  18084. value = value.valueOf();
  18085. }
  18086. if (Array.isArray(target)) {
  18087. for (i = 0, len = target.length; i < len; i++) {
  18088. insTarget = target[i];
  18089. this.instruction(insTarget);
  18090. }
  18091. } else if (isObject(target)) {
  18092. for (insTarget in target) {
  18093. if (!hasProp.call(target, insTarget)) continue;
  18094. insValue = target[insTarget];
  18095. this.instruction(insTarget, insValue);
  18096. }
  18097. } else {
  18098. if (isFunction(value)) {
  18099. value = value.apply();
  18100. }
  18101. node = new XMLProcessingInstruction(this, target, value);
  18102. this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
  18103. }
  18104. return this;
  18105. };
  18106. XMLDocumentCB.prototype.declaration = function (version, encoding, standalone) {
  18107. var node;
  18108. this.openCurrent();
  18109. if (this.documentStarted) {
  18110. throw new Error("declaration() must be the first node");
  18111. }
  18112. node = new XMLDeclaration(this, version, encoding, standalone);
  18113. this.onData(this.writer.declaration(node, this.currentLevel + 1));
  18114. return this;
  18115. };
  18116. XMLDocumentCB.prototype.doctype = function (root, pubID, sysID) {
  18117. this.openCurrent();
  18118. if (root == null) {
  18119. throw new Error("Missing root node name");
  18120. }
  18121. if (this.root) {
  18122. throw new Error("dtd() must come before the root node");
  18123. }
  18124. this.currentNode = new XMLDocType(this, pubID, sysID);
  18125. this.currentNode.rootNodeName = root;
  18126. this.currentNode.children = false;
  18127. this.currentLevel++;
  18128. this.openTags[this.currentLevel] = this.currentNode;
  18129. return this;
  18130. };
  18131. XMLDocumentCB.prototype.dtdElement = function (name, value) {
  18132. var node;
  18133. this.openCurrent();
  18134. node = new XMLDTDElement(this, name, value);
  18135. this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
  18136. return this;
  18137. };
  18138. XMLDocumentCB.prototype.attList = function (elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  18139. var node;
  18140. this.openCurrent();
  18141. node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  18142. this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
  18143. return this;
  18144. };
  18145. XMLDocumentCB.prototype.entity = function (name, value) {
  18146. var node;
  18147. this.openCurrent();
  18148. node = new XMLDTDEntity(this, false, name, value);
  18149. this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
  18150. return this;
  18151. };
  18152. XMLDocumentCB.prototype.pEntity = function (name, value) {
  18153. var node;
  18154. this.openCurrent();
  18155. node = new XMLDTDEntity(this, true, name, value);
  18156. this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
  18157. return this;
  18158. };
  18159. XMLDocumentCB.prototype.notation = function (name, value) {
  18160. var node;
  18161. this.openCurrent();
  18162. node = new XMLDTDNotation(this, name, value);
  18163. this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
  18164. return this;
  18165. };
  18166. XMLDocumentCB.prototype.up = function () {
  18167. if (this.currentLevel < 0) {
  18168. throw new Error("The document node has no parent");
  18169. }
  18170. if (this.currentNode) {
  18171. if (this.currentNode.children) {
  18172. this.closeNode(this.currentNode);
  18173. } else {
  18174. this.openNode(this.currentNode);
  18175. }
  18176. this.currentNode = null;
  18177. } else {
  18178. this.closeNode(this.openTags[this.currentLevel]);
  18179. }
  18180. delete this.openTags[this.currentLevel];
  18181. this.currentLevel--;
  18182. return this;
  18183. };
  18184. XMLDocumentCB.prototype.end = function () {
  18185. while (this.currentLevel >= 0) {
  18186. this.up();
  18187. }
  18188. return this.onEnd();
  18189. };
  18190. XMLDocumentCB.prototype.openCurrent = function () {
  18191. if (this.currentNode) {
  18192. this.currentNode.children = true;
  18193. return this.openNode(this.currentNode);
  18194. }
  18195. };
  18196. XMLDocumentCB.prototype.openNode = function (node) {
  18197. if (!node.isOpen) {
  18198. if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
  18199. this.root = node;
  18200. }
  18201. this.onData(this.writer.openNode(node, this.currentLevel));
  18202. return node.isOpen = true;
  18203. }
  18204. };
  18205. XMLDocumentCB.prototype.closeNode = function (node) {
  18206. if (!node.isClosed) {
  18207. this.onData(this.writer.closeNode(node, this.currentLevel));
  18208. return node.isClosed = true;
  18209. }
  18210. };
  18211. XMLDocumentCB.prototype.onData = function (chunk) {
  18212. this.documentStarted = true;
  18213. return this.onDataCallback(chunk);
  18214. };
  18215. XMLDocumentCB.prototype.onEnd = function () {
  18216. this.documentCompleted = true;
  18217. return this.onEndCallback();
  18218. };
  18219. XMLDocumentCB.prototype.ele = function () {
  18220. return this.element.apply(this, arguments);
  18221. };
  18222. XMLDocumentCB.prototype.nod = function (name, attributes, text) {
  18223. return this.node(name, attributes, text);
  18224. };
  18225. XMLDocumentCB.prototype.txt = function (value) {
  18226. return this.text(value);
  18227. };
  18228. XMLDocumentCB.prototype.dat = function (value) {
  18229. return this.cdata(value);
  18230. };
  18231. XMLDocumentCB.prototype.com = function (value) {
  18232. return this.comment(value);
  18233. };
  18234. XMLDocumentCB.prototype.ins = function (target, value) {
  18235. return this.instruction(target, value);
  18236. };
  18237. XMLDocumentCB.prototype.dec = function (version, encoding, standalone) {
  18238. return this.declaration(version, encoding, standalone);
  18239. };
  18240. XMLDocumentCB.prototype.dtd = function (root, pubID, sysID) {
  18241. return this.doctype(root, pubID, sysID);
  18242. };
  18243. XMLDocumentCB.prototype.e = function (name, attributes, text) {
  18244. return this.element(name, attributes, text);
  18245. };
  18246. XMLDocumentCB.prototype.n = function (name, attributes, text) {
  18247. return this.node(name, attributes, text);
  18248. };
  18249. XMLDocumentCB.prototype.t = function (value) {
  18250. return this.text(value);
  18251. };
  18252. XMLDocumentCB.prototype.d = function (value) {
  18253. return this.cdata(value);
  18254. };
  18255. XMLDocumentCB.prototype.c = function (value) {
  18256. return this.comment(value);
  18257. };
  18258. XMLDocumentCB.prototype.r = function (value) {
  18259. return this.raw(value);
  18260. };
  18261. XMLDocumentCB.prototype.i = function (target, value) {
  18262. return this.instruction(target, value);
  18263. };
  18264. XMLDocumentCB.prototype.att = function () {
  18265. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  18266. return this.attList.apply(this, arguments);
  18267. } else {
  18268. return this.attribute.apply(this, arguments);
  18269. }
  18270. };
  18271. XMLDocumentCB.prototype.a = function () {
  18272. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  18273. return this.attList.apply(this, arguments);
  18274. } else {
  18275. return this.attribute.apply(this, arguments);
  18276. }
  18277. };
  18278. XMLDocumentCB.prototype.ent = function (name, value) {
  18279. return this.entity(name, value);
  18280. };
  18281. XMLDocumentCB.prototype.pent = function (name, value) {
  18282. return this.pEntity(name, value);
  18283. };
  18284. XMLDocumentCB.prototype.not = function (name, value) {
  18285. return this.notation(name, value);
  18286. };
  18287. return XMLDocumentCB;
  18288. }();
  18289. }).call(undefined);
  18290. },{"./Utility":203,"./XMLAttribute":204,"./XMLCData":205,"./XMLComment":206,"./XMLDTDAttList":207,"./XMLDTDElement":208,"./XMLDTDEntity":209,"./XMLDTDNotation":210,"./XMLDeclaration":211,"./XMLDocType":212,"./XMLElement":215,"./XMLProcessingInstruction":217,"./XMLRaw":218,"./XMLStringWriter":220,"./XMLStringifier":221,"./XMLText":222}],215:[function(require,module,exports){
  18291. 'use strict';
  18292. var _create = require('babel-runtime/core-js/object/create');
  18293. var _create2 = _interopRequireDefault(_create);
  18294. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18295. // Generated by CoffeeScript 1.12.6
  18296. (function () {
  18297. var XMLAttribute,
  18298. XMLElement,
  18299. XMLNode,
  18300. isFunction,
  18301. isObject,
  18302. ref,
  18303. extend = function extend(child, parent) {
  18304. for (var key in parent) {
  18305. if (hasProp.call(parent, key)) child[key] = parent[key];
  18306. }function ctor() {
  18307. this.constructor = child;
  18308. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  18309. },
  18310. hasProp = {}.hasOwnProperty;
  18311. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
  18312. XMLNode = require('./XMLNode');
  18313. XMLAttribute = require('./XMLAttribute');
  18314. module.exports = XMLElement = function (superClass) {
  18315. extend(XMLElement, superClass);
  18316. function XMLElement(parent, name, attributes) {
  18317. XMLElement.__super__.constructor.call(this, parent);
  18318. if (name == null) {
  18319. throw new Error("Missing element name");
  18320. }
  18321. this.name = this.stringify.eleName(name);
  18322. this.attributes = {};
  18323. if (attributes != null) {
  18324. this.attribute(attributes);
  18325. }
  18326. if (parent.isDocument) {
  18327. this.isRoot = true;
  18328. this.documentObject = parent;
  18329. parent.rootObject = this;
  18330. }
  18331. }
  18332. XMLElement.prototype.clone = function () {
  18333. var att, attName, clonedSelf, ref1;
  18334. clonedSelf = (0, _create2.default)(this);
  18335. if (clonedSelf.isRoot) {
  18336. clonedSelf.documentObject = null;
  18337. }
  18338. clonedSelf.attributes = {};
  18339. ref1 = this.attributes;
  18340. for (attName in ref1) {
  18341. if (!hasProp.call(ref1, attName)) continue;
  18342. att = ref1[attName];
  18343. clonedSelf.attributes[attName] = att.clone();
  18344. }
  18345. clonedSelf.children = [];
  18346. this.children.forEach(function (child) {
  18347. var clonedChild;
  18348. clonedChild = child.clone();
  18349. clonedChild.parent = clonedSelf;
  18350. return clonedSelf.children.push(clonedChild);
  18351. });
  18352. return clonedSelf;
  18353. };
  18354. XMLElement.prototype.attribute = function (name, value) {
  18355. var attName, attValue;
  18356. if (name != null) {
  18357. name = name.valueOf();
  18358. }
  18359. if (isObject(name)) {
  18360. for (attName in name) {
  18361. if (!hasProp.call(name, attName)) continue;
  18362. attValue = name[attName];
  18363. this.attribute(attName, attValue);
  18364. }
  18365. } else {
  18366. if (isFunction(value)) {
  18367. value = value.apply();
  18368. }
  18369. if (!this.options.skipNullAttributes || value != null) {
  18370. this.attributes[name] = new XMLAttribute(this, name, value);
  18371. }
  18372. }
  18373. return this;
  18374. };
  18375. XMLElement.prototype.removeAttribute = function (name) {
  18376. var attName, i, len;
  18377. if (name == null) {
  18378. throw new Error("Missing attribute name");
  18379. }
  18380. name = name.valueOf();
  18381. if (Array.isArray(name)) {
  18382. for (i = 0, len = name.length; i < len; i++) {
  18383. attName = name[i];
  18384. delete this.attributes[attName];
  18385. }
  18386. } else {
  18387. delete this.attributes[name];
  18388. }
  18389. return this;
  18390. };
  18391. XMLElement.prototype.toString = function (options) {
  18392. return this.options.writer.set(options).element(this);
  18393. };
  18394. XMLElement.prototype.att = function (name, value) {
  18395. return this.attribute(name, value);
  18396. };
  18397. XMLElement.prototype.a = function (name, value) {
  18398. return this.attribute(name, value);
  18399. };
  18400. return XMLElement;
  18401. }(XMLNode);
  18402. }).call(undefined);
  18403. },{"./Utility":203,"./XMLAttribute":204,"./XMLNode":216,"babel-runtime/core-js/object/create":14}],216:[function(require,module,exports){
  18404. 'use strict';
  18405. // Generated by CoffeeScript 1.12.6
  18406. (function () {
  18407. var XMLCData,
  18408. XMLComment,
  18409. XMLDeclaration,
  18410. XMLDocType,
  18411. XMLElement,
  18412. XMLNode,
  18413. XMLProcessingInstruction,
  18414. XMLRaw,
  18415. XMLText,
  18416. isEmpty,
  18417. isFunction,
  18418. isObject,
  18419. ref,
  18420. hasProp = {}.hasOwnProperty;
  18421. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
  18422. XMLElement = null;
  18423. XMLCData = null;
  18424. XMLComment = null;
  18425. XMLDeclaration = null;
  18426. XMLDocType = null;
  18427. XMLRaw = null;
  18428. XMLText = null;
  18429. XMLProcessingInstruction = null;
  18430. module.exports = XMLNode = function () {
  18431. function XMLNode(parent) {
  18432. this.parent = parent;
  18433. if (this.parent) {
  18434. this.options = this.parent.options;
  18435. this.stringify = this.parent.stringify;
  18436. }
  18437. this.children = [];
  18438. if (!XMLElement) {
  18439. XMLElement = require('./XMLElement');
  18440. XMLCData = require('./XMLCData');
  18441. XMLComment = require('./XMLComment');
  18442. XMLDeclaration = require('./XMLDeclaration');
  18443. XMLDocType = require('./XMLDocType');
  18444. XMLRaw = require('./XMLRaw');
  18445. XMLText = require('./XMLText');
  18446. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  18447. }
  18448. }
  18449. XMLNode.prototype.element = function (name, attributes, text) {
  18450. var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
  18451. lastChild = null;
  18452. if (attributes == null) {
  18453. attributes = {};
  18454. }
  18455. attributes = attributes.valueOf();
  18456. if (!isObject(attributes)) {
  18457. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  18458. }
  18459. if (name != null) {
  18460. name = name.valueOf();
  18461. }
  18462. if (Array.isArray(name)) {
  18463. for (j = 0, len = name.length; j < len; j++) {
  18464. item = name[j];
  18465. lastChild = this.element(item);
  18466. }
  18467. } else if (isFunction(name)) {
  18468. lastChild = this.element(name.apply());
  18469. } else if (isObject(name)) {
  18470. for (key in name) {
  18471. if (!hasProp.call(name, key)) continue;
  18472. val = name[key];
  18473. if (isFunction(val)) {
  18474. val = val.apply();
  18475. }
  18476. if (isObject(val) && isEmpty(val)) {
  18477. val = null;
  18478. }
  18479. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  18480. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  18481. } else if (!this.options.separateArrayItems && Array.isArray(val)) {
  18482. for (k = 0, len1 = val.length; k < len1; k++) {
  18483. item = val[k];
  18484. childNode = {};
  18485. childNode[key] = item;
  18486. lastChild = this.element(childNode);
  18487. }
  18488. } else if (isObject(val)) {
  18489. lastChild = this.element(key);
  18490. lastChild.element(val);
  18491. } else {
  18492. lastChild = this.element(key, val);
  18493. }
  18494. }
  18495. } else {
  18496. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  18497. lastChild = this.text(text);
  18498. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  18499. lastChild = this.cdata(text);
  18500. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  18501. lastChild = this.comment(text);
  18502. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  18503. lastChild = this.raw(text);
  18504. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
  18505. lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
  18506. } else {
  18507. lastChild = this.node(name, attributes, text);
  18508. }
  18509. }
  18510. if (lastChild == null) {
  18511. throw new Error("Could not create any elements with: " + name);
  18512. }
  18513. return lastChild;
  18514. };
  18515. XMLNode.prototype.insertBefore = function (name, attributes, text) {
  18516. var child, i, removed;
  18517. if (this.isRoot) {
  18518. throw new Error("Cannot insert elements at root level");
  18519. }
  18520. i = this.parent.children.indexOf(this);
  18521. removed = this.parent.children.splice(i);
  18522. child = this.parent.element(name, attributes, text);
  18523. Array.prototype.push.apply(this.parent.children, removed);
  18524. return child;
  18525. };
  18526. XMLNode.prototype.insertAfter = function (name, attributes, text) {
  18527. var child, i, removed;
  18528. if (this.isRoot) {
  18529. throw new Error("Cannot insert elements at root level");
  18530. }
  18531. i = this.parent.children.indexOf(this);
  18532. removed = this.parent.children.splice(i + 1);
  18533. child = this.parent.element(name, attributes, text);
  18534. Array.prototype.push.apply(this.parent.children, removed);
  18535. return child;
  18536. };
  18537. XMLNode.prototype.remove = function () {
  18538. var i, ref1;
  18539. if (this.isRoot) {
  18540. throw new Error("Cannot remove the root element");
  18541. }
  18542. i = this.parent.children.indexOf(this);
  18543. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
  18544. return this.parent;
  18545. };
  18546. XMLNode.prototype.node = function (name, attributes, text) {
  18547. var child, ref1;
  18548. if (name != null) {
  18549. name = name.valueOf();
  18550. }
  18551. attributes || (attributes = {});
  18552. attributes = attributes.valueOf();
  18553. if (!isObject(attributes)) {
  18554. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  18555. }
  18556. child = new XMLElement(this, name, attributes);
  18557. if (text != null) {
  18558. child.text(text);
  18559. }
  18560. this.children.push(child);
  18561. return child;
  18562. };
  18563. XMLNode.prototype.text = function (value) {
  18564. var child;
  18565. child = new XMLText(this, value);
  18566. this.children.push(child);
  18567. return this;
  18568. };
  18569. XMLNode.prototype.cdata = function (value) {
  18570. var child;
  18571. child = new XMLCData(this, value);
  18572. this.children.push(child);
  18573. return this;
  18574. };
  18575. XMLNode.prototype.comment = function (value) {
  18576. var child;
  18577. child = new XMLComment(this, value);
  18578. this.children.push(child);
  18579. return this;
  18580. };
  18581. XMLNode.prototype.commentBefore = function (value) {
  18582. var child, i, removed;
  18583. i = this.parent.children.indexOf(this);
  18584. removed = this.parent.children.splice(i);
  18585. child = this.parent.comment(value);
  18586. Array.prototype.push.apply(this.parent.children, removed);
  18587. return this;
  18588. };
  18589. XMLNode.prototype.commentAfter = function (value) {
  18590. var child, i, removed;
  18591. i = this.parent.children.indexOf(this);
  18592. removed = this.parent.children.splice(i + 1);
  18593. child = this.parent.comment(value);
  18594. Array.prototype.push.apply(this.parent.children, removed);
  18595. return this;
  18596. };
  18597. XMLNode.prototype.raw = function (value) {
  18598. var child;
  18599. child = new XMLRaw(this, value);
  18600. this.children.push(child);
  18601. return this;
  18602. };
  18603. XMLNode.prototype.instruction = function (target, value) {
  18604. var insTarget, insValue, instruction, j, len;
  18605. if (target != null) {
  18606. target = target.valueOf();
  18607. }
  18608. if (value != null) {
  18609. value = value.valueOf();
  18610. }
  18611. if (Array.isArray(target)) {
  18612. for (j = 0, len = target.length; j < len; j++) {
  18613. insTarget = target[j];
  18614. this.instruction(insTarget);
  18615. }
  18616. } else if (isObject(target)) {
  18617. for (insTarget in target) {
  18618. if (!hasProp.call(target, insTarget)) continue;
  18619. insValue = target[insTarget];
  18620. this.instruction(insTarget, insValue);
  18621. }
  18622. } else {
  18623. if (isFunction(value)) {
  18624. value = value.apply();
  18625. }
  18626. instruction = new XMLProcessingInstruction(this, target, value);
  18627. this.children.push(instruction);
  18628. }
  18629. return this;
  18630. };
  18631. XMLNode.prototype.instructionBefore = function (target, value) {
  18632. var child, i, removed;
  18633. i = this.parent.children.indexOf(this);
  18634. removed = this.parent.children.splice(i);
  18635. child = this.parent.instruction(target, value);
  18636. Array.prototype.push.apply(this.parent.children, removed);
  18637. return this;
  18638. };
  18639. XMLNode.prototype.instructionAfter = function (target, value) {
  18640. var child, i, removed;
  18641. i = this.parent.children.indexOf(this);
  18642. removed = this.parent.children.splice(i + 1);
  18643. child = this.parent.instruction(target, value);
  18644. Array.prototype.push.apply(this.parent.children, removed);
  18645. return this;
  18646. };
  18647. XMLNode.prototype.declaration = function (version, encoding, standalone) {
  18648. var doc, xmldec;
  18649. doc = this.document();
  18650. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  18651. if (doc.children[0] instanceof XMLDeclaration) {
  18652. doc.children[0] = xmldec;
  18653. } else {
  18654. doc.children.unshift(xmldec);
  18655. }
  18656. return doc.root() || doc;
  18657. };
  18658. XMLNode.prototype.doctype = function (pubID, sysID) {
  18659. var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
  18660. doc = this.document();
  18661. doctype = new XMLDocType(doc, pubID, sysID);
  18662. ref1 = doc.children;
  18663. for (i = j = 0, len = ref1.length; j < len; i = ++j) {
  18664. child = ref1[i];
  18665. if (child instanceof XMLDocType) {
  18666. doc.children[i] = doctype;
  18667. return doctype;
  18668. }
  18669. }
  18670. ref2 = doc.children;
  18671. for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
  18672. child = ref2[i];
  18673. if (child.isRoot) {
  18674. doc.children.splice(i, 0, doctype);
  18675. return doctype;
  18676. }
  18677. }
  18678. doc.children.push(doctype);
  18679. return doctype;
  18680. };
  18681. XMLNode.prototype.up = function () {
  18682. if (this.isRoot) {
  18683. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  18684. }
  18685. return this.parent;
  18686. };
  18687. XMLNode.prototype.root = function () {
  18688. var node;
  18689. node = this;
  18690. while (node) {
  18691. if (node.isDocument) {
  18692. return node.rootObject;
  18693. } else if (node.isRoot) {
  18694. return node;
  18695. } else {
  18696. node = node.parent;
  18697. }
  18698. }
  18699. };
  18700. XMLNode.prototype.document = function () {
  18701. var node;
  18702. node = this;
  18703. while (node) {
  18704. if (node.isDocument) {
  18705. return node;
  18706. } else {
  18707. node = node.parent;
  18708. }
  18709. }
  18710. };
  18711. XMLNode.prototype.end = function (options) {
  18712. return this.document().end(options);
  18713. };
  18714. XMLNode.prototype.prev = function () {
  18715. var i;
  18716. i = this.parent.children.indexOf(this);
  18717. if (i < 1) {
  18718. throw new Error("Already at the first node");
  18719. }
  18720. return this.parent.children[i - 1];
  18721. };
  18722. XMLNode.prototype.next = function () {
  18723. var i;
  18724. i = this.parent.children.indexOf(this);
  18725. if (i === -1 || i === this.parent.children.length - 1) {
  18726. throw new Error("Already at the last node");
  18727. }
  18728. return this.parent.children[i + 1];
  18729. };
  18730. XMLNode.prototype.importDocument = function (doc) {
  18731. var clonedRoot;
  18732. clonedRoot = doc.root().clone();
  18733. clonedRoot.parent = this;
  18734. clonedRoot.isRoot = false;
  18735. this.children.push(clonedRoot);
  18736. return this;
  18737. };
  18738. XMLNode.prototype.ele = function (name, attributes, text) {
  18739. return this.element(name, attributes, text);
  18740. };
  18741. XMLNode.prototype.nod = function (name, attributes, text) {
  18742. return this.node(name, attributes, text);
  18743. };
  18744. XMLNode.prototype.txt = function (value) {
  18745. return this.text(value);
  18746. };
  18747. XMLNode.prototype.dat = function (value) {
  18748. return this.cdata(value);
  18749. };
  18750. XMLNode.prototype.com = function (value) {
  18751. return this.comment(value);
  18752. };
  18753. XMLNode.prototype.ins = function (target, value) {
  18754. return this.instruction(target, value);
  18755. };
  18756. XMLNode.prototype.doc = function () {
  18757. return this.document();
  18758. };
  18759. XMLNode.prototype.dec = function (version, encoding, standalone) {
  18760. return this.declaration(version, encoding, standalone);
  18761. };
  18762. XMLNode.prototype.dtd = function (pubID, sysID) {
  18763. return this.doctype(pubID, sysID);
  18764. };
  18765. XMLNode.prototype.e = function (name, attributes, text) {
  18766. return this.element(name, attributes, text);
  18767. };
  18768. XMLNode.prototype.n = function (name, attributes, text) {
  18769. return this.node(name, attributes, text);
  18770. };
  18771. XMLNode.prototype.t = function (value) {
  18772. return this.text(value);
  18773. };
  18774. XMLNode.prototype.d = function (value) {
  18775. return this.cdata(value);
  18776. };
  18777. XMLNode.prototype.c = function (value) {
  18778. return this.comment(value);
  18779. };
  18780. XMLNode.prototype.r = function (value) {
  18781. return this.raw(value);
  18782. };
  18783. XMLNode.prototype.i = function (target, value) {
  18784. return this.instruction(target, value);
  18785. };
  18786. XMLNode.prototype.u = function () {
  18787. return this.up();
  18788. };
  18789. XMLNode.prototype.importXMLBuilder = function (doc) {
  18790. return this.importDocument(doc);
  18791. };
  18792. return XMLNode;
  18793. }();
  18794. }).call(undefined);
  18795. },{"./Utility":203,"./XMLCData":205,"./XMLComment":206,"./XMLDeclaration":211,"./XMLDocType":212,"./XMLElement":215,"./XMLProcessingInstruction":217,"./XMLRaw":218,"./XMLText":222}],217:[function(require,module,exports){
  18796. "use strict";
  18797. var _create = require("babel-runtime/core-js/object/create");
  18798. var _create2 = _interopRequireDefault(_create);
  18799. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18800. // Generated by CoffeeScript 1.12.6
  18801. (function () {
  18802. var XMLNode,
  18803. XMLProcessingInstruction,
  18804. extend = function extend(child, parent) {
  18805. for (var key in parent) {
  18806. if (hasProp.call(parent, key)) child[key] = parent[key];
  18807. }function ctor() {
  18808. this.constructor = child;
  18809. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  18810. },
  18811. hasProp = {}.hasOwnProperty;
  18812. XMLNode = require('./XMLNode');
  18813. module.exports = XMLProcessingInstruction = function (superClass) {
  18814. extend(XMLProcessingInstruction, superClass);
  18815. function XMLProcessingInstruction(parent, target, value) {
  18816. XMLProcessingInstruction.__super__.constructor.call(this, parent);
  18817. if (target == null) {
  18818. throw new Error("Missing instruction target");
  18819. }
  18820. this.target = this.stringify.insTarget(target);
  18821. if (value) {
  18822. this.value = this.stringify.insValue(value);
  18823. }
  18824. }
  18825. XMLProcessingInstruction.prototype.clone = function () {
  18826. return (0, _create2.default)(this);
  18827. };
  18828. XMLProcessingInstruction.prototype.toString = function (options) {
  18829. return this.options.writer.set(options).processingInstruction(this);
  18830. };
  18831. return XMLProcessingInstruction;
  18832. }(XMLNode);
  18833. }).call(undefined);
  18834. },{"./XMLNode":216,"babel-runtime/core-js/object/create":14}],218:[function(require,module,exports){
  18835. "use strict";
  18836. var _create = require("babel-runtime/core-js/object/create");
  18837. var _create2 = _interopRequireDefault(_create);
  18838. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18839. // Generated by CoffeeScript 1.12.6
  18840. (function () {
  18841. var XMLNode,
  18842. XMLRaw,
  18843. extend = function extend(child, parent) {
  18844. for (var key in parent) {
  18845. if (hasProp.call(parent, key)) child[key] = parent[key];
  18846. }function ctor() {
  18847. this.constructor = child;
  18848. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  18849. },
  18850. hasProp = {}.hasOwnProperty;
  18851. XMLNode = require('./XMLNode');
  18852. module.exports = XMLRaw = function (superClass) {
  18853. extend(XMLRaw, superClass);
  18854. function XMLRaw(parent, text) {
  18855. XMLRaw.__super__.constructor.call(this, parent);
  18856. if (text == null) {
  18857. throw new Error("Missing raw text");
  18858. }
  18859. this.value = this.stringify.raw(text);
  18860. }
  18861. XMLRaw.prototype.clone = function () {
  18862. return (0, _create2.default)(this);
  18863. };
  18864. XMLRaw.prototype.toString = function (options) {
  18865. return this.options.writer.set(options).raw(this);
  18866. };
  18867. return XMLRaw;
  18868. }(XMLNode);
  18869. }).call(undefined);
  18870. },{"./XMLNode":216,"babel-runtime/core-js/object/create":14}],219:[function(require,module,exports){
  18871. 'use strict';
  18872. // Generated by CoffeeScript 1.12.6
  18873. (function () {
  18874. var XMLCData,
  18875. XMLComment,
  18876. XMLDTDAttList,
  18877. XMLDTDElement,
  18878. XMLDTDEntity,
  18879. XMLDTDNotation,
  18880. XMLDeclaration,
  18881. XMLDocType,
  18882. XMLElement,
  18883. XMLProcessingInstruction,
  18884. XMLRaw,
  18885. XMLStreamWriter,
  18886. XMLText,
  18887. XMLWriterBase,
  18888. extend = function extend(child, parent) {
  18889. for (var key in parent) {
  18890. if (hasProp.call(parent, key)) child[key] = parent[key];
  18891. }function ctor() {
  18892. this.constructor = child;
  18893. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  18894. },
  18895. hasProp = {}.hasOwnProperty;
  18896. XMLDeclaration = require('./XMLDeclaration');
  18897. XMLDocType = require('./XMLDocType');
  18898. XMLCData = require('./XMLCData');
  18899. XMLComment = require('./XMLComment');
  18900. XMLElement = require('./XMLElement');
  18901. XMLRaw = require('./XMLRaw');
  18902. XMLText = require('./XMLText');
  18903. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  18904. XMLDTDAttList = require('./XMLDTDAttList');
  18905. XMLDTDElement = require('./XMLDTDElement');
  18906. XMLDTDEntity = require('./XMLDTDEntity');
  18907. XMLDTDNotation = require('./XMLDTDNotation');
  18908. XMLWriterBase = require('./XMLWriterBase');
  18909. module.exports = XMLStreamWriter = function (superClass) {
  18910. extend(XMLStreamWriter, superClass);
  18911. function XMLStreamWriter(stream, options) {
  18912. this.stream = stream;
  18913. XMLStreamWriter.__super__.constructor.call(this, options);
  18914. }
  18915. XMLStreamWriter.prototype.document = function (doc) {
  18916. var child, i, j, len, len1, ref, ref1, results;
  18917. ref = doc.children;
  18918. for (i = 0, len = ref.length; i < len; i++) {
  18919. child = ref[i];
  18920. child.isLastRootNode = false;
  18921. }
  18922. doc.children[doc.children.length - 1].isLastRootNode = true;
  18923. ref1 = doc.children;
  18924. results = [];
  18925. for (j = 0, len1 = ref1.length; j < len1; j++) {
  18926. child = ref1[j];
  18927. switch (false) {
  18928. case !(child instanceof XMLDeclaration):
  18929. results.push(this.declaration(child));
  18930. break;
  18931. case !(child instanceof XMLDocType):
  18932. results.push(this.docType(child));
  18933. break;
  18934. case !(child instanceof XMLComment):
  18935. results.push(this.comment(child));
  18936. break;
  18937. case !(child instanceof XMLProcessingInstruction):
  18938. results.push(this.processingInstruction(child));
  18939. break;
  18940. default:
  18941. results.push(this.element(child));
  18942. }
  18943. }
  18944. return results;
  18945. };
  18946. XMLStreamWriter.prototype.attribute = function (att) {
  18947. return this.stream.write(' ' + att.name + '="' + att.value + '"');
  18948. };
  18949. XMLStreamWriter.prototype.cdata = function (node, level) {
  18950. return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
  18951. };
  18952. XMLStreamWriter.prototype.comment = function (node, level) {
  18953. return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
  18954. };
  18955. XMLStreamWriter.prototype.declaration = function (node, level) {
  18956. this.stream.write(this.space(level));
  18957. this.stream.write('<?xml version="' + node.version + '"');
  18958. if (node.encoding != null) {
  18959. this.stream.write(' encoding="' + node.encoding + '"');
  18960. }
  18961. if (node.standalone != null) {
  18962. this.stream.write(' standalone="' + node.standalone + '"');
  18963. }
  18964. this.stream.write(this.spacebeforeslash + '?>');
  18965. return this.stream.write(this.endline(node));
  18966. };
  18967. XMLStreamWriter.prototype.docType = function (node, level) {
  18968. var child, i, len, ref;
  18969. level || (level = 0);
  18970. this.stream.write(this.space(level));
  18971. this.stream.write('<!DOCTYPE ' + node.root().name);
  18972. if (node.pubID && node.sysID) {
  18973. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  18974. } else if (node.sysID) {
  18975. this.stream.write(' SYSTEM "' + node.sysID + '"');
  18976. }
  18977. if (node.children.length > 0) {
  18978. this.stream.write(' [');
  18979. this.stream.write(this.endline(node));
  18980. ref = node.children;
  18981. for (i = 0, len = ref.length; i < len; i++) {
  18982. child = ref[i];
  18983. switch (false) {
  18984. case !(child instanceof XMLDTDAttList):
  18985. this.dtdAttList(child, level + 1);
  18986. break;
  18987. case !(child instanceof XMLDTDElement):
  18988. this.dtdElement(child, level + 1);
  18989. break;
  18990. case !(child instanceof XMLDTDEntity):
  18991. this.dtdEntity(child, level + 1);
  18992. break;
  18993. case !(child instanceof XMLDTDNotation):
  18994. this.dtdNotation(child, level + 1);
  18995. break;
  18996. case !(child instanceof XMLCData):
  18997. this.cdata(child, level + 1);
  18998. break;
  18999. case !(child instanceof XMLComment):
  19000. this.comment(child, level + 1);
  19001. break;
  19002. case !(child instanceof XMLProcessingInstruction):
  19003. this.processingInstruction(child, level + 1);
  19004. break;
  19005. default:
  19006. throw new Error("Unknown DTD node type: " + child.constructor.name);
  19007. }
  19008. }
  19009. this.stream.write(']');
  19010. }
  19011. this.stream.write(this.spacebeforeslash + '>');
  19012. return this.stream.write(this.endline(node));
  19013. };
  19014. XMLStreamWriter.prototype.element = function (node, level) {
  19015. var att, child, i, len, name, ref, ref1, space;
  19016. level || (level = 0);
  19017. space = this.space(level);
  19018. this.stream.write(space + '<' + node.name);
  19019. ref = node.attributes;
  19020. for (name in ref) {
  19021. if (!hasProp.call(ref, name)) continue;
  19022. att = ref[name];
  19023. this.attribute(att);
  19024. }
  19025. if (node.children.length === 0 || node.children.every(function (e) {
  19026. return e.value === '';
  19027. })) {
  19028. if (this.allowEmpty) {
  19029. this.stream.write('></' + node.name + '>');
  19030. } else {
  19031. this.stream.write(this.spacebeforeslash + '/>');
  19032. }
  19033. } else if (this.pretty && node.children.length === 1 && node.children[0].value != null) {
  19034. this.stream.write('>');
  19035. this.stream.write(node.children[0].value);
  19036. this.stream.write('</' + node.name + '>');
  19037. } else {
  19038. this.stream.write('>' + this.newline);
  19039. ref1 = node.children;
  19040. for (i = 0, len = ref1.length; i < len; i++) {
  19041. child = ref1[i];
  19042. switch (false) {
  19043. case !(child instanceof XMLCData):
  19044. this.cdata(child, level + 1);
  19045. break;
  19046. case !(child instanceof XMLComment):
  19047. this.comment(child, level + 1);
  19048. break;
  19049. case !(child instanceof XMLElement):
  19050. this.element(child, level + 1);
  19051. break;
  19052. case !(child instanceof XMLRaw):
  19053. this.raw(child, level + 1);
  19054. break;
  19055. case !(child instanceof XMLText):
  19056. this.text(child, level + 1);
  19057. break;
  19058. case !(child instanceof XMLProcessingInstruction):
  19059. this.processingInstruction(child, level + 1);
  19060. break;
  19061. default:
  19062. throw new Error("Unknown XML node type: " + child.constructor.name);
  19063. }
  19064. }
  19065. this.stream.write(space + '</' + node.name + '>');
  19066. }
  19067. return this.stream.write(this.endline(node));
  19068. };
  19069. XMLStreamWriter.prototype.processingInstruction = function (node, level) {
  19070. this.stream.write(this.space(level) + '<?' + node.target);
  19071. if (node.value) {
  19072. this.stream.write(' ' + node.value);
  19073. }
  19074. return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
  19075. };
  19076. XMLStreamWriter.prototype.raw = function (node, level) {
  19077. return this.stream.write(this.space(level) + node.value + this.endline(node));
  19078. };
  19079. XMLStreamWriter.prototype.text = function (node, level) {
  19080. return this.stream.write(this.space(level) + node.value + this.endline(node));
  19081. };
  19082. XMLStreamWriter.prototype.dtdAttList = function (node, level) {
  19083. this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
  19084. if (node.defaultValueType !== '#DEFAULT') {
  19085. this.stream.write(' ' + node.defaultValueType);
  19086. }
  19087. if (node.defaultValue) {
  19088. this.stream.write(' "' + node.defaultValue + '"');
  19089. }
  19090. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  19091. };
  19092. XMLStreamWriter.prototype.dtdElement = function (node, level) {
  19093. this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
  19094. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  19095. };
  19096. XMLStreamWriter.prototype.dtdEntity = function (node, level) {
  19097. this.stream.write(this.space(level) + '<!ENTITY');
  19098. if (node.pe) {
  19099. this.stream.write(' %');
  19100. }
  19101. this.stream.write(' ' + node.name);
  19102. if (node.value) {
  19103. this.stream.write(' "' + node.value + '"');
  19104. } else {
  19105. if (node.pubID && node.sysID) {
  19106. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  19107. } else if (node.sysID) {
  19108. this.stream.write(' SYSTEM "' + node.sysID + '"');
  19109. }
  19110. if (node.nData) {
  19111. this.stream.write(' NDATA ' + node.nData);
  19112. }
  19113. }
  19114. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  19115. };
  19116. XMLStreamWriter.prototype.dtdNotation = function (node, level) {
  19117. this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
  19118. if (node.pubID && node.sysID) {
  19119. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  19120. } else if (node.pubID) {
  19121. this.stream.write(' PUBLIC "' + node.pubID + '"');
  19122. } else if (node.sysID) {
  19123. this.stream.write(' SYSTEM "' + node.sysID + '"');
  19124. }
  19125. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  19126. };
  19127. XMLStreamWriter.prototype.endline = function (node) {
  19128. if (!node.isLastRootNode) {
  19129. return this.newline;
  19130. } else {
  19131. return '';
  19132. }
  19133. };
  19134. return XMLStreamWriter;
  19135. }(XMLWriterBase);
  19136. }).call(undefined);
  19137. },{"./XMLCData":205,"./XMLComment":206,"./XMLDTDAttList":207,"./XMLDTDElement":208,"./XMLDTDEntity":209,"./XMLDTDNotation":210,"./XMLDeclaration":211,"./XMLDocType":212,"./XMLElement":215,"./XMLProcessingInstruction":217,"./XMLRaw":218,"./XMLText":222,"./XMLWriterBase":223}],220:[function(require,module,exports){
  19138. 'use strict';
  19139. // Generated by CoffeeScript 1.12.6
  19140. (function () {
  19141. var XMLCData,
  19142. XMLComment,
  19143. XMLDTDAttList,
  19144. XMLDTDElement,
  19145. XMLDTDEntity,
  19146. XMLDTDNotation,
  19147. XMLDeclaration,
  19148. XMLDocType,
  19149. XMLElement,
  19150. XMLProcessingInstruction,
  19151. XMLRaw,
  19152. XMLStringWriter,
  19153. XMLText,
  19154. XMLWriterBase,
  19155. extend = function extend(child, parent) {
  19156. for (var key in parent) {
  19157. if (hasProp.call(parent, key)) child[key] = parent[key];
  19158. }function ctor() {
  19159. this.constructor = child;
  19160. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  19161. },
  19162. hasProp = {}.hasOwnProperty;
  19163. XMLDeclaration = require('./XMLDeclaration');
  19164. XMLDocType = require('./XMLDocType');
  19165. XMLCData = require('./XMLCData');
  19166. XMLComment = require('./XMLComment');
  19167. XMLElement = require('./XMLElement');
  19168. XMLRaw = require('./XMLRaw');
  19169. XMLText = require('./XMLText');
  19170. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  19171. XMLDTDAttList = require('./XMLDTDAttList');
  19172. XMLDTDElement = require('./XMLDTDElement');
  19173. XMLDTDEntity = require('./XMLDTDEntity');
  19174. XMLDTDNotation = require('./XMLDTDNotation');
  19175. XMLWriterBase = require('./XMLWriterBase');
  19176. module.exports = XMLStringWriter = function (superClass) {
  19177. extend(XMLStringWriter, superClass);
  19178. function XMLStringWriter(options) {
  19179. XMLStringWriter.__super__.constructor.call(this, options);
  19180. }
  19181. XMLStringWriter.prototype.document = function (doc) {
  19182. var child, i, len, r, ref;
  19183. this.textispresent = false;
  19184. r = '';
  19185. ref = doc.children;
  19186. for (i = 0, len = ref.length; i < len; i++) {
  19187. child = ref[i];
  19188. r += function () {
  19189. switch (false) {
  19190. case !(child instanceof XMLDeclaration):
  19191. return this.declaration(child);
  19192. case !(child instanceof XMLDocType):
  19193. return this.docType(child);
  19194. case !(child instanceof XMLComment):
  19195. return this.comment(child);
  19196. case !(child instanceof XMLProcessingInstruction):
  19197. return this.processingInstruction(child);
  19198. default:
  19199. return this.element(child, 0);
  19200. }
  19201. }.call(this);
  19202. }
  19203. if (this.pretty && r.slice(-this.newline.length) === this.newline) {
  19204. r = r.slice(0, -this.newline.length);
  19205. }
  19206. return r;
  19207. };
  19208. XMLStringWriter.prototype.attribute = function (att) {
  19209. return ' ' + att.name + '="' + att.value + '"';
  19210. };
  19211. XMLStringWriter.prototype.cdata = function (node, level) {
  19212. return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
  19213. };
  19214. XMLStringWriter.prototype.comment = function (node, level) {
  19215. return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
  19216. };
  19217. XMLStringWriter.prototype.declaration = function (node, level) {
  19218. var r;
  19219. r = this.space(level);
  19220. r += '<?xml version="' + node.version + '"';
  19221. if (node.encoding != null) {
  19222. r += ' encoding="' + node.encoding + '"';
  19223. }
  19224. if (node.standalone != null) {
  19225. r += ' standalone="' + node.standalone + '"';
  19226. }
  19227. r += this.spacebeforeslash + '?>';
  19228. r += this.newline;
  19229. return r;
  19230. };
  19231. XMLStringWriter.prototype.docType = function (node, level) {
  19232. var child, i, len, r, ref;
  19233. level || (level = 0);
  19234. r = this.space(level);
  19235. r += '<!DOCTYPE ' + node.root().name;
  19236. if (node.pubID && node.sysID) {
  19237. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  19238. } else if (node.sysID) {
  19239. r += ' SYSTEM "' + node.sysID + '"';
  19240. }
  19241. if (node.children.length > 0) {
  19242. r += ' [';
  19243. r += this.newline;
  19244. ref = node.children;
  19245. for (i = 0, len = ref.length; i < len; i++) {
  19246. child = ref[i];
  19247. r += function () {
  19248. switch (false) {
  19249. case !(child instanceof XMLDTDAttList):
  19250. return this.dtdAttList(child, level + 1);
  19251. case !(child instanceof XMLDTDElement):
  19252. return this.dtdElement(child, level + 1);
  19253. case !(child instanceof XMLDTDEntity):
  19254. return this.dtdEntity(child, level + 1);
  19255. case !(child instanceof XMLDTDNotation):
  19256. return this.dtdNotation(child, level + 1);
  19257. case !(child instanceof XMLCData):
  19258. return this.cdata(child, level + 1);
  19259. case !(child instanceof XMLComment):
  19260. return this.comment(child, level + 1);
  19261. case !(child instanceof XMLProcessingInstruction):
  19262. return this.processingInstruction(child, level + 1);
  19263. default:
  19264. throw new Error("Unknown DTD node type: " + child.constructor.name);
  19265. }
  19266. }.call(this);
  19267. }
  19268. r += ']';
  19269. }
  19270. r += this.spacebeforeslash + '>';
  19271. r += this.newline;
  19272. return r;
  19273. };
  19274. XMLStringWriter.prototype.element = function (node, level) {
  19275. var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
  19276. level || (level = 0);
  19277. textispresentwasset = false;
  19278. if (this.textispresent) {
  19279. this.newline = '';
  19280. this.pretty = false;
  19281. } else {
  19282. this.newline = this.newlinedefault;
  19283. this.pretty = this.prettydefault;
  19284. }
  19285. space = this.space(level);
  19286. r = '';
  19287. r += space + '<' + node.name;
  19288. ref = node.attributes;
  19289. for (name in ref) {
  19290. if (!hasProp.call(ref, name)) continue;
  19291. att = ref[name];
  19292. r += this.attribute(att);
  19293. }
  19294. if (node.children.length === 0 || node.children.every(function (e) {
  19295. return e.value === '';
  19296. })) {
  19297. if (this.allowEmpty) {
  19298. r += '></' + node.name + '>' + this.newline;
  19299. } else {
  19300. r += this.spacebeforeslash + '/>' + this.newline;
  19301. }
  19302. } else if (this.pretty && node.children.length === 1 && node.children[0].value != null) {
  19303. r += '>';
  19304. r += node.children[0].value;
  19305. r += '</' + node.name + '>' + this.newline;
  19306. } else {
  19307. if (this.dontprettytextnodes) {
  19308. ref1 = node.children;
  19309. for (i = 0, len = ref1.length; i < len; i++) {
  19310. child = ref1[i];
  19311. if (child.value != null) {
  19312. this.textispresent++;
  19313. textispresentwasset = true;
  19314. break;
  19315. }
  19316. }
  19317. }
  19318. if (this.textispresent) {
  19319. this.newline = '';
  19320. this.pretty = false;
  19321. space = this.space(level);
  19322. }
  19323. r += '>' + this.newline;
  19324. ref2 = node.children;
  19325. for (j = 0, len1 = ref2.length; j < len1; j++) {
  19326. child = ref2[j];
  19327. r += function () {
  19328. switch (false) {
  19329. case !(child instanceof XMLCData):
  19330. return this.cdata(child, level + 1);
  19331. case !(child instanceof XMLComment):
  19332. return this.comment(child, level + 1);
  19333. case !(child instanceof XMLElement):
  19334. return this.element(child, level + 1);
  19335. case !(child instanceof XMLRaw):
  19336. return this.raw(child, level + 1);
  19337. case !(child instanceof XMLText):
  19338. return this.text(child, level + 1);
  19339. case !(child instanceof XMLProcessingInstruction):
  19340. return this.processingInstruction(child, level + 1);
  19341. default:
  19342. throw new Error("Unknown XML node type: " + child.constructor.name);
  19343. }
  19344. }.call(this);
  19345. }
  19346. if (textispresentwasset) {
  19347. this.textispresent--;
  19348. }
  19349. if (!this.textispresent) {
  19350. this.newline = this.newlinedefault;
  19351. this.pretty = this.prettydefault;
  19352. }
  19353. r += space + '</' + node.name + '>' + this.newline;
  19354. }
  19355. return r;
  19356. };
  19357. XMLStringWriter.prototype.processingInstruction = function (node, level) {
  19358. var r;
  19359. r = this.space(level) + '<?' + node.target;
  19360. if (node.value) {
  19361. r += ' ' + node.value;
  19362. }
  19363. r += this.spacebeforeslash + '?>' + this.newline;
  19364. return r;
  19365. };
  19366. XMLStringWriter.prototype.raw = function (node, level) {
  19367. return this.space(level) + node.value + this.newline;
  19368. };
  19369. XMLStringWriter.prototype.text = function (node, level) {
  19370. return this.space(level) + node.value + this.newline;
  19371. };
  19372. XMLStringWriter.prototype.dtdAttList = function (node, level) {
  19373. var r;
  19374. r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
  19375. if (node.defaultValueType !== '#DEFAULT') {
  19376. r += ' ' + node.defaultValueType;
  19377. }
  19378. if (node.defaultValue) {
  19379. r += ' "' + node.defaultValue + '"';
  19380. }
  19381. r += this.spacebeforeslash + '>' + this.newline;
  19382. return r;
  19383. };
  19384. XMLStringWriter.prototype.dtdElement = function (node, level) {
  19385. return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
  19386. };
  19387. XMLStringWriter.prototype.dtdEntity = function (node, level) {
  19388. var r;
  19389. r = this.space(level) + '<!ENTITY';
  19390. if (node.pe) {
  19391. r += ' %';
  19392. }
  19393. r += ' ' + node.name;
  19394. if (node.value) {
  19395. r += ' "' + node.value + '"';
  19396. } else {
  19397. if (node.pubID && node.sysID) {
  19398. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  19399. } else if (node.sysID) {
  19400. r += ' SYSTEM "' + node.sysID + '"';
  19401. }
  19402. if (node.nData) {
  19403. r += ' NDATA ' + node.nData;
  19404. }
  19405. }
  19406. r += this.spacebeforeslash + '>' + this.newline;
  19407. return r;
  19408. };
  19409. XMLStringWriter.prototype.dtdNotation = function (node, level) {
  19410. var r;
  19411. r = this.space(level) + '<!NOTATION ' + node.name;
  19412. if (node.pubID && node.sysID) {
  19413. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  19414. } else if (node.pubID) {
  19415. r += ' PUBLIC "' + node.pubID + '"';
  19416. } else if (node.sysID) {
  19417. r += ' SYSTEM "' + node.sysID + '"';
  19418. }
  19419. r += this.spacebeforeslash + '>' + this.newline;
  19420. return r;
  19421. };
  19422. XMLStringWriter.prototype.openNode = function (node, level) {
  19423. var att, name, r, ref;
  19424. level || (level = 0);
  19425. if (node instanceof XMLElement) {
  19426. r = this.space(level) + '<' + node.name;
  19427. ref = node.attributes;
  19428. for (name in ref) {
  19429. if (!hasProp.call(ref, name)) continue;
  19430. att = ref[name];
  19431. r += this.attribute(att);
  19432. }
  19433. r += (node.children ? '>' : '/>') + this.newline;
  19434. return r;
  19435. } else {
  19436. r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
  19437. if (node.pubID && node.sysID) {
  19438. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  19439. } else if (node.sysID) {
  19440. r += ' SYSTEM "' + node.sysID + '"';
  19441. }
  19442. r += (node.children ? ' [' : '>') + this.newline;
  19443. return r;
  19444. }
  19445. };
  19446. XMLStringWriter.prototype.closeNode = function (node, level) {
  19447. level || (level = 0);
  19448. switch (false) {
  19449. case !(node instanceof XMLElement):
  19450. return this.space(level) + '</' + node.name + '>' + this.newline;
  19451. case !(node instanceof XMLDocType):
  19452. return this.space(level) + ']>' + this.newline;
  19453. }
  19454. };
  19455. return XMLStringWriter;
  19456. }(XMLWriterBase);
  19457. }).call(undefined);
  19458. },{"./XMLCData":205,"./XMLComment":206,"./XMLDTDAttList":207,"./XMLDTDElement":208,"./XMLDTDEntity":209,"./XMLDTDNotation":210,"./XMLDeclaration":211,"./XMLDocType":212,"./XMLElement":215,"./XMLProcessingInstruction":217,"./XMLRaw":218,"./XMLText":222,"./XMLWriterBase":223}],221:[function(require,module,exports){
  19459. 'use strict';
  19460. // Generated by CoffeeScript 1.12.6
  19461. (function () {
  19462. var XMLStringifier,
  19463. bind = function bind(fn, me) {
  19464. return function () {
  19465. return fn.apply(me, arguments);
  19466. };
  19467. },
  19468. hasProp = {}.hasOwnProperty;
  19469. module.exports = XMLStringifier = function () {
  19470. function XMLStringifier(options) {
  19471. this.assertLegalChar = bind(this.assertLegalChar, this);
  19472. var key, ref, value;
  19473. options || (options = {});
  19474. this.noDoubleEncoding = options.noDoubleEncoding;
  19475. ref = options.stringify || {};
  19476. for (key in ref) {
  19477. if (!hasProp.call(ref, key)) continue;
  19478. value = ref[key];
  19479. this[key] = value;
  19480. }
  19481. }
  19482. XMLStringifier.prototype.eleName = function (val) {
  19483. val = '' + val || '';
  19484. return this.assertLegalChar(val);
  19485. };
  19486. XMLStringifier.prototype.eleText = function (val) {
  19487. val = '' + val || '';
  19488. return this.assertLegalChar(this.elEscape(val));
  19489. };
  19490. XMLStringifier.prototype.cdata = function (val) {
  19491. val = '' + val || '';
  19492. val = val.replace(']]>', ']]]]><![CDATA[>');
  19493. return this.assertLegalChar(val);
  19494. };
  19495. XMLStringifier.prototype.comment = function (val) {
  19496. val = '' + val || '';
  19497. if (val.match(/--/)) {
  19498. throw new Error("Comment text cannot contain double-hypen: " + val);
  19499. }
  19500. return this.assertLegalChar(val);
  19501. };
  19502. XMLStringifier.prototype.raw = function (val) {
  19503. return '' + val || '';
  19504. };
  19505. XMLStringifier.prototype.attName = function (val) {
  19506. return val = '' + val || '';
  19507. };
  19508. XMLStringifier.prototype.attValue = function (val) {
  19509. val = '' + val || '';
  19510. return this.attEscape(val);
  19511. };
  19512. XMLStringifier.prototype.insTarget = function (val) {
  19513. return '' + val || '';
  19514. };
  19515. XMLStringifier.prototype.insValue = function (val) {
  19516. val = '' + val || '';
  19517. if (val.match(/\?>/)) {
  19518. throw new Error("Invalid processing instruction value: " + val);
  19519. }
  19520. return val;
  19521. };
  19522. XMLStringifier.prototype.xmlVersion = function (val) {
  19523. val = '' + val || '';
  19524. if (!val.match(/1\.[0-9]+/)) {
  19525. throw new Error("Invalid version number: " + val);
  19526. }
  19527. return val;
  19528. };
  19529. XMLStringifier.prototype.xmlEncoding = function (val) {
  19530. val = '' + val || '';
  19531. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) {
  19532. throw new Error("Invalid encoding: " + val);
  19533. }
  19534. return val;
  19535. };
  19536. XMLStringifier.prototype.xmlStandalone = function (val) {
  19537. if (val) {
  19538. return "yes";
  19539. } else {
  19540. return "no";
  19541. }
  19542. };
  19543. XMLStringifier.prototype.dtdPubID = function (val) {
  19544. return '' + val || '';
  19545. };
  19546. XMLStringifier.prototype.dtdSysID = function (val) {
  19547. return '' + val || '';
  19548. };
  19549. XMLStringifier.prototype.dtdElementValue = function (val) {
  19550. return '' + val || '';
  19551. };
  19552. XMLStringifier.prototype.dtdAttType = function (val) {
  19553. return '' + val || '';
  19554. };
  19555. XMLStringifier.prototype.dtdAttDefault = function (val) {
  19556. if (val != null) {
  19557. return '' + val || '';
  19558. } else {
  19559. return val;
  19560. }
  19561. };
  19562. XMLStringifier.prototype.dtdEntityValue = function (val) {
  19563. return '' + val || '';
  19564. };
  19565. XMLStringifier.prototype.dtdNData = function (val) {
  19566. return '' + val || '';
  19567. };
  19568. XMLStringifier.prototype.convertAttKey = '@';
  19569. XMLStringifier.prototype.convertPIKey = '?';
  19570. XMLStringifier.prototype.convertTextKey = '#text';
  19571. XMLStringifier.prototype.convertCDataKey = '#cdata';
  19572. XMLStringifier.prototype.convertCommentKey = '#comment';
  19573. XMLStringifier.prototype.convertRawKey = '#raw';
  19574. XMLStringifier.prototype.assertLegalChar = function (str) {
  19575. var res;
  19576. res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
  19577. if (res) {
  19578. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  19579. }
  19580. return str;
  19581. };
  19582. XMLStringifier.prototype.elEscape = function (str) {
  19583. var ampregex;
  19584. ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  19585. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  19586. };
  19587. XMLStringifier.prototype.attEscape = function (str) {
  19588. var ampregex;
  19589. ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  19590. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
  19591. };
  19592. return XMLStringifier;
  19593. }();
  19594. }).call(undefined);
  19595. },{}],222:[function(require,module,exports){
  19596. "use strict";
  19597. var _create = require("babel-runtime/core-js/object/create");
  19598. var _create2 = _interopRequireDefault(_create);
  19599. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19600. // Generated by CoffeeScript 1.12.6
  19601. (function () {
  19602. var XMLNode,
  19603. XMLText,
  19604. extend = function extend(child, parent) {
  19605. for (var key in parent) {
  19606. if (hasProp.call(parent, key)) child[key] = parent[key];
  19607. }function ctor() {
  19608. this.constructor = child;
  19609. }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
  19610. },
  19611. hasProp = {}.hasOwnProperty;
  19612. XMLNode = require('./XMLNode');
  19613. module.exports = XMLText = function (superClass) {
  19614. extend(XMLText, superClass);
  19615. function XMLText(parent, text) {
  19616. XMLText.__super__.constructor.call(this, parent);
  19617. if (text == null) {
  19618. throw new Error("Missing element text");
  19619. }
  19620. this.value = this.stringify.eleText(text);
  19621. }
  19622. XMLText.prototype.clone = function () {
  19623. return (0, _create2.default)(this);
  19624. };
  19625. XMLText.prototype.toString = function (options) {
  19626. return this.options.writer.set(options).text(this);
  19627. };
  19628. return XMLText;
  19629. }(XMLNode);
  19630. }).call(undefined);
  19631. },{"./XMLNode":216,"babel-runtime/core-js/object/create":14}],223:[function(require,module,exports){
  19632. 'use strict';
  19633. // Generated by CoffeeScript 1.12.6
  19634. (function () {
  19635. var XMLWriterBase,
  19636. hasProp = {}.hasOwnProperty;
  19637. module.exports = XMLWriterBase = function () {
  19638. function XMLWriterBase(options) {
  19639. var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
  19640. options || (options = {});
  19641. this.pretty = options.pretty || false;
  19642. this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
  19643. if (this.pretty) {
  19644. this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
  19645. this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
  19646. this.offset = (ref3 = options.offset) != null ? ref3 : 0;
  19647. this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
  19648. } else {
  19649. this.indent = '';
  19650. this.newline = '';
  19651. this.offset = 0;
  19652. this.dontprettytextnodes = 0;
  19653. }
  19654. this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
  19655. if (this.spacebeforeslash === true) {
  19656. this.spacebeforeslash = ' ';
  19657. }
  19658. this.newlinedefault = this.newline;
  19659. this.prettydefault = this.pretty;
  19660. ref6 = options.writer || {};
  19661. for (key in ref6) {
  19662. if (!hasProp.call(ref6, key)) continue;
  19663. value = ref6[key];
  19664. this[key] = value;
  19665. }
  19666. }
  19667. XMLWriterBase.prototype.set = function (options) {
  19668. var key, ref, value;
  19669. options || (options = {});
  19670. if ("pretty" in options) {
  19671. this.pretty = options.pretty;
  19672. }
  19673. if ("allowEmpty" in options) {
  19674. this.allowEmpty = options.allowEmpty;
  19675. }
  19676. if (this.pretty) {
  19677. this.indent = "indent" in options ? options.indent : ' ';
  19678. this.newline = "newline" in options ? options.newline : '\n';
  19679. this.offset = "offset" in options ? options.offset : 0;
  19680. this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
  19681. } else {
  19682. this.indent = '';
  19683. this.newline = '';
  19684. this.offset = 0;
  19685. this.dontprettytextnodes = 0;
  19686. }
  19687. this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
  19688. if (this.spacebeforeslash === true) {
  19689. this.spacebeforeslash = ' ';
  19690. }
  19691. this.newlinedefault = this.newline;
  19692. this.prettydefault = this.pretty;
  19693. ref = options.writer || {};
  19694. for (key in ref) {
  19695. if (!hasProp.call(ref, key)) continue;
  19696. value = ref[key];
  19697. this[key] = value;
  19698. }
  19699. return this;
  19700. };
  19701. XMLWriterBase.prototype.space = function (level) {
  19702. var indent;
  19703. if (this.pretty) {
  19704. indent = (level || 0) + this.offset + 1;
  19705. if (indent > 0) {
  19706. return new Array(indent).join(this.indent);
  19707. } else {
  19708. return '';
  19709. }
  19710. } else {
  19711. return '';
  19712. }
  19713. };
  19714. return XMLWriterBase;
  19715. }();
  19716. }).call(undefined);
  19717. },{}],224:[function(require,module,exports){
  19718. 'use strict';
  19719. // Generated by CoffeeScript 1.12.6
  19720. (function () {
  19721. var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
  19722. ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
  19723. XMLDocument = require('./XMLDocument');
  19724. XMLDocumentCB = require('./XMLDocumentCB');
  19725. XMLStringWriter = require('./XMLStringWriter');
  19726. XMLStreamWriter = require('./XMLStreamWriter');
  19727. module.exports.create = function (name, xmldec, doctype, options) {
  19728. var doc, root;
  19729. if (name == null) {
  19730. throw new Error("Root element needs a name");
  19731. }
  19732. options = assign({}, xmldec, doctype, options);
  19733. doc = new XMLDocument(options);
  19734. root = doc.element(name);
  19735. if (!options.headless) {
  19736. doc.declaration(options);
  19737. if (options.pubID != null || options.sysID != null) {
  19738. doc.doctype(options);
  19739. }
  19740. }
  19741. return root;
  19742. };
  19743. module.exports.begin = function (options, onData, onEnd) {
  19744. var ref1;
  19745. if (isFunction(options)) {
  19746. ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
  19747. options = {};
  19748. }
  19749. if (onData) {
  19750. return new XMLDocumentCB(options, onData, onEnd);
  19751. } else {
  19752. return new XMLDocument(options);
  19753. }
  19754. };
  19755. module.exports.stringWriter = function (options) {
  19756. return new XMLStringWriter(options);
  19757. };
  19758. module.exports.streamWriter = function (stream, options) {
  19759. return new XMLStreamWriter(stream, options);
  19760. };
  19761. }).call(undefined);
  19762. },{"./Utility":203,"./XMLDocument":213,"./XMLDocumentCB":214,"./XMLStreamWriter":219,"./XMLStringWriter":220}],225:[function(require,module,exports){
  19763. module.exports = extend
  19764. var hasOwnProperty = Object.prototype.hasOwnProperty;
  19765. function extend() {
  19766. var target = {}
  19767. for (var i = 0; i < arguments.length; i++) {
  19768. var source = arguments[i]
  19769. for (var key in source) {
  19770. if (hasOwnProperty.call(source, key)) {
  19771. target[key] = source[key]
  19772. }
  19773. }
  19774. }
  19775. return target
  19776. }
  19777. },{}],226:[function(require,module,exports){
  19778. 'use strict';
  19779. // use crypto-browserify@1.0.9 to minify dist size
  19780. module.exports = require('crypto-browserify');
  19781. },{"crypto-browserify":136}],227:[function(require,module,exports){
  19782. (function (global){
  19783. "use strict";
  19784. var _create = require("babel-runtime/core-js/object/create");
  19785. var _create2 = _interopRequireDefault(_create);
  19786. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  19787. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  19788. var _createClass2 = require("babel-runtime/helpers/createClass");
  19789. var _createClass3 = _interopRequireDefault(_createClass2);
  19790. var _typeof2 = require("babel-runtime/helpers/typeof");
  19791. var _typeof3 = _interopRequireDefault(_typeof2);
  19792. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19793. (function (f) {
  19794. if ((typeof exports === "undefined" ? "undefined" : (0, _typeof3.default)(exports)) === "object" && typeof module !== "undefined") {
  19795. module.exports = f();
  19796. } else if (typeof define === "function" && define.amd) {
  19797. define([], f);
  19798. } else {
  19799. var g;if (typeof window !== "undefined") {
  19800. g = window;
  19801. } else if (typeof global !== "undefined") {
  19802. g = global;
  19803. } else if (typeof self !== "undefined") {
  19804. g = self;
  19805. } else {
  19806. g = this;
  19807. }g.mime = f();
  19808. }
  19809. })(function () {
  19810. var define, module, exports;return function e(t, n, r) {
  19811. function s(o, u) {
  19812. if (!n[o]) {
  19813. if (!t[o]) {
  19814. 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;
  19815. }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) {
  19816. var n = t[o][1][e];return s(n ? n : e);
  19817. }, l, l.exports, e, t, n, r);
  19818. }return n[o].exports;
  19819. }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) {
  19820. s(r[o]);
  19821. }return s;
  19822. }({ 1: [function (require, module, exports) {
  19823. 'use strict';
  19824. /**
  19825. * @param typeMap [Object] Map of MIME type -> Array[extensions]
  19826. * @param ...
  19827. */
  19828. var Mime = function () {
  19829. function Mime() {
  19830. (0, _classCallCheck3.default)(this, Mime);
  19831. this._types = (0, _create2.default)(null);
  19832. this._extensions = (0, _create2.default)(null);
  19833. for (var i = 0; i < arguments.length; i++) {
  19834. this.define(arguments[i]);
  19835. }
  19836. }
  19837. /**
  19838. * Define mimetype -> xtension mappings. Each key is a mime-type that maps
  19839. * to an array of extensions associated with the type. The first extension is
  19840. * used as the default extension for the type.
  19841. *
  19842. * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
  19843. *
  19844. * @param map (Object) type definitions
  19845. */
  19846. (0, _createClass3.default)(Mime, [{
  19847. key: "define",
  19848. value: function define(typeMap, force) {
  19849. for (var type in typeMap) {
  19850. var extensions = typeMap[type];
  19851. for (var i = 0; i < extensions.length; i++) {
  19852. var ext = extensions[i];
  19853. if (!force && ext in this._types) {
  19854. throw new Error("Attempt to change mapping for \"" + ext + "\" extension from \"" + this._types[ext] + "\" to \"" + type + "\". Pass `force=true` to allow this, otherwise remove \"" + ext + "\" from the list of extensions for \"" + type + "\".");
  19855. }
  19856. this._types[ext] = type;
  19857. }
  19858. // Use first extension as default
  19859. if (force || !this._extensions[type]) {
  19860. this._extensions[type] = extensions[0];
  19861. }
  19862. }
  19863. }
  19864. /**
  19865. * Lookup a mime type based on extension
  19866. */
  19867. }, {
  19868. key: "getType",
  19869. value: function getType(path) {
  19870. path = String(path);
  19871. var last = path.replace(/^.*[/\\]/, '').toLowerCase();
  19872. var ext = last.replace(/^.*\./, '').toLowerCase();
  19873. var hasPath = last.length < path.length;
  19874. var hasDot = ext.length < last.length - 1;
  19875. return (hasDot || !hasPath) && this._types[ext] || null;
  19876. }
  19877. /**
  19878. * Return file extension associated with a mime type
  19879. */
  19880. }, {
  19881. key: "getExtension",
  19882. value: function getExtension(type) {
  19883. type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
  19884. return type && this._extensions[type.toLowerCase()] || null;
  19885. }
  19886. }]);
  19887. return Mime;
  19888. }();
  19889. module.exports = Mime;
  19890. }, {}], 2: [function (r, module, exports) {
  19891. 'use strict';
  19892. var Mime = r('./Mime');
  19893. module.exports = new Mime(r('./types/standard'), r('./types/other'));
  19894. }, { "./Mime": 1, "./types/other": 3, "./types/standard": 4 }], 3: [function (require, module, exports) {
  19895. module.exports = { "application/prs.cww": ["cww"], "application/vnd.3gpp.pic-bw-large": ["plb"], "application/vnd.3gpp.pic-bw-small": ["psb"], "application/vnd.3gpp.pic-bw-var": ["pvb"], "application/vnd.3gpp2.tcap": ["tcap"], "application/vnd.3m.post-it-notes": ["pwn"], "application/vnd.accpac.simply.aso": ["aso"], "application/vnd.accpac.simply.imp": ["imp"], "application/vnd.acucobol": ["acu"], "application/vnd.acucorp": ["atc", "acutc"], "application/vnd.adobe.air-application-installer-package+zip": ["air"], "application/vnd.adobe.formscentral.fcdt": ["fcdt"], "application/vnd.adobe.fxp": ["fxp", "fxpl"], "application/vnd.adobe.xdp+xml": ["xdp"], "application/vnd.adobe.xfdf": ["xfdf"], "application/vnd.ahead.space": ["ahead"], "application/vnd.airzip.filesecure.azf": ["azf"], "application/vnd.airzip.filesecure.azs": ["azs"], "application/vnd.amazon.ebook": ["azw"], "application/vnd.americandynamics.acc": ["acc"], "application/vnd.amiga.ami": ["ami"], "application/vnd.android.package-archive": ["apk"], "application/vnd.anser-web-certificate-issue-initiation": ["cii"], "application/vnd.anser-web-funds-transfer-initiation": ["fti"], "application/vnd.antix.game-component": ["atx"], "application/vnd.apple.installer+xml": ["mpkg"], "application/vnd.apple.mpegurl": ["m3u8"], "application/vnd.apple.pkpass": ["pkpass"], "application/vnd.aristanetworks.swi": ["swi"], "application/vnd.astraea-software.iota": ["iota"], "application/vnd.audiograph": ["aep"], "application/vnd.blueice.multipass": ["mpm"], "application/vnd.bmi": ["bmi"], "application/vnd.businessobjects": ["rep"], "application/vnd.chemdraw+xml": ["cdxml"], "application/vnd.chipnuts.karaoke-mmd": ["mmd"], "application/vnd.cinderella": ["cdy"], "application/vnd.claymore": ["cla"], "application/vnd.cloanto.rp9": ["rp9"], "application/vnd.clonk.c4group": ["c4g", "c4d", "c4f", "c4p", "c4u"], "application/vnd.cluetrust.cartomobile-config": ["c11amc"], "application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"], "application/vnd.commonspace": ["csp"], "application/vnd.contact.cmsg": ["cdbcmsg"], "application/vnd.cosmocaller": ["cmc"], "application/vnd.crick.clicker": ["clkx"], "application/vnd.crick.clicker.keyboard": ["clkk"], "application/vnd.crick.clicker.palette": ["clkp"], "application/vnd.crick.clicker.template": ["clkt"], "application/vnd.crick.clicker.wordbank": ["clkw"], "application/vnd.criticaltools.wbs+xml": ["wbs"], "application/vnd.ctc-posml": ["pml"], "application/vnd.cups-ppd": ["ppd"], "application/vnd.curl.car": ["car"], "application/vnd.curl.pcurl": ["pcurl"], "application/vnd.dart": ["dart"], "application/vnd.data-vision.rdz": ["rdz"], "application/vnd.dece.data": ["uvf", "uvvf", "uvd", "uvvd"], "application/vnd.dece.ttml+xml": ["uvt", "uvvt"], "application/vnd.dece.unspecified": ["uvx", "uvvx"], "application/vnd.dece.zip": ["uvz", "uvvz"], "application/vnd.denovo.fcselayout-link": ["fe_launch"], "application/vnd.dna": ["dna"], "application/vnd.dolby.mlp": ["mlp"], "application/vnd.dpgraph": ["dpg"], "application/vnd.dreamfactory": ["dfac"], "application/vnd.ds-keypoint": ["kpxx"], "application/vnd.dvb.ait": ["ait"], "application/vnd.dvb.service": ["svc"], "application/vnd.dynageo": ["geo"], "application/vnd.ecowin.chart": ["mag"], "application/vnd.enliven": ["nml"], "application/vnd.epson.esf": ["esf"], "application/vnd.epson.msf": ["msf"], "application/vnd.epson.quickanime": ["qam"], "application/vnd.epson.salt": ["slt"], "application/vnd.epson.ssf": ["ssf"], "application/vnd.eszigno3+xml": ["es3", "et3"], "application/vnd.ezpix-album": ["ez2"], "application/vnd.ezpix-package": ["ez3"], "application/vnd.fdf": ["fdf"], "application/vnd.fdsn.mseed": ["mseed"], "application/vnd.fdsn.seed": ["seed", "dataless"], "application/vnd.flographit": ["gph"], "application/vnd.fluxtime.clip": ["ftc"], "application/vnd.framemaker": ["fm", "frame", "maker", "book"], "application/vnd.frogans.fnc": ["fnc"], "application/vnd.frogans.ltf": ["ltf"], "application/vnd.fsc.weblaunch": ["fsc"], "application/vnd.fujitsu.oasys": ["oas"], "application/vnd.fujitsu.oasys2": ["oa2"], "application/vnd.fujitsu.oasys3": ["oa3"], "application/vnd.fujitsu.oasysgp": ["fg5"], "application/vnd.fujitsu.oasysprs": ["bh2"], "application/vnd.fujixerox.ddd": ["ddd"], "application/vnd.fujixerox.docuworks": ["xdw"], "application/vnd.fujixerox.docuworks.binder": ["xbd"], "application/vnd.fuzzysheet": ["fzs"], "application/vnd.genomatix.tuxedo": ["txd"], "application/vnd.geogebra.file": ["ggb"], "application/vnd.geogebra.tool": ["ggt"], "application/vnd.geometry-explorer": ["gex", "gre"], "application/vnd.geonext": ["gxt"], "application/vnd.geoplan": ["g2w"], "application/vnd.geospace": ["g3w"], "application/vnd.gmx": ["gmx"], "application/vnd.google-apps.document": ["gdoc"], "application/vnd.google-apps.presentation": ["gslides"], "application/vnd.google-apps.spreadsheet": ["gsheet"], "application/vnd.google-earth.kml+xml": ["kml"], "application/vnd.google-earth.kmz": ["kmz"], "application/vnd.grafeq": ["gqf", "gqs"], "application/vnd.groove-account": ["gac"], "application/vnd.groove-help": ["ghf"], "application/vnd.groove-identity-message": ["gim"], "application/vnd.groove-injector": ["grv"], "application/vnd.groove-tool-message": ["gtm"], "application/vnd.groove-tool-template": ["tpl"], "application/vnd.groove-vcard": ["vcg"], "application/vnd.hal+xml": ["hal"], "application/vnd.handheld-entertainment+xml": ["zmm"], "application/vnd.hbci": ["hbci"], "application/vnd.hhe.lesson-player": ["les"], "application/vnd.hp-hpgl": ["hpgl"], "application/vnd.hp-hpid": ["hpid"], "application/vnd.hp-hps": ["hps"], "application/vnd.hp-jlyt": ["jlt"], "application/vnd.hp-pcl": ["pcl"], "application/vnd.hp-pclxl": ["pclxl"], "application/vnd.hydrostatix.sof-data": ["sfd-hdstx"], "application/vnd.ibm.minipay": ["mpy"], "application/vnd.ibm.modcap": ["afp", "listafp", "list3820"], "application/vnd.ibm.rights-management": ["irm"], "application/vnd.ibm.secure-container": ["sc"], "application/vnd.iccprofile": ["icc", "icm"], "application/vnd.igloader": ["igl"], "application/vnd.immervision-ivp": ["ivp"], "application/vnd.immervision-ivu": ["ivu"], "application/vnd.insors.igm": ["igm"], "application/vnd.intercon.formnet": ["xpw", "xpx"], "application/vnd.intergeo": ["i2g"], "application/vnd.intu.qbo": ["qbo"], "application/vnd.intu.qfx": ["qfx"], "application/vnd.ipunplugged.rcprofile": ["rcprofile"], "application/vnd.irepository.package+xml": ["irp"], "application/vnd.is-xpr": ["xpr"], "application/vnd.isac.fcs": ["fcs"], "application/vnd.jam": ["jam"], "application/vnd.jcp.javame.midlet-rms": ["rms"], "application/vnd.jisp": ["jisp"], "application/vnd.joost.joda-archive": ["joda"], "application/vnd.kahootz": ["ktz", "ktr"], "application/vnd.kde.karbon": ["karbon"], "application/vnd.kde.kchart": ["chrt"], "application/vnd.kde.kformula": ["kfo"], "application/vnd.kde.kivio": ["flw"], "application/vnd.kde.kontour": ["kon"], "application/vnd.kde.kpresenter": ["kpr", "kpt"], "application/vnd.kde.kspread": ["ksp"], "application/vnd.kde.kword": ["kwd", "kwt"], "application/vnd.kenameaapp": ["htke"], "application/vnd.kidspiration": ["kia"], "application/vnd.kinar": ["kne", "knp"], "application/vnd.koan": ["skp", "skd", "skt", "skm"], "application/vnd.kodak-descriptor": ["sse"], "application/vnd.las.las+xml": ["lasxml"], "application/vnd.llamagraphics.life-balance.desktop": ["lbd"], "application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"], "application/vnd.lotus-1-2-3": ["123"], "application/vnd.lotus-approach": ["apr"], "application/vnd.lotus-freelance": ["pre"], "application/vnd.lotus-notes": ["nsf"], "application/vnd.lotus-organizer": ["org"], "application/vnd.lotus-screencam": ["scm"], "application/vnd.lotus-wordpro": ["lwp"], "application/vnd.macports.portpkg": ["portpkg"], "application/vnd.mcd": ["mcd"], "application/vnd.medcalcdata": ["mc1"], "application/vnd.mediastation.cdkey": ["cdkey"], "application/vnd.mfer": ["mwf"], "application/vnd.mfmp": ["mfm"], "application/vnd.micrografx.flo": ["flo"], "application/vnd.micrografx.igx": ["igx"], "application/vnd.mif": ["mif"], "application/vnd.mobius.daf": ["daf"], "application/vnd.mobius.dis": ["dis"], "application/vnd.mobius.mbk": ["mbk"], "application/vnd.mobius.mqy": ["mqy"], "application/vnd.mobius.msl": ["msl"], "application/vnd.mobius.plc": ["plc"], "application/vnd.mobius.txf": ["txf"], "application/vnd.mophun.application": ["mpn"], "application/vnd.mophun.certificate": ["mpc"], "application/vnd.mozilla.xul+xml": ["xul"], "application/vnd.ms-artgalry": ["cil"], "application/vnd.ms-cab-compressed": ["cab"], "application/vnd.ms-excel": ["xls", "xlm", "xla", "xlc", "xlt", "xlw"], "application/vnd.ms-excel.addin.macroenabled.12": ["xlam"], "application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"], "application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"], "application/vnd.ms-excel.template.macroenabled.12": ["xltm"], "application/vnd.ms-fontobject": ["eot"], "application/vnd.ms-htmlhelp": ["chm"], "application/vnd.ms-ims": ["ims"], "application/vnd.ms-lrm": ["lrm"], "application/vnd.ms-officetheme": ["thmx"], "application/vnd.ms-outlook": ["msg"], "application/vnd.ms-pki.seccat": ["cat"], "application/vnd.ms-pki.stl": ["stl"], "application/vnd.ms-powerpoint": ["ppt", "pps", "pot"], "application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"], "application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"], "application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"], "application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"], "application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"], "application/vnd.ms-project": ["mpp", "mpt"], "application/vnd.ms-word.document.macroenabled.12": ["docm"], "application/vnd.ms-word.template.macroenabled.12": ["dotm"], "application/vnd.ms-works": ["wps", "wks", "wcm", "wdb"], "application/vnd.ms-wpl": ["wpl"], "application/vnd.ms-xpsdocument": ["xps"], "application/vnd.mseq": ["mseq"], "application/vnd.musician": ["mus"], "application/vnd.muvee.style": ["msty"], "application/vnd.mynfc": ["taglet"], "application/vnd.neurolanguage.nlu": ["nlu"], "application/vnd.nitf": ["ntf", "nitf"], "application/vnd.noblenet-directory": ["nnd"], "application/vnd.noblenet-sealer": ["nns"], "application/vnd.noblenet-web": ["nnw"], "application/vnd.nokia.n-gage.data": ["ngdat"], "application/vnd.nokia.n-gage.symbian.install": ["n-gage"], "application/vnd.nokia.radio-preset": ["rpst"], "application/vnd.nokia.radio-presets": ["rpss"], "application/vnd.novadigm.edm": ["edm"], "application/vnd.novadigm.edx": ["edx"], "application/vnd.novadigm.ext": ["ext"], "application/vnd.oasis.opendocument.chart": ["odc"], "application/vnd.oasis.opendocument.chart-template": ["otc"], "application/vnd.oasis.opendocument.database": ["odb"], "application/vnd.oasis.opendocument.formula": ["odf"], "application/vnd.oasis.opendocument.formula-template": ["odft"], "application/vnd.oasis.opendocument.graphics": ["odg"], "application/vnd.oasis.opendocument.graphics-template": ["otg"], "application/vnd.oasis.opendocument.image": ["odi"], "application/vnd.oasis.opendocument.image-template": ["oti"], "application/vnd.oasis.opendocument.presentation": ["odp"], "application/vnd.oasis.opendocument.presentation-template": ["otp"], "application/vnd.oasis.opendocument.spreadsheet": ["ods"], "application/vnd.oasis.opendocument.spreadsheet-template": ["ots"], "application/vnd.oasis.opendocument.text": ["odt"], "application/vnd.oasis.opendocument.text-master": ["odm"], "application/vnd.oasis.opendocument.text-template": ["ott"], "application/vnd.oasis.opendocument.text-web": ["oth"], "application/vnd.olpc-sugar": ["xo"], "application/vnd.oma.dd2+xml": ["dd2"], "application/vnd.openofficeorg.extension": ["oxt"], "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"], "application/vnd.openxmlformats-officedocument.presentationml.slide": ["sldx"], "application/vnd.openxmlformats-officedocument.presentationml.slideshow": ["ppsx"], "application/vnd.openxmlformats-officedocument.presentationml.template": ["potx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"], "application/vnd.openxmlformats-officedocument.spreadsheetml.template": ["xltx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"], "application/vnd.openxmlformats-officedocument.wordprocessingml.template": ["dotx"], "application/vnd.osgeo.mapguide.package": ["mgp"], "application/vnd.osgi.dp": ["dp"], "application/vnd.osgi.subsystem": ["esa"], "application/vnd.palm": ["pdb", "pqa", "oprc"], "application/vnd.pawaafile": ["paw"], "application/vnd.pg.format": ["str"], "application/vnd.pg.osasli": ["ei6"], "application/vnd.picsel": ["efif"], "application/vnd.pmi.widget": ["wg"], "application/vnd.pocketlearn": ["plf"], "application/vnd.powerbuilder6": ["pbd"], "application/vnd.previewsystems.box": ["box"], "application/vnd.proteus.magazine": ["mgz"], "application/vnd.publishare-delta-tree": ["qps"], "application/vnd.pvi.ptid1": ["ptid"], "application/vnd.quark.quarkxpress": ["qxd", "qxt", "qwd", "qwt", "qxl", "qxb"], "application/vnd.realvnc.bed": ["bed"], "application/vnd.recordare.musicxml": ["mxl"], "application/vnd.recordare.musicxml+xml": ["musicxml"], "application/vnd.rig.cryptonote": ["cryptonote"], "application/vnd.rim.cod": ["cod"], "application/vnd.rn-realmedia": ["rm"], "application/vnd.rn-realmedia-vbr": ["rmvb"], "application/vnd.route66.link66+xml": ["link66"], "application/vnd.sailingtracker.track": ["st"], "application/vnd.seemail": ["see"], "application/vnd.sema": ["sema"], "application/vnd.semd": ["semd"], "application/vnd.semf": ["semf"], "application/vnd.shana.informed.formdata": ["ifm"], "application/vnd.shana.informed.formtemplate": ["itp"], "application/vnd.shana.informed.interchange": ["iif"], "application/vnd.shana.informed.package": ["ipk"], "application/vnd.simtech-mindmapper": ["twd", "twds"], "application/vnd.smaf": ["mmf"], "application/vnd.smart.teacher": ["teacher"], "application/vnd.solent.sdkm+xml": ["sdkm", "sdkd"], "application/vnd.spotfire.dxp": ["dxp"], "application/vnd.spotfire.sfs": ["sfs"], "application/vnd.stardivision.calc": ["sdc"], "application/vnd.stardivision.draw": ["sda"], "application/vnd.stardivision.impress": ["sdd"], "application/vnd.stardivision.math": ["smf"], "application/vnd.stardivision.writer": ["sdw", "vor"], "application/vnd.stardivision.writer-global": ["sgl"], "application/vnd.stepmania.package": ["smzip"], "application/vnd.stepmania.stepchart": ["sm"], "application/vnd.sun.wadl+xml": ["wadl"], "application/vnd.sun.xml.calc": ["sxc"], "application/vnd.sun.xml.calc.template": ["stc"], "application/vnd.sun.xml.draw": ["sxd"], "application/vnd.sun.xml.draw.template": ["std"], "application/vnd.sun.xml.impress": ["sxi"], "application/vnd.sun.xml.impress.template": ["sti"], "application/vnd.sun.xml.math": ["sxm"], "application/vnd.sun.xml.writer": ["sxw"], "application/vnd.sun.xml.writer.global": ["sxg"], "application/vnd.sun.xml.writer.template": ["stw"], "application/vnd.sus-calendar": ["sus", "susp"], "application/vnd.svd": ["svd"], "application/vnd.symbian.install": ["sis", "sisx"], "application/vnd.syncml+xml": ["xsm"], "application/vnd.syncml.dm+wbxml": ["bdm"], "application/vnd.syncml.dm+xml": ["xdm"], "application/vnd.tao.intent-module-archive": ["tao"], "application/vnd.tcpdump.pcap": ["pcap", "cap", "dmp"], "application/vnd.tmobile-livetv": ["tmo"], "application/vnd.trid.tpt": ["tpt"], "application/vnd.triscape.mxs": ["mxs"], "application/vnd.trueapp": ["tra"], "application/vnd.ufdl": ["ufd", "ufdl"], "application/vnd.uiq.theme": ["utz"], "application/vnd.umajin": ["umj"], "application/vnd.unity": ["unityweb"], "application/vnd.uoml+xml": ["uoml"], "application/vnd.vcx": ["vcx"], "application/vnd.visio": ["vsd", "vst", "vss", "vsw"], "application/vnd.visionary": ["vis"], "application/vnd.vsf": ["vsf"], "application/vnd.wap.wbxml": ["wbxml"], "application/vnd.wap.wmlc": ["wmlc"], "application/vnd.wap.wmlscriptc": ["wmlsc"], "application/vnd.webturbo": ["wtb"], "application/vnd.wolfram.player": ["nbp"], "application/vnd.wordperfect": ["wpd"], "application/vnd.wqd": ["wqd"], "application/vnd.wt.stf": ["stf"], "application/vnd.xara": ["xar"], "application/vnd.xfdl": ["xfdl"], "application/vnd.yamaha.hv-dic": ["hvd"], "application/vnd.yamaha.hv-script": ["hvs"], "application/vnd.yamaha.hv-voice": ["hvp"], "application/vnd.yamaha.openscoreformat": ["osf"], "application/vnd.yamaha.openscoreformat.osfpvg+xml": ["osfpvg"], "application/vnd.yamaha.smaf-audio": ["saf"], "application/vnd.yamaha.smaf-phrase": ["spf"], "application/vnd.yellowriver-custom-menu": ["cmp"], "application/vnd.zul": ["zir", "zirz"], "application/vnd.zzazz.deck+xml": ["zaz"], "application/x-7z-compressed": ["7z"], "application/x-abiword": ["abw"], "application/x-ace-compressed": ["ace"], "application/x-apple-diskimage": [], "application/x-arj": ["arj"], "application/x-authorware-bin": ["aab", "x32", "u32", "vox"], "application/x-authorware-map": ["aam"], "application/x-authorware-seg": ["aas"], "application/x-bcpio": ["bcpio"], "application/x-bdoc": [], "application/x-bittorrent": ["torrent"], "application/x-blorb": ["blb", "blorb"], "application/x-bzip": ["bz"], "application/x-bzip2": ["bz2", "boz"], "application/x-cbr": ["cbr", "cba", "cbt", "cbz", "cb7"], "application/x-cdlink": ["vcd"], "application/x-cfs-compressed": ["cfs"], "application/x-chat": ["chat"], "application/x-chess-pgn": ["pgn"], "application/x-chrome-extension": ["crx"], "application/x-cocoa": ["cco"], "application/x-conference": ["nsc"], "application/x-cpio": ["cpio"], "application/x-csh": ["csh"], "application/x-debian-package": ["udeb"], "application/x-dgc-compressed": ["dgc"], "application/x-director": ["dir", "dcr", "dxr", "cst", "cct", "cxt", "w3d", "fgd", "swa"], "application/x-doom": ["wad"], "application/x-dtbncx+xml": ["ncx"], "application/x-dtbook+xml": ["dtb"], "application/x-dtbresource+xml": ["res"], "application/x-dvi": ["dvi"], "application/x-envoy": ["evy"], "application/x-eva": ["eva"], "application/x-font-bdf": ["bdf"], "application/x-font-ghostscript": ["gsf"], "application/x-font-linux-psf": ["psf"], "application/x-font-otf": [], "application/x-font-pcf": ["pcf"], "application/x-font-snf": ["snf"], "application/x-font-ttf": ["ttf", "ttc"], "application/x-font-type1": ["pfa", "pfb", "pfm", "afm"], "application/x-freearc": ["arc"], "application/x-futuresplash": ["spl"], "application/x-gca-compressed": ["gca"], "application/x-glulx": ["ulx"], "application/x-gnumeric": ["gnumeric"], "application/x-gramps-xml": ["gramps"], "application/x-gtar": ["gtar"], "application/x-hdf": ["hdf"], "application/x-httpd-php": ["php"], "application/x-install-instructions": ["install"], "application/x-iso9660-image": [], "application/x-java-archive-diff": ["jardiff"], "application/x-java-jnlp-file": ["jnlp"], "application/x-latex": ["latex"], "application/x-lua-bytecode": ["luac"], "application/x-lzh-compressed": ["lzh", "lha"], "application/x-makeself": ["run"], "application/x-mie": ["mie"], "application/x-mobipocket-ebook": ["prc", "mobi"], "application/x-ms-application": ["application"], "application/x-ms-shortcut": ["lnk"], "application/x-ms-wmd": ["wmd"], "application/x-ms-wmz": ["wmz"], "application/x-ms-xbap": ["xbap"], "application/x-msaccess": ["mdb"], "application/x-msbinder": ["obd"], "application/x-mscardfile": ["crd"], "application/x-msclip": ["clp"], "application/x-msdos-program": [], "application/x-msdownload": ["com", "bat"], "application/x-msmediaview": ["mvb", "m13", "m14"], "application/x-msmetafile": ["wmf", "emf", "emz"], "application/x-msmoney": ["mny"], "application/x-mspublisher": ["pub"], "application/x-msschedule": ["scd"], "application/x-msterminal": ["trm"], "application/x-mswrite": ["wri"], "application/x-netcdf": ["nc", "cdf"], "application/x-ns-proxy-autoconfig": ["pac"], "application/x-nzb": ["nzb"], "application/x-perl": ["pl", "pm"], "application/x-pilot": [], "application/x-pkcs12": ["p12", "pfx"], "application/x-pkcs7-certificates": ["p7b", "spc"], "application/x-pkcs7-certreqresp": ["p7r"], "application/x-rar-compressed": ["rar"], "application/x-redhat-package-manager": ["rpm"], "application/x-research-info-systems": ["ris"], "application/x-sea": ["sea"], "application/x-sh": ["sh"], "application/x-shar": ["shar"], "application/x-shockwave-flash": ["swf"], "application/x-silverlight-app": ["xap"], "application/x-sql": ["sql"], "application/x-stuffit": ["sit"], "application/x-stuffitx": ["sitx"], "application/x-subrip": ["srt"], "application/x-sv4cpio": ["sv4cpio"], "application/x-sv4crc": ["sv4crc"], "application/x-t3vm-image": ["t3"], "application/x-tads": ["gam"], "application/x-tar": ["tar"], "application/x-tcl": ["tcl", "tk"], "application/x-tex": ["tex"], "application/x-tex-tfm": ["tfm"], "application/x-texinfo": ["texinfo", "texi"], "application/x-tgif": ["obj"], "application/x-ustar": ["ustar"], "application/x-virtualbox-hdd": ["hdd"], "application/x-virtualbox-ova": ["ova"], "application/x-virtualbox-ovf": ["ovf"], "application/x-virtualbox-vbox": ["vbox"], "application/x-virtualbox-vbox-extpack": ["vbox-extpack"], "application/x-virtualbox-vdi": ["vdi"], "application/x-virtualbox-vhd": ["vhd"], "application/x-virtualbox-vmdk": ["vmdk"], "application/x-wais-source": ["src"], "application/x-web-app-manifest+json": ["webapp"], "application/x-x509-ca-cert": ["der", "crt", "pem"], "application/x-xfig": ["fig"], "application/x-xliff+xml": ["xlf"], "application/x-xpinstall": ["xpi"], "application/x-xz": ["xz"], "application/x-zmachine": ["z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8"], "audio/vnd.dece.audio": ["uva", "uvva"], "audio/vnd.digital-winds": ["eol"], "audio/vnd.dra": ["dra"], "audio/vnd.dts": ["dts"], "audio/vnd.dts.hd": ["dtshd"], "audio/vnd.lucent.voice": ["lvp"], "audio/vnd.ms-playready.media.pya": ["pya"], "audio/vnd.nuera.ecelp4800": ["ecelp4800"], "audio/vnd.nuera.ecelp7470": ["ecelp7470"], "audio/vnd.nuera.ecelp9600": ["ecelp9600"], "audio/vnd.rip": ["rip"], "audio/x-aac": ["aac"], "audio/x-aiff": ["aif", "aiff", "aifc"], "audio/x-caf": ["caf"], "audio/x-flac": ["flac"], "audio/x-m4a": [], "audio/x-matroska": ["mka"], "audio/x-mpegurl": ["m3u"], "audio/x-ms-wax": ["wax"], "audio/x-ms-wma": ["wma"], "audio/x-pn-realaudio": ["ram", "ra"], "audio/x-pn-realaudio-plugin": ["rmp"], "audio/x-realaudio": [], "audio/x-wav": [], "chemical/x-cdx": ["cdx"], "chemical/x-cif": ["cif"], "chemical/x-cmdf": ["cmdf"], "chemical/x-cml": ["cml"], "chemical/x-csml": ["csml"], "chemical/x-xyz": ["xyz"], "image/prs.btif": ["btif"], "image/vnd.adobe.photoshop": ["psd"], "image/vnd.dece.graphic": ["uvi", "uvvi", "uvg", "uvvg"], "image/vnd.djvu": ["djvu", "djv"], "image/vnd.dvb.subtitle": [], "image/vnd.dwg": ["dwg"], "image/vnd.dxf": ["dxf"], "image/vnd.fastbidsheet": ["fbs"], "image/vnd.fpx": ["fpx"], "image/vnd.fst": ["fst"], "image/vnd.fujixerox.edmics-mmr": ["mmr"], "image/vnd.fujixerox.edmics-rlc": ["rlc"], "image/vnd.ms-modi": ["mdi"], "image/vnd.ms-photo": ["wdp"], "image/vnd.net-fpx": ["npx"], "image/vnd.wap.wbmp": ["wbmp"], "image/vnd.xiff": ["xif"], "image/x-3ds": ["3ds"], "image/x-cmu-raster": ["ras"], "image/x-cmx": ["cmx"], "image/x-freehand": ["fh", "fhc", "fh4", "fh5", "fh7"], "image/x-icon": ["ico"], "image/x-jng": ["jng"], "image/x-mrsid-image": ["sid"], "image/x-ms-bmp": [], "image/x-pcx": ["pcx"], "image/x-pict": ["pic", "pct"], "image/x-portable-anymap": ["pnm"], "image/x-portable-bitmap": ["pbm"], "image/x-portable-graymap": ["pgm"], "image/x-portable-pixmap": ["ppm"], "image/x-rgb": ["rgb"], "image/x-tga": ["tga"], "image/x-xbitmap": ["xbm"], "image/x-xpixmap": ["xpm"], "image/x-xwindowdump": ["xwd"], "model/vnd.collada+xml": ["dae"], "model/vnd.dwf": ["dwf"], "model/vnd.gdl": ["gdl"], "model/vnd.gtw": ["gtw"], "model/vnd.mts": ["mts"], "model/vnd.vtu": ["vtu"], "text/prs.lines.tag": ["dsc"], "text/vnd.curl": ["curl"], "text/vnd.curl.dcurl": ["dcurl"], "text/vnd.curl.mcurl": ["mcurl"], "text/vnd.curl.scurl": ["scurl"], "text/vnd.dvb.subtitle": ["sub"], "text/vnd.fly": ["fly"], "text/vnd.fmi.flexstor": ["flx"], "text/vnd.graphviz": ["gv"], "text/vnd.in3d.3dml": ["3dml"], "text/vnd.in3d.spot": ["spot"], "text/vnd.sun.j2me.app-descriptor": ["jad"], "text/vnd.wap.wml": ["wml"], "text/vnd.wap.wmlscript": ["wmls"], "text/x-asm": ["s", "asm"], "text/x-c": ["c", "cc", "cxx", "cpp", "h", "hh", "dic"], "text/x-component": ["htc"], "text/x-fortran": ["f", "for", "f77", "f90"], "text/x-handlebars-template": ["hbs"], "text/x-java-source": ["java"], "text/x-lua": ["lua"], "text/x-markdown": ["mkd"], "text/x-nfo": ["nfo"], "text/x-opml": ["opml"], "text/x-org": [], "text/x-pascal": ["p", "pas"], "text/x-processing": ["pde"], "text/x-sass": ["sass"], "text/x-scss": ["scss"], "text/x-setext": ["etx"], "text/x-sfv": ["sfv"], "text/x-suse-ymp": ["ymp"], "text/x-uuencode": ["uu"], "text/x-vcalendar": ["vcs"], "text/x-vcard": ["vcf"], "video/vnd.dece.hd": ["uvh", "uvvh"], "video/vnd.dece.mobile": ["uvm", "uvvm"], "video/vnd.dece.pd": ["uvp", "uvvp"], "video/vnd.dece.sd": ["uvs", "uvvs"], "video/vnd.dece.video": ["uvv", "uvvv"], "video/vnd.dvb.file": ["dvb"], "video/vnd.fvt": ["fvt"], "video/vnd.mpegurl": ["mxu", "m4u"], "video/vnd.ms-playready.media.pyv": ["pyv"], "video/vnd.uvvu.mp4": ["uvu", "uvvu"], "video/vnd.vivo": ["viv"], "video/x-f4v": ["f4v"], "video/x-fli": ["fli"], "video/x-flv": ["flv"], "video/x-m4v": ["m4v"], "video/x-matroska": ["mkv", "mk3d", "mks"], "video/x-mng": ["mng"], "video/x-ms-asf": ["asf", "asx"], "video/x-ms-vob": ["vob"], "video/x-ms-wm": ["wm"], "video/x-ms-wmv": ["wmv"], "video/x-ms-wmx": ["wmx"], "video/x-ms-wvx": ["wvx"], "video/x-msvideo": ["avi"], "video/x-sgi-movie": ["movie"], "video/x-smv": ["smv"], "x-conference/x-cooltalk": ["ice"] };
  19896. }, {}], 4: [function (require, module, exports) {
  19897. module.exports = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomsvc+xml": ["atomsvc"], "application/bdoc": ["bdoc"], "application/ccxml+xml": ["ccxml"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/font-tdpfr": ["pfr"], "application/font-woff": ["woff"], "application/font-woff2": ["woff2"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/pskc+xml": ["pskcxml"], "application/rdf+xml": ["rdf"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/voicexml+xml": ["vxml"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-diff+xml": ["xdf"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": [], "audio/adpcm": ["adp"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mp3": [], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": [], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/otf": ["otf"], "image/apng": ["apng"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/ief": ["ief"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/ktx": ["ktx"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/tiff": ["tiff", "tif"], "image/webp": ["webp"], "message/rfc822": ["eml", "mime"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["x3db", "x3dbz"], "model/x3d+vrml": ["x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/hjson": ["hjson"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": [], "text/sgml": ["sgml", "sgm"], "text/slim": ["slim", "slm"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": [], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/jpeg": ["jpgv"], "video/jpm": ["jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
  19898. }, {}] }, {}, [2])(2);
  19899. });
  19900. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  19901. },{"babel-runtime/core-js/object/create":14,"babel-runtime/helpers/classCallCheck":24,"babel-runtime/helpers/createClass":25,"babel-runtime/helpers/typeof":26}],228:[function(require,module,exports){
  19902. 'use strict';
  19903. // copy from https://github.com/node-modules/utility for browser
  19904. exports.encodeURIComponent = function (text) {
  19905. try {
  19906. return encodeURIComponent(text);
  19907. } catch (e) {
  19908. return text;
  19909. }
  19910. };
  19911. exports.escape = require('escape-html');
  19912. exports.timestamp = function timestamp(t) {
  19913. if (t) {
  19914. var v = t;
  19915. if (typeof v === 'string') {
  19916. v = Number(v);
  19917. }
  19918. if (String(t).length === 10) {
  19919. v *= 1000;
  19920. }
  19921. return new Date(v);
  19922. }
  19923. return Math.round(Date.now() / 1000);
  19924. };
  19925. },{"escape-html":144}],229:[function(require,module,exports){
  19926. (function (process,Buffer){
  19927. 'use strict';
  19928. var _stringify = require('babel-runtime/core-js/json/stringify');
  19929. var _stringify2 = _interopRequireDefault(_stringify);
  19930. var _typeof2 = require('babel-runtime/helpers/typeof');
  19931. var _typeof3 = _interopRequireDefault(_typeof2);
  19932. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19933. var util = require('util');
  19934. var urlutil = require('url');
  19935. var http = require('http');
  19936. var https = require('https');
  19937. var debug = require('debug')('urllib');
  19938. var ms = require('humanize-ms');
  19939. var _Promise;
  19940. var REQUEST_ID = 0;
  19941. var MAX_VALUE = Math.pow(2, 31) - 10;
  19942. var PROTO_RE = /^https?:\/\//i;
  19943. function getAgent(agent, defaultAgent) {
  19944. return agent === undefined ? defaultAgent : agent;
  19945. }
  19946. function makeCallback(resolve, reject) {
  19947. return function (err, data, res) {
  19948. if (err) {
  19949. return reject(err);
  19950. }
  19951. resolve({
  19952. data: data,
  19953. status: res.statusCode,
  19954. headers: res.headers,
  19955. res: res
  19956. });
  19957. };
  19958. }
  19959. exports.TIMEOUT = ms('5s');
  19960. exports.TIMEOUTS = [ms('5s'), ms('5s')];
  19961. var TEXT_DATA_TYPES = ['json', 'text'];
  19962. exports.request = function request(url, args, callback) {
  19963. // request(url, callback)
  19964. if (arguments.length === 2 && typeof args === 'function') {
  19965. callback = args;
  19966. args = null;
  19967. }
  19968. if (typeof callback === 'function') {
  19969. return exports.requestWithCallback(url, args, callback);
  19970. }
  19971. // Promise
  19972. if (!_Promise) {
  19973. _Promise = require('any-promise');
  19974. }
  19975. return new _Promise(function (resolve, reject) {
  19976. exports.requestWithCallback(url, args, makeCallback(resolve, reject));
  19977. });
  19978. };
  19979. exports.requestWithCallback = function requestWithCallback(url, args, callback) {
  19980. // requestWithCallback(url, callback)
  19981. if (!url || typeof url !== 'string' && (typeof url === 'undefined' ? 'undefined' : (0, _typeof3.default)(url)) !== 'object') {
  19982. var msg = util.format('expect request url to be a string or a http request options, but got %j', url);
  19983. throw new Error(msg);
  19984. }
  19985. if (arguments.length === 2 && typeof args === 'function') {
  19986. callback = args;
  19987. args = null;
  19988. }
  19989. args = args || {};
  19990. if (REQUEST_ID >= MAX_VALUE) {
  19991. REQUEST_ID = 0;
  19992. }
  19993. var reqId = ++REQUEST_ID;
  19994. args.requestUrls = args.requestUrls || [];
  19995. var reqMeta = {
  19996. requestId: reqId,
  19997. url: url,
  19998. args: args,
  19999. ctx: args.ctx
  20000. };
  20001. if (args.emitter) {
  20002. args.emitter.emit('request', reqMeta);
  20003. }
  20004. args.timeout = args.timeout || exports.TIMEOUTS;
  20005. args.maxRedirects = args.maxRedirects || 10;
  20006. args.streaming = args.streaming || args.customResponse;
  20007. var requestStartTime = Date.now();
  20008. var parsedUrl;
  20009. if (typeof url === 'string') {
  20010. if (!PROTO_RE.test(url)) {
  20011. // Support `request('www.server.com')`
  20012. url = 'http://' + url;
  20013. }
  20014. parsedUrl = urlutil.parse(url);
  20015. } else {
  20016. parsedUrl = url;
  20017. }
  20018. var method = (args.type || args.method || parsedUrl.method || 'GET').toUpperCase();
  20019. var port = parsedUrl.port || 80;
  20020. var httplib = http;
  20021. var agent = getAgent(args.agent, exports.agent);
  20022. var fixJSONCtlChars = args.fixJSONCtlChars;
  20023. if (parsedUrl.protocol === 'https:') {
  20024. httplib = https;
  20025. agent = getAgent(args.httpsAgent, exports.httpsAgent);
  20026. if (!parsedUrl.port) {
  20027. port = 443;
  20028. }
  20029. }
  20030. // request through proxy tunnel
  20031. // var proxyTunnelAgent = detectProxyAgent(parsedUrl, args);
  20032. // if (proxyTunnelAgent) {
  20033. // agent = proxyTunnelAgent;
  20034. // }
  20035. var options = {
  20036. host: parsedUrl.hostname || parsedUrl.host || 'localhost',
  20037. path: parsedUrl.path || '/',
  20038. method: method,
  20039. port: port,
  20040. agent: agent,
  20041. headers: args.headers || {},
  20042. // default is dns.lookup
  20043. // https://github.com/nodejs/node/blob/master/lib/net.js#L986
  20044. // custom dnslookup require node >= 4.0.0
  20045. // https://github.com/nodejs/node/blob/archived-io.js-v0.12/lib/net.js#L952
  20046. lookup: args.lookup
  20047. };
  20048. if (args.timeout) {
  20049. options.timeout = args.timeout;
  20050. }
  20051. var sslNames = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'secureProtocol', 'secureOptions'];
  20052. for (var i = 0; i < sslNames.length; i++) {
  20053. var name = sslNames[i];
  20054. if (args.hasOwnProperty(name)) {
  20055. options[name] = args[name];
  20056. }
  20057. }
  20058. // don't check ssl
  20059. if (options.rejectUnauthorized === false && !options.hasOwnProperty('secureOptions')) {
  20060. options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
  20061. }
  20062. var auth = args.auth || parsedUrl.auth;
  20063. if (auth) {
  20064. options.auth = auth;
  20065. }
  20066. var body = args.content || args.data;
  20067. var dataAsQueryString = method === 'GET' || method === 'HEAD' || args.dataAsQueryString;
  20068. if (!args.content) {
  20069. if (body && !(typeof body === 'string' || Buffer.isBuffer(body))) {
  20070. if (dataAsQueryString) {
  20071. // read: GET, HEAD, use query string
  20072. body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
  20073. } else {
  20074. var contentType = options.headers['Content-Type'] || options.headers['content-type'];
  20075. // auto add application/x-www-form-urlencoded when using urlencode form request
  20076. if (!contentType) {
  20077. if (args.contentType === 'json') {
  20078. contentType = 'application/json';
  20079. } else {
  20080. contentType = 'application/x-www-form-urlencoded';
  20081. }
  20082. options.headers['Content-Type'] = contentType;
  20083. }
  20084. if (parseContentType(contentType).type === 'application/json') {
  20085. body = (0, _stringify2.default)(body);
  20086. } else {
  20087. // 'application/x-www-form-urlencoded'
  20088. body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
  20089. }
  20090. }
  20091. }
  20092. }
  20093. // if it's a GET or HEAD request, data should be sent as query string
  20094. if (dataAsQueryString && body) {
  20095. options.path += (parsedUrl.query ? '&' : '?') + body;
  20096. body = null;
  20097. }
  20098. var requestSize = 0;
  20099. if (body) {
  20100. var length = body.length;
  20101. if (!Buffer.isBuffer(body)) {
  20102. length = Buffer.byteLength(body);
  20103. }
  20104. requestSize = options.headers['Content-Length'] = length;
  20105. }
  20106. if (args.dataType === 'json') {
  20107. options.headers.Accept = 'application/json';
  20108. }
  20109. if (typeof args.beforeRequest === 'function') {
  20110. // you can use this hook to change every thing.
  20111. args.beforeRequest(options);
  20112. }
  20113. var connectTimer = null;
  20114. var responseTimer = null;
  20115. var __err = null;
  20116. var connected = false; // socket connected or not
  20117. var keepAliveSocket = false; // request with keepalive socket
  20118. var responseSize = 0;
  20119. var statusCode = -1;
  20120. var responseAborted = false;
  20121. var remoteAddress = '';
  20122. var remotePort = '';
  20123. var timing = null;
  20124. if (args.timing) {
  20125. timing = {
  20126. // socket assigned
  20127. queuing: 0,
  20128. // dns lookup time
  20129. dnslookup: 0,
  20130. // socket connected
  20131. connected: 0,
  20132. // request sent
  20133. requestSent: 0,
  20134. // Time to first byte (TTFB)
  20135. waiting: 0,
  20136. contentDownload: 0
  20137. };
  20138. }
  20139. function cancelConnectTimer() {
  20140. if (connectTimer) {
  20141. clearTimeout(connectTimer);
  20142. connectTimer = null;
  20143. }
  20144. }
  20145. function cancelResponseTimer() {
  20146. if (responseTimer) {
  20147. clearTimeout(responseTimer);
  20148. responseTimer = null;
  20149. }
  20150. }
  20151. function done(err, data, res) {
  20152. cancelResponseTimer();
  20153. if (!callback) {
  20154. console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s %s callback twice!!!', Date(), reqId, process.pid, options.method, url);
  20155. // https://github.com/node-modules/urllib/pull/30
  20156. if (err) {
  20157. console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s: %s\nstack: %s', Date(), reqId, process.pid, err.name, err.message, err.stack);
  20158. }
  20159. return;
  20160. }
  20161. var cb = callback;
  20162. callback = null;
  20163. var headers = {};
  20164. if (res) {
  20165. statusCode = res.statusCode;
  20166. headers = res.headers;
  20167. }
  20168. // handle digest auth
  20169. if (statusCode === 401 && headers['www-authenticate'] && (!args.headers || !args.headers.Authorization) && args.digestAuth) {
  20170. var authenticate = headers['www-authenticate'];
  20171. if (authenticate.indexOf('Digest ') >= 0) {
  20172. debug('Request#%d %s: got digest auth header WWW-Authenticate: %s', reqId, url, authenticate);
  20173. args.headers = args.headers || {};
  20174. args.headers.Authorization = digestAuthHeader(options.method, options.path, authenticate, args.digestAuth);
  20175. debug('Request#%d %s: auth with digest header: %s', reqId, url, args.headers.Authorization);
  20176. if (res.headers['set-cookie']) {
  20177. args.headers.Cookie = res.headers['set-cookie'].join(';');
  20178. }
  20179. return exports.requestWithCallback(url, args, cb);
  20180. }
  20181. }
  20182. var requestUseTime = Date.now() - requestStartTime;
  20183. if (timing) {
  20184. timing.contentDownload = requestUseTime;
  20185. }
  20186. debug('[%sms] done, %s bytes HTTP %s %s %s %s, keepAliveSocket: %s, timing: %j', requestUseTime, responseSize, statusCode, options.method, options.host, options.path, keepAliveSocket, timing);
  20187. var response = {
  20188. status: statusCode,
  20189. statusCode: statusCode,
  20190. headers: headers,
  20191. size: responseSize,
  20192. aborted: responseAborted,
  20193. rt: requestUseTime,
  20194. keepAliveSocket: keepAliveSocket,
  20195. data: data,
  20196. requestUrls: args.requestUrls,
  20197. timing: timing,
  20198. remoteAddress: remoteAddress,
  20199. remotePort: remotePort
  20200. };
  20201. if (err) {
  20202. var agentStatus = '';
  20203. if (agent && typeof agent.getCurrentStatus === 'function') {
  20204. // add current agent status to error message for logging and debug
  20205. agentStatus = ', agent status: ' + (0, _stringify2.default)(agent.getCurrentStatus());
  20206. }
  20207. err.message += ', ' + options.method + ' ' + url + ' ' + statusCode + ' (connected: ' + connected + ', keepalive socket: ' + keepAliveSocket + agentStatus + ')' + '\nheaders: ' + (0, _stringify2.default)(headers);
  20208. err.data = data;
  20209. err.path = options.path;
  20210. err.status = statusCode;
  20211. err.headers = headers;
  20212. err.res = response;
  20213. }
  20214. cb(err, data, args.streaming ? res : response);
  20215. if (args.emitter) {
  20216. // keep to use the same reqMeta object on request event before
  20217. reqMeta.url = url;
  20218. reqMeta.socket = req && req.connection;
  20219. reqMeta.options = options;
  20220. reqMeta.size = requestSize;
  20221. args.emitter.emit('response', {
  20222. requestId: reqId,
  20223. error: err,
  20224. ctx: args.ctx,
  20225. req: reqMeta,
  20226. res: response
  20227. });
  20228. }
  20229. }
  20230. function handleRedirect(res) {
  20231. var err = null;
  20232. if (args.followRedirect && statuses.redirect[res.statusCode]) {
  20233. // handle redirect
  20234. args._followRedirectCount = (args._followRedirectCount || 0) + 1;
  20235. var location = res.headers.location;
  20236. if (!location) {
  20237. err = new Error('Got statusCode ' + res.statusCode + ' but cannot resolve next location from headers');
  20238. err.name = 'FollowRedirectError';
  20239. } else if (args._followRedirectCount > args.maxRedirects) {
  20240. err = new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + url);
  20241. err.name = 'MaxRedirectError';
  20242. } else {
  20243. var newUrl = args.formatRedirectUrl ? args.formatRedirectUrl(url, location) : urlutil.resolve(url, location);
  20244. debug('Request#%d %s: `redirected` from %s to %s', reqId, options.path, url, newUrl);
  20245. // make sure timer stop
  20246. cancelResponseTimer();
  20247. // should clean up headers.Host on `location: http://other-domain/url`
  20248. if (args.headers && args.headers.Host && PROTO_RE.test(location)) {
  20249. args.headers.Host = null;
  20250. }
  20251. // avoid done will be execute in the future change.
  20252. var cb = callback;
  20253. callback = null;
  20254. exports.requestWithCallback(newUrl, args, cb);
  20255. return {
  20256. redirect: true,
  20257. error: null
  20258. };
  20259. }
  20260. }
  20261. return {
  20262. redirect: false,
  20263. error: err
  20264. };
  20265. }
  20266. // set user-agent
  20267. if (!options.headers['User-Agent'] && !options.headers['user-agent']) {
  20268. options.headers['User-Agent'] = navigator.userAgent;
  20269. }
  20270. if (args.gzip) {
  20271. if (!options.headers['Accept-Encoding'] && !options.headers['accept-encoding']) {
  20272. options.headers['Accept-Encoding'] = 'gzip';
  20273. }
  20274. }
  20275. function decodeContent(res, body, cb) {
  20276. var encoding = res.headers['content-encoding'];
  20277. // if (body.length === 0) {
  20278. // return cb(null, body, encoding);
  20279. // }
  20280. // if (!encoding || encoding.toLowerCase() !== 'gzip') {
  20281. return cb(null, body, encoding);
  20282. // }
  20283. // debug('gunzip %d length body', body.length);
  20284. // zlib.gunzip(body, cb);
  20285. }
  20286. var writeStream = args.writeStream;
  20287. debug('Request#%d %s %s with headers %j, options.path: %s', reqId, method, url, options.headers, options.path);
  20288. args.requestUrls.push(url);
  20289. function onResponse(res) {
  20290. if (timing) {
  20291. timing.waiting = Date.now() - requestStartTime;
  20292. }
  20293. debug('Request#%d %s `req response` event emit: status %d, headers: %j', reqId, url, res.statusCode, res.headers);
  20294. if (args.streaming) {
  20295. var result = handleRedirect(res);
  20296. if (result.redirect) {
  20297. res.resume();
  20298. return;
  20299. }
  20300. if (result.error) {
  20301. res.resume();
  20302. return done(result.error, null, res);
  20303. }
  20304. return done(null, null, res);
  20305. }
  20306. res.on('close', function () {
  20307. debug('Request#%d %s: `res close` event emit, total size %d', reqId, url, responseSize);
  20308. });
  20309. res.on('error', function () {
  20310. debug('Request#%d %s: `res error` event emit, total size %d', reqId, url, responseSize);
  20311. });
  20312. res.on('aborted', function () {
  20313. responseAborted = true;
  20314. debug('Request#%d %s: `res aborted` event emit, total size %d', reqId, url, responseSize);
  20315. });
  20316. if (writeStream) {
  20317. // If there's a writable stream to recieve the response data, just pipe the
  20318. // response stream to that writable stream and call the callback when it has
  20319. // finished writing.
  20320. //
  20321. // NOTE that when the response stream `res` emits an 'end' event it just
  20322. // means that it has finished piping data to another stream. In the
  20323. // meanwhile that writable stream may still writing data to the disk until
  20324. // it emits a 'close' event.
  20325. //
  20326. // That means that we should not apply callback until the 'close' of the
  20327. // writable stream is emited.
  20328. //
  20329. // See also:
  20330. // - https://github.com/TBEDP/urllib/commit/959ac3365821e0e028c231a5e8efca6af410eabb
  20331. // - http://nodejs.org/api/stream.html#stream_event_end
  20332. // - http://nodejs.org/api/stream.html#stream_event_close_1
  20333. var result = handleRedirect(res);
  20334. if (result.redirect) {
  20335. res.resume();
  20336. return;
  20337. }
  20338. if (result.error) {
  20339. res.resume();
  20340. // end ths stream first
  20341. writeStream.end();
  20342. return done(result.error, null, res);
  20343. }
  20344. // you can set consumeWriteStream false that only wait response end
  20345. if (args.consumeWriteStream === false) {
  20346. res.on('end', done.bind(null, null, null, res));
  20347. } else {
  20348. // node 0.10, 0.12: only emit res aborted, writeStream close not fired
  20349. if (isNode010 || isNode012) {
  20350. first([[writeStream, 'close'], [res, 'aborted']], function (_, stream, event) {
  20351. debug('Request#%d %s: writeStream or res %s event emitted', reqId, url, event);
  20352. done(__err || null, null, res);
  20353. });
  20354. } else {
  20355. writeStream.on('close', function () {
  20356. debug('Request#%d %s: writeStream close event emitted', reqId, url);
  20357. done(__err || null, null, res);
  20358. });
  20359. }
  20360. }
  20361. return res.pipe(writeStream);
  20362. }
  20363. // Otherwise, just concat those buffers.
  20364. //
  20365. // NOTE that the `chunk` is not a String but a Buffer. It means that if
  20366. // you simply concat two chunk with `+` you're actually converting both
  20367. // Buffers into Strings before concating them. It'll cause problems when
  20368. // dealing with multi-byte characters.
  20369. //
  20370. // The solution is to store each chunk in an array and concat them with
  20371. // 'buffer-concat' when all chunks is recieved.
  20372. //
  20373. // See also:
  20374. // http://cnodejs.org/topic/4faf65852e8fb5bc65113403
  20375. var chunks = [];
  20376. res.on('data', function (chunk) {
  20377. debug('Request#%d %s: `res data` event emit, size %d', reqId, url, chunk.length);
  20378. responseSize += chunk.length;
  20379. chunks.push(chunk);
  20380. });
  20381. res.on('end', function () {
  20382. var body = Buffer.concat(chunks, responseSize);
  20383. debug('Request#%d %s: `res end` event emit, total size %d, _dumped: %s', reqId, url, responseSize, res._dumped);
  20384. if (__err) {
  20385. // req.abort() after `res data` event emit.
  20386. return done(__err, body, res);
  20387. }
  20388. var result = handleRedirect(res);
  20389. if (result.error) {
  20390. return done(result.error, body, res);
  20391. }
  20392. if (result.redirect) {
  20393. return;
  20394. }
  20395. decodeContent(res, body, function (err, data, encoding) {
  20396. if (err) {
  20397. return done(err, body, res);
  20398. }
  20399. // if body not decode, dont touch it
  20400. if (!encoding && TEXT_DATA_TYPES.indexOf(args.dataType) >= 0) {
  20401. // try to decode charset
  20402. try {
  20403. data = decodeBodyByCharset(data, res);
  20404. } catch (e) {
  20405. debug('decodeBodyByCharset error: %s', e);
  20406. // if error, dont touch it
  20407. return done(null, data, res);
  20408. }
  20409. if (args.dataType === 'json') {
  20410. if (responseSize === 0) {
  20411. data = null;
  20412. } else {
  20413. var r = parseJSON(data, fixJSONCtlChars);
  20414. if (r.error) {
  20415. err = r.error;
  20416. } else {
  20417. data = r.data;
  20418. }
  20419. }
  20420. }
  20421. }
  20422. if (responseAborted) {
  20423. // err = new Error('Remote socket was terminated before `response.end()` was called');
  20424. // err.name = 'RemoteSocketClosedError';
  20425. debug('Request#%d %s: Remote socket was terminated before `response.end()` was called', reqId, url);
  20426. }
  20427. done(err, data, res);
  20428. });
  20429. });
  20430. }
  20431. var connectTimeout, responseTimeout;
  20432. if (Array.isArray(args.timeout)) {
  20433. connectTimeout = ms(args.timeout[0]);
  20434. responseTimeout = ms(args.timeout[1]);
  20435. } else {
  20436. // set both timeout equal
  20437. connectTimeout = responseTimeout = ms(args.timeout);
  20438. }
  20439. debug('ConnectTimeout: %d, ResponseTimeout: %d', connectTimeout, responseTimeout);
  20440. function startConnectTimer() {
  20441. debug('Connect timer ticking, timeout: %d', connectTimeout);
  20442. connectTimer = setTimeout(function () {
  20443. connectTimer = null;
  20444. if (statusCode === -1) {
  20445. statusCode = -2;
  20446. }
  20447. var msg = 'Connect timeout for ' + connectTimeout + 'ms';
  20448. var errorName = 'ConnectionTimeoutError';
  20449. if (!req.socket) {
  20450. errorName = 'SocketAssignTimeoutError';
  20451. msg += ', working sockets is full';
  20452. }
  20453. __err = new Error(msg);
  20454. __err.name = errorName;
  20455. __err.requestId = reqId;
  20456. debug('ConnectTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
  20457. abortRequest();
  20458. }, connectTimeout);
  20459. }
  20460. function startResposneTimer() {
  20461. debug('Response timer ticking, timeout: %d', responseTimeout);
  20462. responseTimer = setTimeout(function () {
  20463. responseTimer = null;
  20464. var msg = 'Response timeout for ' + responseTimeout + 'ms';
  20465. var errorName = 'ResponseTimeoutError';
  20466. __err = new Error(msg);
  20467. __err.name = errorName;
  20468. __err.requestId = reqId;
  20469. debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
  20470. abortRequest();
  20471. }, responseTimeout);
  20472. }
  20473. var req;
  20474. // request headers checker will throw error
  20475. try {
  20476. req = httplib.request(options, onResponse);
  20477. } catch (err) {
  20478. return done(err);
  20479. }
  20480. // environment detection: browser or nodejs
  20481. if (typeof window === 'undefined') {
  20482. // start connect timer just after `request` return, and just in nodejs environment
  20483. startConnectTimer();
  20484. } else {
  20485. req.on('timeout', function () {
  20486. if (statusCode === -1) {
  20487. statusCode = -2;
  20488. }
  20489. var msg = 'Connect timeout for ' + connectTimeout + 'ms';
  20490. var errorName = 'ConnectionTimeoutError';
  20491. __err = new Error(msg);
  20492. __err.name = errorName;
  20493. __err.requestId = reqId;
  20494. abortRequest();
  20495. });
  20496. }
  20497. function abortRequest() {
  20498. debug('Request#%d %s abort, connected: %s', reqId, url, connected);
  20499. // it wont case error event when req haven't been assigned a socket yet.
  20500. if (!req.socket) {
  20501. __err.noSocket = true;
  20502. done(__err);
  20503. }
  20504. req.abort();
  20505. }
  20506. if (timing) {
  20507. // request sent
  20508. req.on('finish', function () {
  20509. timing.requestSent = Date.now() - requestStartTime;
  20510. });
  20511. }
  20512. req.once('socket', function (socket) {
  20513. if (timing) {
  20514. // socket queuing time
  20515. timing.queuing = Date.now() - requestStartTime;
  20516. }
  20517. // https://github.com/nodejs/node/blob/master/lib/net.js#L377
  20518. // https://github.com/nodejs/node/blob/v0.10.40-release/lib/net.js#L352
  20519. // should use socket.socket on 0.10.x
  20520. if (isNode010 && socket.socket) {
  20521. socket = socket.socket;
  20522. }
  20523. var readyState = socket.readyState;
  20524. if (readyState === 'opening') {
  20525. socket.once('lookup', function (err, ip, addressType) {
  20526. debug('Request#%d %s lookup: %s, %s, %s', reqId, url, err, ip, addressType);
  20527. if (timing) {
  20528. timing.dnslookup = Date.now() - requestStartTime;
  20529. }
  20530. if (ip) {
  20531. remoteAddress = ip;
  20532. }
  20533. });
  20534. socket.once('connect', function () {
  20535. if (timing) {
  20536. // socket connected
  20537. timing.connected = Date.now() - requestStartTime;
  20538. }
  20539. // cancel socket timer at first and start tick for TTFB
  20540. cancelConnectTimer();
  20541. startResposneTimer();
  20542. debug('Request#%d %s new socket connected', reqId, url);
  20543. connected = true;
  20544. if (!remoteAddress) {
  20545. remoteAddress = socket.remoteAddress;
  20546. }
  20547. remotePort = socket.remotePort;
  20548. });
  20549. return;
  20550. }
  20551. debug('Request#%d %s reuse socket connected, readyState: %s', reqId, url, readyState);
  20552. connected = true;
  20553. keepAliveSocket = true;
  20554. if (!remoteAddress) {
  20555. remoteAddress = socket.remoteAddress;
  20556. }
  20557. remotePort = socket.remotePort;
  20558. // reuse socket, timer should be canceled.
  20559. cancelConnectTimer();
  20560. startResposneTimer();
  20561. });
  20562. req.on('error', function (err) {
  20563. //TypeError for browser fetch api, Error for browser xmlhttprequest api
  20564. if (err.name === 'Error' || err.name === 'TypeError') {
  20565. err.name = connected ? 'ResponseError' : 'RequestError';
  20566. }
  20567. err.message += ' (req "error")';
  20568. debug('Request#%d %s `req error` event emit, %s: %s', reqId, url, err.name, err.message);
  20569. done(__err || err);
  20570. });
  20571. if (writeStream) {
  20572. writeStream.once('error', function (err) {
  20573. err.message += ' (writeStream "error")';
  20574. __err = err;
  20575. debug('Request#%d %s `writeStream error` event emit, %s: %s', reqId, url, err.name, err.message);
  20576. abortRequest();
  20577. });
  20578. }
  20579. if (args.stream) {
  20580. args.stream.pipe(req);
  20581. args.stream.once('error', function (err) {
  20582. err.message += ' (stream "error")';
  20583. __err = err;
  20584. debug('Request#%d %s `readStream error` event emit, %s: %s', reqId, url, err.name, err.message);
  20585. abortRequest();
  20586. });
  20587. } else {
  20588. req.end(body);
  20589. }
  20590. req.requestId = reqId;
  20591. return req;
  20592. };
  20593. }).call(this,require('_process'),require("buffer").Buffer)
  20594. },{"_process":159,"any-promise":8,"babel-runtime/core-js/json/stringify":12,"babel-runtime/helpers/typeof":26,"buffer":31,"constants":37,"debug":142,"http":184,"https":146,"humanize-ms":147,"url":191,"util":196}]},{},[1])(1)
  20595. });