omega_pac.min.js 716 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131
  1. (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.OmegaPac = 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){
  2. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  3. ;(function (exports) {
  4. 'use strict';
  5. var Arr = (typeof Uint8Array !== 'undefined')
  6. ? Uint8Array
  7. : Array
  8. var PLUS = '+'.charCodeAt(0)
  9. var SLASH = '/'.charCodeAt(0)
  10. var NUMBER = '0'.charCodeAt(0)
  11. var LOWER = 'a'.charCodeAt(0)
  12. var UPPER = 'A'.charCodeAt(0)
  13. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  14. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  15. function decode (elt) {
  16. var code = elt.charCodeAt(0)
  17. if (code === PLUS ||
  18. code === PLUS_URL_SAFE)
  19. return 62 // '+'
  20. if (code === SLASH ||
  21. code === SLASH_URL_SAFE)
  22. return 63 // '/'
  23. if (code < NUMBER)
  24. return -1 //no match
  25. if (code < NUMBER + 10)
  26. return code - NUMBER + 26 + 26
  27. if (code < UPPER + 26)
  28. return code - UPPER
  29. if (code < LOWER + 26)
  30. return code - LOWER + 26
  31. }
  32. function b64ToByteArray (b64) {
  33. var i, j, l, tmp, placeHolders, arr
  34. if (b64.length % 4 > 0) {
  35. throw new Error('Invalid string. Length must be a multiple of 4')
  36. }
  37. // the number of equal signs (place holders)
  38. // if there are two placeholders, than the two characters before it
  39. // represent one byte
  40. // if there is only one, then the three characters before it represent 2 bytes
  41. // this is just a cheap hack to not do indexOf twice
  42. var len = b64.length
  43. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  44. // base64 is 4/3 + up to two characters of the original data
  45. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  46. // if there are placeholders, only get up to the last complete 4 chars
  47. l = placeHolders > 0 ? b64.length - 4 : b64.length
  48. var L = 0
  49. function push (v) {
  50. arr[L++] = v
  51. }
  52. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  53. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  54. push((tmp & 0xFF0000) >> 16)
  55. push((tmp & 0xFF00) >> 8)
  56. push(tmp & 0xFF)
  57. }
  58. if (placeHolders === 2) {
  59. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  60. push(tmp & 0xFF)
  61. } else if (placeHolders === 1) {
  62. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  63. push((tmp >> 8) & 0xFF)
  64. push(tmp & 0xFF)
  65. }
  66. return arr
  67. }
  68. function uint8ToBase64 (uint8) {
  69. var i,
  70. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  71. output = "",
  72. temp, length
  73. function encode (num) {
  74. return lookup.charAt(num)
  75. }
  76. function tripletToBase64 (num) {
  77. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  78. }
  79. // go through the array every three bytes, we'll deal with trailing stuff later
  80. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  81. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  82. output += tripletToBase64(temp)
  83. }
  84. // pad the end with zeros, but make sure to not forget the extra bytes
  85. switch (extraBytes) {
  86. case 1:
  87. temp = uint8[uint8.length - 1]
  88. output += encode(temp >> 2)
  89. output += encode((temp << 4) & 0x3F)
  90. output += '=='
  91. break
  92. case 2:
  93. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  94. output += encode(temp >> 10)
  95. output += encode((temp >> 4) & 0x3F)
  96. output += encode((temp << 2) & 0x3F)
  97. output += '='
  98. break
  99. }
  100. return output
  101. }
  102. exports.toByteArray = b64ToByteArray
  103. exports.fromByteArray = uint8ToBase64
  104. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  105. },{}],2:[function(require,module,exports){
  106. (function (global){
  107. /*!
  108. * The buffer module from node.js, for the browser.
  109. *
  110. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  111. * @license MIT
  112. */
  113. /* eslint-disable no-proto */
  114. 'use strict'
  115. var base64 = require('base64-js')
  116. var ieee754 = require('ieee754')
  117. var isArray = require('isarray')
  118. exports.Buffer = Buffer
  119. exports.SlowBuffer = SlowBuffer
  120. exports.INSPECT_MAX_BYTES = 50
  121. Buffer.poolSize = 8192 // not used by this implementation
  122. var rootParent = {}
  123. /**
  124. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  125. * === true Use Uint8Array implementation (fastest)
  126. * === false Use Object implementation (most compatible, even IE6)
  127. *
  128. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  129. * Opera 11.6+, iOS 4.2+.
  130. *
  131. * Due to various browser bugs, sometimes the Object implementation will be used even
  132. * when the browser supports typed arrays.
  133. *
  134. * Note:
  135. *
  136. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  137. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  138. *
  139. * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
  140. * on objects.
  141. *
  142. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  143. *
  144. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  145. * incorrect length in some situations.
  146. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  147. * get the Object implementation, which is slower but behaves correctly.
  148. */
  149. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  150. ? global.TYPED_ARRAY_SUPPORT
  151. : typedArraySupport()
  152. function typedArraySupport () {
  153. function Bar () {}
  154. try {
  155. var arr = new Uint8Array(1)
  156. arr.foo = function () { return 42 }
  157. arr.constructor = Bar
  158. return arr.foo() === 42 && // typed array instances can be augmented
  159. arr.constructor === Bar && // constructor can be set
  160. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  161. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  162. } catch (e) {
  163. return false
  164. }
  165. }
  166. function kMaxLength () {
  167. return Buffer.TYPED_ARRAY_SUPPORT
  168. ? 0x7fffffff
  169. : 0x3fffffff
  170. }
  171. /**
  172. * Class: Buffer
  173. * =============
  174. *
  175. * The Buffer constructor returns instances of `Uint8Array` that are augmented
  176. * with function properties for all the node `Buffer` API functions. We use
  177. * `Uint8Array` so that square bracket notation works as expected -- it returns
  178. * a single octet.
  179. *
  180. * By augmenting the instances, we can avoid modifying the `Uint8Array`
  181. * prototype.
  182. */
  183. function Buffer (arg) {
  184. if (!(this instanceof Buffer)) {
  185. // Avoid going through an ArgumentsAdaptorTrampoline in the common case.
  186. if (arguments.length > 1) return new Buffer(arg, arguments[1])
  187. return new Buffer(arg)
  188. }
  189. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  190. this.length = 0
  191. this.parent = undefined
  192. }
  193. // Common case.
  194. if (typeof arg === 'number') {
  195. return fromNumber(this, arg)
  196. }
  197. // Slightly less common case.
  198. if (typeof arg === 'string') {
  199. return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
  200. }
  201. // Unusual.
  202. return fromObject(this, arg)
  203. }
  204. function fromNumber (that, length) {
  205. that = allocate(that, length < 0 ? 0 : checked(length) | 0)
  206. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  207. for (var i = 0; i < length; i++) {
  208. that[i] = 0
  209. }
  210. }
  211. return that
  212. }
  213. function fromString (that, string, encoding) {
  214. if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
  215. // Assumption: byteLength() return value is always < kMaxLength.
  216. var length = byteLength(string, encoding) | 0
  217. that = allocate(that, length)
  218. that.write(string, encoding)
  219. return that
  220. }
  221. function fromObject (that, object) {
  222. if (Buffer.isBuffer(object)) return fromBuffer(that, object)
  223. if (isArray(object)) return fromArray(that, object)
  224. if (object == null) {
  225. throw new TypeError('must start with number, buffer, array or string')
  226. }
  227. if (typeof ArrayBuffer !== 'undefined') {
  228. if (object.buffer instanceof ArrayBuffer) {
  229. return fromTypedArray(that, object)
  230. }
  231. if (object instanceof ArrayBuffer) {
  232. return fromArrayBuffer(that, object)
  233. }
  234. }
  235. if (object.length) return fromArrayLike(that, object)
  236. return fromJsonObject(that, object)
  237. }
  238. function fromBuffer (that, buffer) {
  239. var length = checked(buffer.length) | 0
  240. that = allocate(that, length)
  241. buffer.copy(that, 0, 0, length)
  242. return that
  243. }
  244. function fromArray (that, array) {
  245. var length = checked(array.length) | 0
  246. that = allocate(that, length)
  247. for (var i = 0; i < length; i += 1) {
  248. that[i] = array[i] & 255
  249. }
  250. return that
  251. }
  252. // Duplicate of fromArray() to keep fromArray() monomorphic.
  253. function fromTypedArray (that, array) {
  254. var length = checked(array.length) | 0
  255. that = allocate(that, length)
  256. // Truncating the elements is probably not what people expect from typed
  257. // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
  258. // of the old Buffer constructor.
  259. for (var i = 0; i < length; i += 1) {
  260. that[i] = array[i] & 255
  261. }
  262. return that
  263. }
  264. function fromArrayBuffer (that, array) {
  265. if (Buffer.TYPED_ARRAY_SUPPORT) {
  266. // Return an augmented `Uint8Array` instance, for best performance
  267. array.byteLength
  268. that = Buffer._augment(new Uint8Array(array))
  269. } else {
  270. // Fallback: Return an object instance of the Buffer class
  271. that = fromTypedArray(that, new Uint8Array(array))
  272. }
  273. return that
  274. }
  275. function fromArrayLike (that, array) {
  276. var length = checked(array.length) | 0
  277. that = allocate(that, length)
  278. for (var i = 0; i < length; i += 1) {
  279. that[i] = array[i] & 255
  280. }
  281. return that
  282. }
  283. // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
  284. // Returns a zero-length buffer for inputs that don't conform to the spec.
  285. function fromJsonObject (that, object) {
  286. var array
  287. var length = 0
  288. if (object.type === 'Buffer' && isArray(object.data)) {
  289. array = object.data
  290. length = checked(array.length) | 0
  291. }
  292. that = allocate(that, length)
  293. for (var i = 0; i < length; i += 1) {
  294. that[i] = array[i] & 255
  295. }
  296. return that
  297. }
  298. if (Buffer.TYPED_ARRAY_SUPPORT) {
  299. Buffer.prototype.__proto__ = Uint8Array.prototype
  300. Buffer.__proto__ = Uint8Array
  301. } else {
  302. // pre-set for values that may exist in the future
  303. Buffer.prototype.length = undefined
  304. Buffer.prototype.parent = undefined
  305. }
  306. function allocate (that, length) {
  307. if (Buffer.TYPED_ARRAY_SUPPORT) {
  308. // Return an augmented `Uint8Array` instance, for best performance
  309. that = Buffer._augment(new Uint8Array(length))
  310. that.__proto__ = Buffer.prototype
  311. } else {
  312. // Fallback: Return an object instance of the Buffer class
  313. that.length = length
  314. that._isBuffer = true
  315. }
  316. var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
  317. if (fromPool) that.parent = rootParent
  318. return that
  319. }
  320. function checked (length) {
  321. // Note: cannot use `length < kMaxLength` here because that fails when
  322. // length is NaN (which is otherwise coerced to zero.)
  323. if (length >= kMaxLength()) {
  324. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  325. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  326. }
  327. return length | 0
  328. }
  329. function SlowBuffer (subject, encoding) {
  330. if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
  331. var buf = new Buffer(subject, encoding)
  332. delete buf.parent
  333. return buf
  334. }
  335. Buffer.isBuffer = function isBuffer (b) {
  336. return !!(b != null && b._isBuffer)
  337. }
  338. Buffer.compare = function compare (a, b) {
  339. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  340. throw new TypeError('Arguments must be Buffers')
  341. }
  342. if (a === b) return 0
  343. var x = a.length
  344. var y = b.length
  345. var i = 0
  346. var len = Math.min(x, y)
  347. while (i < len) {
  348. if (a[i] !== b[i]) break
  349. ++i
  350. }
  351. if (i !== len) {
  352. x = a[i]
  353. y = b[i]
  354. }
  355. if (x < y) return -1
  356. if (y < x) return 1
  357. return 0
  358. }
  359. Buffer.isEncoding = function isEncoding (encoding) {
  360. switch (String(encoding).toLowerCase()) {
  361. case 'hex':
  362. case 'utf8':
  363. case 'utf-8':
  364. case 'ascii':
  365. case 'binary':
  366. case 'base64':
  367. case 'raw':
  368. case 'ucs2':
  369. case 'ucs-2':
  370. case 'utf16le':
  371. case 'utf-16le':
  372. return true
  373. default:
  374. return false
  375. }
  376. }
  377. Buffer.concat = function concat (list, length) {
  378. if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
  379. if (list.length === 0) {
  380. return new Buffer(0)
  381. }
  382. var i
  383. if (length === undefined) {
  384. length = 0
  385. for (i = 0; i < list.length; i++) {
  386. length += list[i].length
  387. }
  388. }
  389. var buf = new Buffer(length)
  390. var pos = 0
  391. for (i = 0; i < list.length; i++) {
  392. var item = list[i]
  393. item.copy(buf, pos)
  394. pos += item.length
  395. }
  396. return buf
  397. }
  398. function byteLength (string, encoding) {
  399. if (typeof string !== 'string') string = '' + string
  400. var len = string.length
  401. if (len === 0) return 0
  402. // Use a for loop to avoid recursion
  403. var loweredCase = false
  404. for (;;) {
  405. switch (encoding) {
  406. case 'ascii':
  407. case 'binary':
  408. // Deprecated
  409. case 'raw':
  410. case 'raws':
  411. return len
  412. case 'utf8':
  413. case 'utf-8':
  414. return utf8ToBytes(string).length
  415. case 'ucs2':
  416. case 'ucs-2':
  417. case 'utf16le':
  418. case 'utf-16le':
  419. return len * 2
  420. case 'hex':
  421. return len >>> 1
  422. case 'base64':
  423. return base64ToBytes(string).length
  424. default:
  425. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  426. encoding = ('' + encoding).toLowerCase()
  427. loweredCase = true
  428. }
  429. }
  430. }
  431. Buffer.byteLength = byteLength
  432. function slowToString (encoding, start, end) {
  433. var loweredCase = false
  434. start = start | 0
  435. end = end === undefined || end === Infinity ? this.length : end | 0
  436. if (!encoding) encoding = 'utf8'
  437. if (start < 0) start = 0
  438. if (end > this.length) end = this.length
  439. if (end <= start) return ''
  440. while (true) {
  441. switch (encoding) {
  442. case 'hex':
  443. return hexSlice(this, start, end)
  444. case 'utf8':
  445. case 'utf-8':
  446. return utf8Slice(this, start, end)
  447. case 'ascii':
  448. return asciiSlice(this, start, end)
  449. case 'binary':
  450. return binarySlice(this, start, end)
  451. case 'base64':
  452. return base64Slice(this, start, end)
  453. case 'ucs2':
  454. case 'ucs-2':
  455. case 'utf16le':
  456. case 'utf-16le':
  457. return utf16leSlice(this, start, end)
  458. default:
  459. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  460. encoding = (encoding + '').toLowerCase()
  461. loweredCase = true
  462. }
  463. }
  464. }
  465. Buffer.prototype.toString = function toString () {
  466. var length = this.length | 0
  467. if (length === 0) return ''
  468. if (arguments.length === 0) return utf8Slice(this, 0, length)
  469. return slowToString.apply(this, arguments)
  470. }
  471. Buffer.prototype.equals = function equals (b) {
  472. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  473. if (this === b) return true
  474. return Buffer.compare(this, b) === 0
  475. }
  476. Buffer.prototype.inspect = function inspect () {
  477. var str = ''
  478. var max = exports.INSPECT_MAX_BYTES
  479. if (this.length > 0) {
  480. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  481. if (this.length > max) str += ' ... '
  482. }
  483. return '<Buffer ' + str + '>'
  484. }
  485. Buffer.prototype.compare = function compare (b) {
  486. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  487. if (this === b) return 0
  488. return Buffer.compare(this, b)
  489. }
  490. Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
  491. if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
  492. else if (byteOffset < -0x80000000) byteOffset = -0x80000000
  493. byteOffset >>= 0
  494. if (this.length === 0) return -1
  495. if (byteOffset >= this.length) return -1
  496. // Negative offsets start from the end of the buffer
  497. if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  498. if (typeof val === 'string') {
  499. if (val.length === 0) return -1 // special case: looking for empty string always fails
  500. return String.prototype.indexOf.call(this, val, byteOffset)
  501. }
  502. if (Buffer.isBuffer(val)) {
  503. return arrayIndexOf(this, val, byteOffset)
  504. }
  505. if (typeof val === 'number') {
  506. if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  507. return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  508. }
  509. return arrayIndexOf(this, [ val ], byteOffset)
  510. }
  511. function arrayIndexOf (arr, val, byteOffset) {
  512. var foundIndex = -1
  513. for (var i = 0; byteOffset + i < arr.length; i++) {
  514. if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
  515. if (foundIndex === -1) foundIndex = i
  516. if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
  517. } else {
  518. foundIndex = -1
  519. }
  520. }
  521. return -1
  522. }
  523. throw new TypeError('val must be string, number or Buffer')
  524. }
  525. // `get` is deprecated
  526. Buffer.prototype.get = function get (offset) {
  527. console.log('.get() is deprecated. Access using array indexes instead.')
  528. return this.readUInt8(offset)
  529. }
  530. // `set` is deprecated
  531. Buffer.prototype.set = function set (v, offset) {
  532. console.log('.set() is deprecated. Access using array indexes instead.')
  533. return this.writeUInt8(v, offset)
  534. }
  535. function hexWrite (buf, string, offset, length) {
  536. offset = Number(offset) || 0
  537. var remaining = buf.length - offset
  538. if (!length) {
  539. length = remaining
  540. } else {
  541. length = Number(length)
  542. if (length > remaining) {
  543. length = remaining
  544. }
  545. }
  546. // must be an even number of digits
  547. var strLen = string.length
  548. if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  549. if (length > strLen / 2) {
  550. length = strLen / 2
  551. }
  552. for (var i = 0; i < length; i++) {
  553. var parsed = parseInt(string.substr(i * 2, 2), 16)
  554. if (isNaN(parsed)) throw new Error('Invalid hex string')
  555. buf[offset + i] = parsed
  556. }
  557. return i
  558. }
  559. function utf8Write (buf, string, offset, length) {
  560. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  561. }
  562. function asciiWrite (buf, string, offset, length) {
  563. return blitBuffer(asciiToBytes(string), buf, offset, length)
  564. }
  565. function binaryWrite (buf, string, offset, length) {
  566. return asciiWrite(buf, string, offset, length)
  567. }
  568. function base64Write (buf, string, offset, length) {
  569. return blitBuffer(base64ToBytes(string), buf, offset, length)
  570. }
  571. function ucs2Write (buf, string, offset, length) {
  572. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  573. }
  574. Buffer.prototype.write = function write (string, offset, length, encoding) {
  575. // Buffer#write(string)
  576. if (offset === undefined) {
  577. encoding = 'utf8'
  578. length = this.length
  579. offset = 0
  580. // Buffer#write(string, encoding)
  581. } else if (length === undefined && typeof offset === 'string') {
  582. encoding = offset
  583. length = this.length
  584. offset = 0
  585. // Buffer#write(string, offset[, length][, encoding])
  586. } else if (isFinite(offset)) {
  587. offset = offset | 0
  588. if (isFinite(length)) {
  589. length = length | 0
  590. if (encoding === undefined) encoding = 'utf8'
  591. } else {
  592. encoding = length
  593. length = undefined
  594. }
  595. // legacy write(string, encoding, offset, length) - remove in v0.13
  596. } else {
  597. var swap = encoding
  598. encoding = offset
  599. offset = length | 0
  600. length = swap
  601. }
  602. var remaining = this.length - offset
  603. if (length === undefined || length > remaining) length = remaining
  604. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  605. throw new RangeError('attempt to write outside buffer bounds')
  606. }
  607. if (!encoding) encoding = 'utf8'
  608. var loweredCase = false
  609. for (;;) {
  610. switch (encoding) {
  611. case 'hex':
  612. return hexWrite(this, string, offset, length)
  613. case 'utf8':
  614. case 'utf-8':
  615. return utf8Write(this, string, offset, length)
  616. case 'ascii':
  617. return asciiWrite(this, string, offset, length)
  618. case 'binary':
  619. return binaryWrite(this, string, offset, length)
  620. case 'base64':
  621. // Warning: maxLength not taken into account in base64Write
  622. return base64Write(this, string, offset, length)
  623. case 'ucs2':
  624. case 'ucs-2':
  625. case 'utf16le':
  626. case 'utf-16le':
  627. return ucs2Write(this, string, offset, length)
  628. default:
  629. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  630. encoding = ('' + encoding).toLowerCase()
  631. loweredCase = true
  632. }
  633. }
  634. }
  635. Buffer.prototype.toJSON = function toJSON () {
  636. return {
  637. type: 'Buffer',
  638. data: Array.prototype.slice.call(this._arr || this, 0)
  639. }
  640. }
  641. function base64Slice (buf, start, end) {
  642. if (start === 0 && end === buf.length) {
  643. return base64.fromByteArray(buf)
  644. } else {
  645. return base64.fromByteArray(buf.slice(start, end))
  646. }
  647. }
  648. function utf8Slice (buf, start, end) {
  649. end = Math.min(buf.length, end)
  650. var res = []
  651. var i = start
  652. while (i < end) {
  653. var firstByte = buf[i]
  654. var codePoint = null
  655. var bytesPerSequence = (firstByte > 0xEF) ? 4
  656. : (firstByte > 0xDF) ? 3
  657. : (firstByte > 0xBF) ? 2
  658. : 1
  659. if (i + bytesPerSequence <= end) {
  660. var secondByte, thirdByte, fourthByte, tempCodePoint
  661. switch (bytesPerSequence) {
  662. case 1:
  663. if (firstByte < 0x80) {
  664. codePoint = firstByte
  665. }
  666. break
  667. case 2:
  668. secondByte = buf[i + 1]
  669. if ((secondByte & 0xC0) === 0x80) {
  670. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  671. if (tempCodePoint > 0x7F) {
  672. codePoint = tempCodePoint
  673. }
  674. }
  675. break
  676. case 3:
  677. secondByte = buf[i + 1]
  678. thirdByte = buf[i + 2]
  679. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  680. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  681. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  682. codePoint = tempCodePoint
  683. }
  684. }
  685. break
  686. case 4:
  687. secondByte = buf[i + 1]
  688. thirdByte = buf[i + 2]
  689. fourthByte = buf[i + 3]
  690. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  691. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  692. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  693. codePoint = tempCodePoint
  694. }
  695. }
  696. }
  697. }
  698. if (codePoint === null) {
  699. // we did not generate a valid codePoint so insert a
  700. // replacement char (U+FFFD) and advance only 1 byte
  701. codePoint = 0xFFFD
  702. bytesPerSequence = 1
  703. } else if (codePoint > 0xFFFF) {
  704. // encode to utf16 (surrogate pair dance)
  705. codePoint -= 0x10000
  706. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  707. codePoint = 0xDC00 | codePoint & 0x3FF
  708. }
  709. res.push(codePoint)
  710. i += bytesPerSequence
  711. }
  712. return decodeCodePointsArray(res)
  713. }
  714. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  715. // the lowest limit is Chrome, with 0x10000 args.
  716. // We go 1 magnitude less, for safety
  717. var MAX_ARGUMENTS_LENGTH = 0x1000
  718. function decodeCodePointsArray (codePoints) {
  719. var len = codePoints.length
  720. if (len <= MAX_ARGUMENTS_LENGTH) {
  721. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  722. }
  723. // Decode in chunks to avoid "call stack size exceeded".
  724. var res = ''
  725. var i = 0
  726. while (i < len) {
  727. res += String.fromCharCode.apply(
  728. String,
  729. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  730. )
  731. }
  732. return res
  733. }
  734. function asciiSlice (buf, start, end) {
  735. var ret = ''
  736. end = Math.min(buf.length, end)
  737. for (var i = start; i < end; i++) {
  738. ret += String.fromCharCode(buf[i] & 0x7F)
  739. }
  740. return ret
  741. }
  742. function binarySlice (buf, start, end) {
  743. var ret = ''
  744. end = Math.min(buf.length, end)
  745. for (var i = start; i < end; i++) {
  746. ret += String.fromCharCode(buf[i])
  747. }
  748. return ret
  749. }
  750. function hexSlice (buf, start, end) {
  751. var len = buf.length
  752. if (!start || start < 0) start = 0
  753. if (!end || end < 0 || end > len) end = len
  754. var out = ''
  755. for (var i = start; i < end; i++) {
  756. out += toHex(buf[i])
  757. }
  758. return out
  759. }
  760. function utf16leSlice (buf, start, end) {
  761. var bytes = buf.slice(start, end)
  762. var res = ''
  763. for (var i = 0; i < bytes.length; i += 2) {
  764. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  765. }
  766. return res
  767. }
  768. Buffer.prototype.slice = function slice (start, end) {
  769. var len = this.length
  770. start = ~~start
  771. end = end === undefined ? len : ~~end
  772. if (start < 0) {
  773. start += len
  774. if (start < 0) start = 0
  775. } else if (start > len) {
  776. start = len
  777. }
  778. if (end < 0) {
  779. end += len
  780. if (end < 0) end = 0
  781. } else if (end > len) {
  782. end = len
  783. }
  784. if (end < start) end = start
  785. var newBuf
  786. if (Buffer.TYPED_ARRAY_SUPPORT) {
  787. newBuf = Buffer._augment(this.subarray(start, end))
  788. } else {
  789. var sliceLen = end - start
  790. newBuf = new Buffer(sliceLen, undefined)
  791. for (var i = 0; i < sliceLen; i++) {
  792. newBuf[i] = this[i + start]
  793. }
  794. }
  795. if (newBuf.length) newBuf.parent = this.parent || this
  796. return newBuf
  797. }
  798. /*
  799. * Need to make sure that buffer isn't trying to write out of bounds.
  800. */
  801. function checkOffset (offset, ext, length) {
  802. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  803. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  804. }
  805. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  806. offset = offset | 0
  807. byteLength = byteLength | 0
  808. if (!noAssert) checkOffset(offset, byteLength, this.length)
  809. var val = this[offset]
  810. var mul = 1
  811. var i = 0
  812. while (++i < byteLength && (mul *= 0x100)) {
  813. val += this[offset + i] * mul
  814. }
  815. return val
  816. }
  817. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  818. offset = offset | 0
  819. byteLength = byteLength | 0
  820. if (!noAssert) {
  821. checkOffset(offset, byteLength, this.length)
  822. }
  823. var val = this[offset + --byteLength]
  824. var mul = 1
  825. while (byteLength > 0 && (mul *= 0x100)) {
  826. val += this[offset + --byteLength] * mul
  827. }
  828. return val
  829. }
  830. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  831. if (!noAssert) checkOffset(offset, 1, this.length)
  832. return this[offset]
  833. }
  834. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  835. if (!noAssert) checkOffset(offset, 2, this.length)
  836. return this[offset] | (this[offset + 1] << 8)
  837. }
  838. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  839. if (!noAssert) checkOffset(offset, 2, this.length)
  840. return (this[offset] << 8) | this[offset + 1]
  841. }
  842. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  843. if (!noAssert) checkOffset(offset, 4, this.length)
  844. return ((this[offset]) |
  845. (this[offset + 1] << 8) |
  846. (this[offset + 2] << 16)) +
  847. (this[offset + 3] * 0x1000000)
  848. }
  849. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  850. if (!noAssert) checkOffset(offset, 4, this.length)
  851. return (this[offset] * 0x1000000) +
  852. ((this[offset + 1] << 16) |
  853. (this[offset + 2] << 8) |
  854. this[offset + 3])
  855. }
  856. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  857. offset = offset | 0
  858. byteLength = byteLength | 0
  859. if (!noAssert) checkOffset(offset, byteLength, this.length)
  860. var val = this[offset]
  861. var mul = 1
  862. var i = 0
  863. while (++i < byteLength && (mul *= 0x100)) {
  864. val += this[offset + i] * mul
  865. }
  866. mul *= 0x80
  867. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  868. return val
  869. }
  870. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  871. offset = offset | 0
  872. byteLength = byteLength | 0
  873. if (!noAssert) checkOffset(offset, byteLength, this.length)
  874. var i = byteLength
  875. var mul = 1
  876. var val = this[offset + --i]
  877. while (i > 0 && (mul *= 0x100)) {
  878. val += this[offset + --i] * mul
  879. }
  880. mul *= 0x80
  881. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  882. return val
  883. }
  884. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  885. if (!noAssert) checkOffset(offset, 1, this.length)
  886. if (!(this[offset] & 0x80)) return (this[offset])
  887. return ((0xff - this[offset] + 1) * -1)
  888. }
  889. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  890. if (!noAssert) checkOffset(offset, 2, this.length)
  891. var val = this[offset] | (this[offset + 1] << 8)
  892. return (val & 0x8000) ? val | 0xFFFF0000 : val
  893. }
  894. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  895. if (!noAssert) checkOffset(offset, 2, this.length)
  896. var val = this[offset + 1] | (this[offset] << 8)
  897. return (val & 0x8000) ? val | 0xFFFF0000 : val
  898. }
  899. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  900. if (!noAssert) checkOffset(offset, 4, this.length)
  901. return (this[offset]) |
  902. (this[offset + 1] << 8) |
  903. (this[offset + 2] << 16) |
  904. (this[offset + 3] << 24)
  905. }
  906. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  907. if (!noAssert) checkOffset(offset, 4, this.length)
  908. return (this[offset] << 24) |
  909. (this[offset + 1] << 16) |
  910. (this[offset + 2] << 8) |
  911. (this[offset + 3])
  912. }
  913. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  914. if (!noAssert) checkOffset(offset, 4, this.length)
  915. return ieee754.read(this, offset, true, 23, 4)
  916. }
  917. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  918. if (!noAssert) checkOffset(offset, 4, this.length)
  919. return ieee754.read(this, offset, false, 23, 4)
  920. }
  921. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  922. if (!noAssert) checkOffset(offset, 8, this.length)
  923. return ieee754.read(this, offset, true, 52, 8)
  924. }
  925. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  926. if (!noAssert) checkOffset(offset, 8, this.length)
  927. return ieee754.read(this, offset, false, 52, 8)
  928. }
  929. function checkInt (buf, value, offset, ext, max, min) {
  930. if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
  931. if (value > max || value < min) throw new RangeError('value is out of bounds')
  932. if (offset + ext > buf.length) throw new RangeError('index out of range')
  933. }
  934. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  935. value = +value
  936. offset = offset | 0
  937. byteLength = byteLength | 0
  938. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  939. var mul = 1
  940. var i = 0
  941. this[offset] = value & 0xFF
  942. while (++i < byteLength && (mul *= 0x100)) {
  943. this[offset + i] = (value / mul) & 0xFF
  944. }
  945. return offset + byteLength
  946. }
  947. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  948. value = +value
  949. offset = offset | 0
  950. byteLength = byteLength | 0
  951. if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  952. var i = byteLength - 1
  953. var mul = 1
  954. this[offset + i] = value & 0xFF
  955. while (--i >= 0 && (mul *= 0x100)) {
  956. this[offset + i] = (value / mul) & 0xFF
  957. }
  958. return offset + byteLength
  959. }
  960. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  961. value = +value
  962. offset = offset | 0
  963. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  964. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  965. this[offset] = (value & 0xff)
  966. return offset + 1
  967. }
  968. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  969. if (value < 0) value = 0xffff + value + 1
  970. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
  971. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  972. (littleEndian ? i : 1 - i) * 8
  973. }
  974. }
  975. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  976. value = +value
  977. offset = offset | 0
  978. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  979. if (Buffer.TYPED_ARRAY_SUPPORT) {
  980. this[offset] = (value & 0xff)
  981. this[offset + 1] = (value >>> 8)
  982. } else {
  983. objectWriteUInt16(this, value, offset, true)
  984. }
  985. return offset + 2
  986. }
  987. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  988. value = +value
  989. offset = offset | 0
  990. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  991. if (Buffer.TYPED_ARRAY_SUPPORT) {
  992. this[offset] = (value >>> 8)
  993. this[offset + 1] = (value & 0xff)
  994. } else {
  995. objectWriteUInt16(this, value, offset, false)
  996. }
  997. return offset + 2
  998. }
  999. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1000. if (value < 0) value = 0xffffffff + value + 1
  1001. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
  1002. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1003. }
  1004. }
  1005. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1006. value = +value
  1007. offset = offset | 0
  1008. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1009. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1010. this[offset + 3] = (value >>> 24)
  1011. this[offset + 2] = (value >>> 16)
  1012. this[offset + 1] = (value >>> 8)
  1013. this[offset] = (value & 0xff)
  1014. } else {
  1015. objectWriteUInt32(this, value, offset, true)
  1016. }
  1017. return offset + 4
  1018. }
  1019. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1020. value = +value
  1021. offset = offset | 0
  1022. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1023. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1024. this[offset] = (value >>> 24)
  1025. this[offset + 1] = (value >>> 16)
  1026. this[offset + 2] = (value >>> 8)
  1027. this[offset + 3] = (value & 0xff)
  1028. } else {
  1029. objectWriteUInt32(this, value, offset, false)
  1030. }
  1031. return offset + 4
  1032. }
  1033. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1034. value = +value
  1035. offset = offset | 0
  1036. if (!noAssert) {
  1037. var limit = Math.pow(2, 8 * byteLength - 1)
  1038. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1039. }
  1040. var i = 0
  1041. var mul = 1
  1042. var sub = value < 0 ? 1 : 0
  1043. this[offset] = value & 0xFF
  1044. while (++i < byteLength && (mul *= 0x100)) {
  1045. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1046. }
  1047. return offset + byteLength
  1048. }
  1049. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1050. value = +value
  1051. offset = offset | 0
  1052. if (!noAssert) {
  1053. var limit = Math.pow(2, 8 * byteLength - 1)
  1054. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1055. }
  1056. var i = byteLength - 1
  1057. var mul = 1
  1058. var sub = value < 0 ? 1 : 0
  1059. this[offset + i] = value & 0xFF
  1060. while (--i >= 0 && (mul *= 0x100)) {
  1061. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1062. }
  1063. return offset + byteLength
  1064. }
  1065. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1066. value = +value
  1067. offset = offset | 0
  1068. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1069. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1070. if (value < 0) value = 0xff + value + 1
  1071. this[offset] = (value & 0xff)
  1072. return offset + 1
  1073. }
  1074. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1075. value = +value
  1076. offset = offset | 0
  1077. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1078. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1079. this[offset] = (value & 0xff)
  1080. this[offset + 1] = (value >>> 8)
  1081. } else {
  1082. objectWriteUInt16(this, value, offset, true)
  1083. }
  1084. return offset + 2
  1085. }
  1086. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1087. value = +value
  1088. offset = offset | 0
  1089. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1090. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1091. this[offset] = (value >>> 8)
  1092. this[offset + 1] = (value & 0xff)
  1093. } else {
  1094. objectWriteUInt16(this, value, offset, false)
  1095. }
  1096. return offset + 2
  1097. }
  1098. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1099. value = +value
  1100. offset = offset | 0
  1101. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1102. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1103. this[offset] = (value & 0xff)
  1104. this[offset + 1] = (value >>> 8)
  1105. this[offset + 2] = (value >>> 16)
  1106. this[offset + 3] = (value >>> 24)
  1107. } else {
  1108. objectWriteUInt32(this, value, offset, true)
  1109. }
  1110. return offset + 4
  1111. }
  1112. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1113. value = +value
  1114. offset = offset | 0
  1115. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1116. if (value < 0) value = 0xffffffff + value + 1
  1117. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1118. this[offset] = (value >>> 24)
  1119. this[offset + 1] = (value >>> 16)
  1120. this[offset + 2] = (value >>> 8)
  1121. this[offset + 3] = (value & 0xff)
  1122. } else {
  1123. objectWriteUInt32(this, value, offset, false)
  1124. }
  1125. return offset + 4
  1126. }
  1127. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1128. if (value > max || value < min) throw new RangeError('value is out of bounds')
  1129. if (offset + ext > buf.length) throw new RangeError('index out of range')
  1130. if (offset < 0) throw new RangeError('index out of range')
  1131. }
  1132. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1133. if (!noAssert) {
  1134. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1135. }
  1136. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1137. return offset + 4
  1138. }
  1139. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1140. return writeFloat(this, value, offset, true, noAssert)
  1141. }
  1142. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1143. return writeFloat(this, value, offset, false, noAssert)
  1144. }
  1145. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1146. if (!noAssert) {
  1147. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1148. }
  1149. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1150. return offset + 8
  1151. }
  1152. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1153. return writeDouble(this, value, offset, true, noAssert)
  1154. }
  1155. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1156. return writeDouble(this, value, offset, false, noAssert)
  1157. }
  1158. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1159. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1160. if (!start) start = 0
  1161. if (!end && end !== 0) end = this.length
  1162. if (targetStart >= target.length) targetStart = target.length
  1163. if (!targetStart) targetStart = 0
  1164. if (end > 0 && end < start) end = start
  1165. // Copy 0 bytes; we're done
  1166. if (end === start) return 0
  1167. if (target.length === 0 || this.length === 0) return 0
  1168. // Fatal error conditions
  1169. if (targetStart < 0) {
  1170. throw new RangeError('targetStart out of bounds')
  1171. }
  1172. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1173. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1174. // Are we oob?
  1175. if (end > this.length) end = this.length
  1176. if (target.length - targetStart < end - start) {
  1177. end = target.length - targetStart + start
  1178. }
  1179. var len = end - start
  1180. var i
  1181. if (this === target && start < targetStart && targetStart < end) {
  1182. // descending copy from end
  1183. for (i = len - 1; i >= 0; i--) {
  1184. target[i + targetStart] = this[i + start]
  1185. }
  1186. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1187. // ascending copy from start
  1188. for (i = 0; i < len; i++) {
  1189. target[i + targetStart] = this[i + start]
  1190. }
  1191. } else {
  1192. target._set(this.subarray(start, start + len), targetStart)
  1193. }
  1194. return len
  1195. }
  1196. // fill(value, start=0, end=buffer.length)
  1197. Buffer.prototype.fill = function fill (value, start, end) {
  1198. if (!value) value = 0
  1199. if (!start) start = 0
  1200. if (!end) end = this.length
  1201. if (end < start) throw new RangeError('end < start')
  1202. // Fill 0 bytes; we're done
  1203. if (end === start) return
  1204. if (this.length === 0) return
  1205. if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
  1206. if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
  1207. var i
  1208. if (typeof value === 'number') {
  1209. for (i = start; i < end; i++) {
  1210. this[i] = value
  1211. }
  1212. } else {
  1213. var bytes = utf8ToBytes(value.toString())
  1214. var len = bytes.length
  1215. for (i = start; i < end; i++) {
  1216. this[i] = bytes[i % len]
  1217. }
  1218. }
  1219. return this
  1220. }
  1221. /**
  1222. * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  1223. * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  1224. */
  1225. Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
  1226. if (typeof Uint8Array !== 'undefined') {
  1227. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1228. return (new Buffer(this)).buffer
  1229. } else {
  1230. var buf = new Uint8Array(this.length)
  1231. for (var i = 0, len = buf.length; i < len; i += 1) {
  1232. buf[i] = this[i]
  1233. }
  1234. return buf.buffer
  1235. }
  1236. } else {
  1237. throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
  1238. }
  1239. }
  1240. // HELPER FUNCTIONS
  1241. // ================
  1242. var BP = Buffer.prototype
  1243. /**
  1244. * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  1245. */
  1246. Buffer._augment = function _augment (arr) {
  1247. arr.constructor = Buffer
  1248. arr._isBuffer = true
  1249. // save reference to original Uint8Array set method before overwriting
  1250. arr._set = arr.set
  1251. // deprecated
  1252. arr.get = BP.get
  1253. arr.set = BP.set
  1254. arr.write = BP.write
  1255. arr.toString = BP.toString
  1256. arr.toLocaleString = BP.toString
  1257. arr.toJSON = BP.toJSON
  1258. arr.equals = BP.equals
  1259. arr.compare = BP.compare
  1260. arr.indexOf = BP.indexOf
  1261. arr.copy = BP.copy
  1262. arr.slice = BP.slice
  1263. arr.readUIntLE = BP.readUIntLE
  1264. arr.readUIntBE = BP.readUIntBE
  1265. arr.readUInt8 = BP.readUInt8
  1266. arr.readUInt16LE = BP.readUInt16LE
  1267. arr.readUInt16BE = BP.readUInt16BE
  1268. arr.readUInt32LE = BP.readUInt32LE
  1269. arr.readUInt32BE = BP.readUInt32BE
  1270. arr.readIntLE = BP.readIntLE
  1271. arr.readIntBE = BP.readIntBE
  1272. arr.readInt8 = BP.readInt8
  1273. arr.readInt16LE = BP.readInt16LE
  1274. arr.readInt16BE = BP.readInt16BE
  1275. arr.readInt32LE = BP.readInt32LE
  1276. arr.readInt32BE = BP.readInt32BE
  1277. arr.readFloatLE = BP.readFloatLE
  1278. arr.readFloatBE = BP.readFloatBE
  1279. arr.readDoubleLE = BP.readDoubleLE
  1280. arr.readDoubleBE = BP.readDoubleBE
  1281. arr.writeUInt8 = BP.writeUInt8
  1282. arr.writeUIntLE = BP.writeUIntLE
  1283. arr.writeUIntBE = BP.writeUIntBE
  1284. arr.writeUInt16LE = BP.writeUInt16LE
  1285. arr.writeUInt16BE = BP.writeUInt16BE
  1286. arr.writeUInt32LE = BP.writeUInt32LE
  1287. arr.writeUInt32BE = BP.writeUInt32BE
  1288. arr.writeIntLE = BP.writeIntLE
  1289. arr.writeIntBE = BP.writeIntBE
  1290. arr.writeInt8 = BP.writeInt8
  1291. arr.writeInt16LE = BP.writeInt16LE
  1292. arr.writeInt16BE = BP.writeInt16BE
  1293. arr.writeInt32LE = BP.writeInt32LE
  1294. arr.writeInt32BE = BP.writeInt32BE
  1295. arr.writeFloatLE = BP.writeFloatLE
  1296. arr.writeFloatBE = BP.writeFloatBE
  1297. arr.writeDoubleLE = BP.writeDoubleLE
  1298. arr.writeDoubleBE = BP.writeDoubleBE
  1299. arr.fill = BP.fill
  1300. arr.inspect = BP.inspect
  1301. arr.toArrayBuffer = BP.toArrayBuffer
  1302. return arr
  1303. }
  1304. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1305. function base64clean (str) {
  1306. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1307. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1308. // Node converts strings with length < 2 to ''
  1309. if (str.length < 2) return ''
  1310. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1311. while (str.length % 4 !== 0) {
  1312. str = str + '='
  1313. }
  1314. return str
  1315. }
  1316. function stringtrim (str) {
  1317. if (str.trim) return str.trim()
  1318. return str.replace(/^\s+|\s+$/g, '')
  1319. }
  1320. function toHex (n) {
  1321. if (n < 16) return '0' + n.toString(16)
  1322. return n.toString(16)
  1323. }
  1324. function utf8ToBytes (string, units) {
  1325. units = units || Infinity
  1326. var codePoint
  1327. var length = string.length
  1328. var leadSurrogate = null
  1329. var bytes = []
  1330. for (var i = 0; i < length; i++) {
  1331. codePoint = string.charCodeAt(i)
  1332. // is surrogate component
  1333. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1334. // last char was a lead
  1335. if (!leadSurrogate) {
  1336. // no lead yet
  1337. if (codePoint > 0xDBFF) {
  1338. // unexpected trail
  1339. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1340. continue
  1341. } else if (i + 1 === length) {
  1342. // unpaired lead
  1343. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1344. continue
  1345. }
  1346. // valid lead
  1347. leadSurrogate = codePoint
  1348. continue
  1349. }
  1350. // 2 leads in a row
  1351. if (codePoint < 0xDC00) {
  1352. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1353. leadSurrogate = codePoint
  1354. continue
  1355. }
  1356. // valid surrogate pair
  1357. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1358. } else if (leadSurrogate) {
  1359. // valid bmp char, but last char was a lead
  1360. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1361. }
  1362. leadSurrogate = null
  1363. // encode utf8
  1364. if (codePoint < 0x80) {
  1365. if ((units -= 1) < 0) break
  1366. bytes.push(codePoint)
  1367. } else if (codePoint < 0x800) {
  1368. if ((units -= 2) < 0) break
  1369. bytes.push(
  1370. codePoint >> 0x6 | 0xC0,
  1371. codePoint & 0x3F | 0x80
  1372. )
  1373. } else if (codePoint < 0x10000) {
  1374. if ((units -= 3) < 0) break
  1375. bytes.push(
  1376. codePoint >> 0xC | 0xE0,
  1377. codePoint >> 0x6 & 0x3F | 0x80,
  1378. codePoint & 0x3F | 0x80
  1379. )
  1380. } else if (codePoint < 0x110000) {
  1381. if ((units -= 4) < 0) break
  1382. bytes.push(
  1383. codePoint >> 0x12 | 0xF0,
  1384. codePoint >> 0xC & 0x3F | 0x80,
  1385. codePoint >> 0x6 & 0x3F | 0x80,
  1386. codePoint & 0x3F | 0x80
  1387. )
  1388. } else {
  1389. throw new Error('Invalid code point')
  1390. }
  1391. }
  1392. return bytes
  1393. }
  1394. function asciiToBytes (str) {
  1395. var byteArray = []
  1396. for (var i = 0; i < str.length; i++) {
  1397. // Node's code seems to be doing this and not & 0x7F..
  1398. byteArray.push(str.charCodeAt(i) & 0xFF)
  1399. }
  1400. return byteArray
  1401. }
  1402. function utf16leToBytes (str, units) {
  1403. var c, hi, lo
  1404. var byteArray = []
  1405. for (var i = 0; i < str.length; i++) {
  1406. if ((units -= 2) < 0) break
  1407. c = str.charCodeAt(i)
  1408. hi = c >> 8
  1409. lo = c % 256
  1410. byteArray.push(lo)
  1411. byteArray.push(hi)
  1412. }
  1413. return byteArray
  1414. }
  1415. function base64ToBytes (str) {
  1416. return base64.toByteArray(base64clean(str))
  1417. }
  1418. function blitBuffer (src, dst, offset, length) {
  1419. for (var i = 0; i < length; i++) {
  1420. if ((i + offset >= dst.length) || (i >= src.length)) break
  1421. dst[i + offset] = src[i]
  1422. }
  1423. return i
  1424. }
  1425. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1426. },{"base64-js":1,"ieee754":4,"isarray":3}],3:[function(require,module,exports){
  1427. var toString = {}.toString;
  1428. module.exports = Array.isArray || function (arr) {
  1429. return toString.call(arr) == '[object Array]';
  1430. };
  1431. },{}],4:[function(require,module,exports){
  1432. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  1433. var e, m
  1434. var eLen = (nBytes * 8) - mLen - 1
  1435. var eMax = (1 << eLen) - 1
  1436. var eBias = eMax >> 1
  1437. var nBits = -7
  1438. var i = isLE ? (nBytes - 1) : 0
  1439. var d = isLE ? -1 : 1
  1440. var s = buffer[offset + i]
  1441. i += d
  1442. e = s & ((1 << (-nBits)) - 1)
  1443. s >>= (-nBits)
  1444. nBits += eLen
  1445. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1446. m = e & ((1 << (-nBits)) - 1)
  1447. e >>= (-nBits)
  1448. nBits += mLen
  1449. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1450. if (e === 0) {
  1451. e = 1 - eBias
  1452. } else if (e === eMax) {
  1453. return m ? NaN : ((s ? -1 : 1) * Infinity)
  1454. } else {
  1455. m = m + Math.pow(2, mLen)
  1456. e = e - eBias
  1457. }
  1458. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  1459. }
  1460. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  1461. var e, m, c
  1462. var eLen = (nBytes * 8) - mLen - 1
  1463. var eMax = (1 << eLen) - 1
  1464. var eBias = eMax >> 1
  1465. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  1466. var i = isLE ? 0 : (nBytes - 1)
  1467. var d = isLE ? 1 : -1
  1468. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  1469. value = Math.abs(value)
  1470. if (isNaN(value) || value === Infinity) {
  1471. m = isNaN(value) ? 1 : 0
  1472. e = eMax
  1473. } else {
  1474. e = Math.floor(Math.log(value) / Math.LN2)
  1475. if (value * (c = Math.pow(2, -e)) < 1) {
  1476. e--
  1477. c *= 2
  1478. }
  1479. if (e + eBias >= 1) {
  1480. value += rt / c
  1481. } else {
  1482. value += rt * Math.pow(2, 1 - eBias)
  1483. }
  1484. if (value * c >= 2) {
  1485. e++
  1486. c /= 2
  1487. }
  1488. if (e + eBias >= eMax) {
  1489. m = 0
  1490. e = eMax
  1491. } else if (e + eBias >= 1) {
  1492. m = ((value * c) - 1) * Math.pow(2, mLen)
  1493. e = e + eBias
  1494. } else {
  1495. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  1496. e = 0
  1497. }
  1498. }
  1499. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  1500. e = (e << mLen) | m
  1501. eLen += mLen
  1502. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  1503. buffer[offset + i - d] |= s * 128
  1504. }
  1505. },{}],5:[function(require,module,exports){
  1506. exports.v4 = require('./lib/ipv4.js').v4;
  1507. exports.v6 = require('./lib/ipv6.js').v6;
  1508. },{"./lib/ipv4.js":7,"./lib/ipv6.js":8}],6:[function(require,module,exports){
  1509. 'use strict';
  1510. var repeatString = exports.repeatString = function (s, n) {
  1511. var result = '';
  1512. var i;
  1513. for (i = 0; i < n; i++) {
  1514. result += s;
  1515. }
  1516. return result;
  1517. };
  1518. exports.zeroPad = function (s, n) {
  1519. return String(repeatString(0, n) + s).slice(n * -1);
  1520. };
  1521. // A wrapper function that returns false if the address is not valid; used to
  1522. // avoid boilerplate checks for `if (!this.valid) { return false; }`
  1523. var falseIfInvalid = exports.falseIfInvalid = function (fn) {
  1524. return function () {
  1525. if (!this.valid) {
  1526. return false;
  1527. }
  1528. return fn.apply(this, arguments);
  1529. };
  1530. };
  1531. exports.isInSubnet = falseIfInvalid(function (address) {
  1532. if (this.subnetMask < address.subnetMask) {
  1533. return false;
  1534. }
  1535. if (this.mask(address.subnetMask) === address.mask()) {
  1536. return true;
  1537. }
  1538. return false;
  1539. });
  1540. exports.isCorrect = function (defaultBits) {
  1541. return falseIfInvalid(function () {
  1542. if (this.addressMinusSuffix !== this.correctForm()) {
  1543. return false;
  1544. }
  1545. if (this.subnetMask === defaultBits && !this.parsedSubnet) {
  1546. return true;
  1547. }
  1548. return this.parsedSubnet === String(this.subnetMask);
  1549. });
  1550. };
  1551. },{}],7:[function(require,module,exports){
  1552. 'use strict';
  1553. var BigInteger = require('jsbn');
  1554. var common = require('./common.js');
  1555. var merge = require('lodash.merge');
  1556. var sprintf = require('sprintf').sprintf;
  1557. var v4 = exports.v4 = {};
  1558. merge(v4, require('./v4/constants.js'));
  1559. /*
  1560. * Instantiates an IPv4 address
  1561. */
  1562. v4.Address = function (address) {
  1563. this.valid = false;
  1564. this.address = address;
  1565. this.groups = v4.GROUPS;
  1566. this.v4 = true;
  1567. this.subnet = '/32';
  1568. this.subnetMask = 32;
  1569. var subnet = v4.RE_SUBNET_STRING.exec(address);
  1570. if (subnet) {
  1571. this.parsedSubnet = subnet[0].replace('/', '');
  1572. this.subnetMask = parseInt(this.parsedSubnet, 10);
  1573. this.subnet = '/' + this.subnetMask;
  1574. if (this.subnetMask < 0 || this.subnetMask > v4.BITS) {
  1575. this.valid = false;
  1576. this.error = 'Invalid subnet mask.';
  1577. return;
  1578. }
  1579. address = address.replace(v4.RE_SUBNET_STRING, '');
  1580. }
  1581. this.addressMinusSuffix = address;
  1582. this.parsedAddress = this.parse(address);
  1583. };
  1584. /*
  1585. * Parses a v4 address
  1586. */
  1587. v4.Address.prototype.parse = function (address) {
  1588. var groups = address.split('.');
  1589. if (address.match(v4.RE_ADDRESS)) {
  1590. this.valid = true;
  1591. } else {
  1592. this.error = 'Invalid IPv4 address.';
  1593. }
  1594. return groups;
  1595. };
  1596. /*
  1597. * Returns true if the address is valid
  1598. */
  1599. v4.Address.prototype.isValid = function () {
  1600. return this.valid;
  1601. };
  1602. /*
  1603. * Returns the correct form of an address
  1604. */
  1605. v4.Address.prototype.correctForm = function () {
  1606. return this.parsedAddress.map(function (part) {
  1607. return parseInt(part, 10);
  1608. }).join('.');
  1609. };
  1610. /*
  1611. * Returns true if the address is correct, false otherwise
  1612. */
  1613. v4.Address.prototype.isCorrect = common.isCorrect(v4.BITS);
  1614. /*
  1615. * Converts a hex string to an IPv4 address object
  1616. */
  1617. v4.Address.fromHex = function (hex) {
  1618. var padded = common.zeroPad(hex.replace(/:/g, ''), 8);
  1619. var groups = [];
  1620. var i;
  1621. for (i = 0; i < 8; i += 2) {
  1622. var h = padded.slice(i, i + 2);
  1623. groups.push(parseInt(h, 16));
  1624. }
  1625. return new v4.Address(groups.join('.'));
  1626. };
  1627. /*
  1628. * Converts an integer into a IPv4 address object
  1629. */
  1630. v4.Address.fromInteger = function (integer) {
  1631. return v4.Address.fromHex(integer.toString(16));
  1632. };
  1633. /*
  1634. * Converts an IPv4 address object to a hex string
  1635. */
  1636. v4.Address.prototype.toHex = function () {
  1637. return this.parsedAddress.map(function (part) {
  1638. return sprintf('%02x', parseInt(part, 10));
  1639. }).join(':');
  1640. };
  1641. /*
  1642. * Converts an IPv4 address object to an array of bytes
  1643. */
  1644. v4.Address.prototype.toArray = function () {
  1645. return this.parsedAddress.map(function (part) {
  1646. return parseInt(part, 10);
  1647. });
  1648. };
  1649. /*
  1650. * Converts an IPv4 address object to an IPv6 address group
  1651. */
  1652. v4.Address.prototype.toV6Group = function () {
  1653. var output = [];
  1654. var i;
  1655. for (i = 0; i < v4.GROUPS; i += 2) {
  1656. var hex = sprintf('%02x%02x',
  1657. parseInt(this.parsedAddress[i], 10),
  1658. parseInt(this.parsedAddress[i + 1], 10));
  1659. output.push(sprintf('%x', parseInt(hex, 16)));
  1660. }
  1661. return output.join(':');
  1662. };
  1663. /*
  1664. * Returns the address as a BigInteger
  1665. */
  1666. v4.Address.prototype.bigInteger = function () {
  1667. if (!this.valid) {
  1668. return null;
  1669. }
  1670. return new BigInteger(this.parsedAddress.map(function (n) {
  1671. return sprintf('%02x', parseInt(n, 10));
  1672. }).join(''), 16);
  1673. };
  1674. /*
  1675. * The first address in the range given by this address' subnet.
  1676. * Often referred to as the Network Address.
  1677. */
  1678. v4.Address.prototype.startAddress = function () {
  1679. var startAddress = new BigInteger(this.mask() +
  1680. common.repeatString(0, v4.BITS - this.subnetMask), 2);
  1681. return v4.Address.fromBigInteger(startAddress);
  1682. };
  1683. /*
  1684. * The last address in the range given by this address' subnet
  1685. * Often referred to as the Broadcast
  1686. */
  1687. v4.Address.prototype.endAddress = function () {
  1688. var endAddress = new BigInteger(this.mask() +
  1689. common.repeatString(1, v4.BITS - this.subnetMask), 2);
  1690. return v4.Address.fromBigInteger(endAddress);
  1691. };
  1692. /*
  1693. * Converts a BigInteger to a v4 address object
  1694. */
  1695. v4.Address.fromBigInteger = function (bigInteger) {
  1696. return v4.Address.fromInteger(parseInt(bigInteger.toString(), 10));
  1697. };
  1698. /*
  1699. * Returns the first n bits of the address, defaulting to the
  1700. * subnet mask
  1701. */
  1702. v4.Address.prototype.mask = function (optionalMask) {
  1703. if (optionalMask === undefined) {
  1704. optionalMask = this.subnetMask;
  1705. }
  1706. return this.getBitsBase2(0, optionalMask);
  1707. };
  1708. /*
  1709. * Returns the bits in the given range as a base-2 string
  1710. */
  1711. v4.Address.prototype.getBitsBase2 = function (start, end) {
  1712. return this.binaryZeroPad().slice(start, end);
  1713. };
  1714. /*
  1715. * Returns true if the given address is in the subnet of the current address
  1716. */
  1717. v4.Address.prototype.isInSubnet = common.isInSubnet;
  1718. /*
  1719. * Returns a zero-padded base-2 string representation of the address
  1720. */
  1721. v4.Address.prototype.binaryZeroPad = function () {
  1722. return common.zeroPad(this.bigInteger().toString(2), v4.BITS);
  1723. };
  1724. },{"./common.js":6,"./v4/constants.js":9,"jsbn":15,"lodash.merge":36,"sprintf":44}],8:[function(require,module,exports){
  1725. 'use strict';
  1726. var BigInteger = require('jsbn');
  1727. var common = require('./common.js');
  1728. var find = require('lodash.find');
  1729. var merge = require('lodash.merge');
  1730. var sprintf = require('sprintf').sprintf;
  1731. var v4 = require('./ipv4.js').v4;
  1732. var v6 = exports.v6 = {
  1733. helpers: require('./v6/helpers.js')
  1734. };
  1735. merge(v6, require('./v6/constants.js'));
  1736. function addCommas(number) {
  1737. var r = /(\d+)(\d{3})/;
  1738. while (r.test(number)) {
  1739. number = number.replace(r, '$1,$2');
  1740. }
  1741. return number;
  1742. }
  1743. function spanLeadingZeroes4(n) {
  1744. n = n.replace(/^(0{1,})([1-9]+)$/, '<span class="parse-error">$1</span>$2');
  1745. n = n.replace(/^(0{1,})(0)$/, '<span class="parse-error">$1</span>$2');
  1746. return n;
  1747. }
  1748. /*
  1749. * Instantiates an IPv6 address
  1750. */
  1751. v6.Address = function (address, optionalGroups) {
  1752. if (optionalGroups === undefined) {
  1753. this.groups = v6.GROUPS;
  1754. } else {
  1755. this.groups = optionalGroups;
  1756. }
  1757. this.v4 = false;
  1758. this.subnet = '/128';
  1759. this.subnetMask = 128;
  1760. this.zone = '';
  1761. this.address = address;
  1762. var subnet = v6.RE_SUBNET_STRING.exec(address);
  1763. if (subnet) {
  1764. this.parsedSubnet = subnet[0].replace('/', '');
  1765. this.subnetMask = parseInt(this.parsedSubnet, 10);
  1766. this.subnet = '/' + this.subnetMask;
  1767. if (isNaN(this.subnetMask) ||
  1768. this.subnetMask < 0 ||
  1769. this.subnetMask > v6.BITS) {
  1770. this.valid = false;
  1771. this.error = 'Invalid subnet mask.';
  1772. return;
  1773. }
  1774. address = address.replace(v6.RE_SUBNET_STRING, '');
  1775. } else if (/\//.test(address)) {
  1776. this.valid = false;
  1777. this.error = 'Invalid subnet mask.';
  1778. return;
  1779. }
  1780. var zone = v6.RE_ZONE_STRING.exec(address);
  1781. if (zone) {
  1782. this.zone = zone[0];
  1783. address = address.replace(v6.RE_ZONE_STRING, '');
  1784. }
  1785. this.addressMinusSuffix = address;
  1786. this.parsedAddress = this.parse(this.addressMinusSuffix);
  1787. };
  1788. merge(v6.Address.prototype, require('./v6/attributes.js'));
  1789. merge(v6.Address.prototype, require('./v6/html.js'));
  1790. merge(v6.Address.prototype, require('./v6/regular-expressions.js'));
  1791. /*
  1792. * Converts a BigInteger to a v6 address object
  1793. */
  1794. v6.Address.fromBigInteger = function (bigInteger) {
  1795. var hex = common.zeroPad(bigInteger.toString(16), 32);
  1796. var groups = [];
  1797. var i;
  1798. for (i = 0; i < v6.GROUPS; i++) {
  1799. groups.push(hex.slice(i * 4, (i + 1) * 4));
  1800. }
  1801. return new v6.Address(groups.join(':'));
  1802. };
  1803. /*
  1804. * Converts a URL (optional port number) to an address object
  1805. */
  1806. v6.Address.fromURL = function (url) {
  1807. var host;
  1808. var port;
  1809. var result;
  1810. // If we have brackets parse them and find a port
  1811. if (url.indexOf('[') !== -1 && url.indexOf(']:') !== -1) {
  1812. result = v6.RE_URL_WITH_PORT.exec(url);
  1813. if (result === null) {
  1814. return {
  1815. error: 'failed to parse address with port',
  1816. address: null,
  1817. port: null
  1818. };
  1819. }
  1820. host = result[1];
  1821. port = result[2];
  1822. // If there's a URL extract the address
  1823. } else if (url.indexOf('/') !== -1) {
  1824. // Remove the protocol prefix
  1825. url = url.replace(/^[a-z0-9]+:\/\//, '');
  1826. // Parse the address
  1827. result = v6.RE_URL.exec(url);
  1828. if (result === null) {
  1829. return {
  1830. error: 'failed to parse address from URL',
  1831. address: null,
  1832. port: null
  1833. };
  1834. }
  1835. host = result[1];
  1836. // Otherwise just assign the URL to the host and let the library parse it
  1837. } else {
  1838. host = url;
  1839. }
  1840. // If there's a port convert it to an integer
  1841. if (port) {
  1842. port = parseInt(port, 10);
  1843. //squelch out of range ports
  1844. if (port < 0 || port > 65536) {
  1845. port = null;
  1846. }
  1847. } else {
  1848. // Standardize `undefined` to `null`
  1849. port = null;
  1850. }
  1851. return {
  1852. address: new v6.Address(host),
  1853. port: port
  1854. };
  1855. };
  1856. /*
  1857. * Create an IPv6-mapped address given an IPv4 address
  1858. */
  1859. v6.Address.fromAddress4 = function (address4) {
  1860. return new v6.Address('::ffff:' + address4);
  1861. };
  1862. /*
  1863. * A helper function to compact an array
  1864. */
  1865. v6.Address.compact = function (address, slice) {
  1866. var s1 = [];
  1867. var s2 = [];
  1868. var i;
  1869. for (i = 0; i < address.length; i++) {
  1870. if (i < slice[0]) {
  1871. s1.push(address[i]);
  1872. } else if (i > slice[1]) {
  1873. s2.push(address[i]);
  1874. }
  1875. }
  1876. return s1.concat(['compact']).concat(s2);
  1877. };
  1878. /*
  1879. * Returns the Microsoft UNC transcription of the address
  1880. */
  1881. v6.Address.prototype.microsoftTranscription = function () {
  1882. return sprintf('%s.ipv6-literal.net',
  1883. this.correctForm().replace(/:/g, '-'));
  1884. };
  1885. /*
  1886. * Returns the first n bits of the address, defaulting to the
  1887. * subnet mask
  1888. */
  1889. v6.Address.prototype.mask = function (optionalMask) {
  1890. if (optionalMask === undefined) {
  1891. optionalMask = this.subnetMask;
  1892. }
  1893. return this.getBitsBase2(0, optionalMask);
  1894. };
  1895. /*
  1896. * Returns the number of possible subnets of a given size in the address
  1897. */
  1898. v6.Address.prototype.possibleSubnets = function (optionalSubnetSize) {
  1899. if (optionalSubnetSize === undefined) {
  1900. optionalSubnetSize = 128;
  1901. }
  1902. var availableBits = v6.BITS - this.subnetMask;
  1903. var subnetBits = Math.abs(optionalSubnetSize - v6.BITS);
  1904. var subnetPowers = availableBits - subnetBits;
  1905. if (subnetPowers < 0) {
  1906. return '0';
  1907. }
  1908. return addCommas(new BigInteger('2', 10).pow(subnetPowers).toString(10));
  1909. };
  1910. /*
  1911. * The first address in the range given by this address' subnet
  1912. */
  1913. v6.Address.prototype.startAddress = function () {
  1914. var startAddress = new BigInteger(this.mask() +
  1915. common.repeatString(0, v6.BITS - this.subnetMask), 2);
  1916. return v6.Address.fromBigInteger(startAddress);
  1917. };
  1918. /*
  1919. * The last address in the range given by this address' subnet
  1920. */
  1921. v6.Address.prototype.endAddress = function () {
  1922. var endAddress = new BigInteger(this.mask() +
  1923. common.repeatString(1, v6.BITS - this.subnetMask), 2);
  1924. return v6.Address.fromBigInteger(endAddress);
  1925. };
  1926. /*
  1927. * Returns the scope of the address
  1928. */
  1929. v6.Address.prototype.getScope = function () {
  1930. var scope = v6.SCOPES[this.getBits(12, 16)];
  1931. if (this.getType() === 'Global unicast' &&
  1932. scope !== 'Link local') {
  1933. scope = 'Global';
  1934. }
  1935. return scope;
  1936. };
  1937. /*
  1938. * Returns the type of the address
  1939. */
  1940. v6.Address.prototype.getType = function () {
  1941. var self = this;
  1942. function isType(name, type) {
  1943. return self.isInSubnet(new v6.Address(type));
  1944. }
  1945. return find(v6.TYPES, isType) || 'Global unicast';
  1946. };
  1947. /*
  1948. * Returns the bits in the given range as a BigInteger
  1949. */
  1950. v6.Address.prototype.getBits = function (start, end) {
  1951. return new BigInteger(this.getBitsBase2(start, end), 2);
  1952. };
  1953. /*
  1954. * Returns the bits in the given range as a base-2 string
  1955. */
  1956. v6.Address.prototype.getBitsBase2 = function (start, end) {
  1957. return this.binaryZeroPad().slice(start, end);
  1958. };
  1959. /*
  1960. * Returns the bits in the given range as a base-16 string
  1961. */
  1962. v6.Address.prototype.getBitsBase16 = function (start, end) {
  1963. var length = end - start;
  1964. if (length % 4 !== 0) {
  1965. return null;
  1966. }
  1967. return common.zeroPad(this.getBits(start, end).toString(16), length / 4);
  1968. };
  1969. /*
  1970. * Returns the bits that are set past the subnet mask length
  1971. */
  1972. v6.Address.prototype.getBitsPastSubnet = function () {
  1973. return this.getBitsBase2(this.subnetMask, v6.BITS);
  1974. };
  1975. /*
  1976. * Returns the reversed ip6.arpa form of the address
  1977. */
  1978. v6.Address.prototype.reverseForm = function () {
  1979. var characters = Math.floor(this.subnetMask / 4);
  1980. var reversed = this.canonicalForm()
  1981. .replace(/:/g, '')
  1982. .split('')
  1983. .slice(0, characters)
  1984. .reverse()
  1985. .join('.');
  1986. if (characters > 0) {
  1987. return sprintf('%s.ip6.arpa.', reversed);
  1988. }
  1989. return 'ip6.arpa.';
  1990. };
  1991. /*
  1992. * Returns the correct form of the address
  1993. */
  1994. v6.Address.prototype.correctForm = function () {
  1995. if (!this.parsedAddress) {
  1996. return null;
  1997. }
  1998. var i;
  1999. var groups = [];
  2000. var zeroCounter = 0;
  2001. var zeroes = [];
  2002. for (i = 0; i < this.parsedAddress.length; i++) {
  2003. var value = parseInt(this.parsedAddress[i], 16);
  2004. if (value === 0) {
  2005. zeroCounter++;
  2006. }
  2007. if (value !== 0 && zeroCounter > 0) {
  2008. if (zeroCounter > 1) {
  2009. zeroes.push([i - zeroCounter, i - 1]);
  2010. }
  2011. zeroCounter = 0;
  2012. }
  2013. }
  2014. // Do we end with a string of zeroes?
  2015. if (zeroCounter > 1) {
  2016. zeroes.push([this.parsedAddress.length - zeroCounter,
  2017. this.parsedAddress.length - 1]);
  2018. }
  2019. var zeroLengths = zeroes.map(function (n) {
  2020. return (n[1] - n[0]) + 1;
  2021. });
  2022. if (zeroes.length > 0) {
  2023. var max = Math.max.apply(Math, zeroLengths);
  2024. var index = zeroLengths.indexOf(max);
  2025. groups = v6.Address.compact(this.parsedAddress, zeroes[index]);
  2026. } else {
  2027. groups = this.parsedAddress;
  2028. }
  2029. for (i = 0; i < groups.length; i++) {
  2030. if (groups[i] !== 'compact') {
  2031. groups[i] = parseInt(groups[i], 16).toString(16);
  2032. }
  2033. }
  2034. var correct = groups.join(':');
  2035. correct = correct.replace(/^compact$/, '::');
  2036. correct = correct.replace(/^compact|compact$/, ':');
  2037. correct = correct.replace(/compact/, '');
  2038. return correct;
  2039. };
  2040. /*
  2041. * Returns a zero-padded base-2 string representation of the address
  2042. */
  2043. v6.Address.prototype.binaryZeroPad = function () {
  2044. return common.zeroPad(this.bigInteger().toString(2), v6.BITS);
  2045. };
  2046. // TODO: Improve the semantics of this helper function
  2047. v6.Address.prototype.parse4in6 = function (address) {
  2048. var groups = address.split(':');
  2049. var lastGroup = groups.slice(-1)[0];
  2050. var address4 = lastGroup.match(v4.RE_ADDRESS);
  2051. if (address4) {
  2052. var temp4 = new v4.Address(address4[0]);
  2053. for (var i = 0; i < temp4.groups; i++) {
  2054. if (/^0[0-9]+/.test(temp4.parsedAddress[i])) {
  2055. this.valid = false;
  2056. this.error = 'IPv4 addresses can not have leading zeroes.';
  2057. this.parseError = address.replace(v4.RE_ADDRESS,
  2058. temp4.parsedAddress.map(spanLeadingZeroes4).join('.'));
  2059. return null;
  2060. }
  2061. }
  2062. this.v4 = true;
  2063. groups[groups.length - 1] = temp4.toV6Group();
  2064. address = groups.join(':');
  2065. }
  2066. return address;
  2067. };
  2068. // TODO: Make private?
  2069. v6.Address.prototype.parse = function (address) {
  2070. address = this.parse4in6(address);
  2071. if (this.error) {
  2072. return null;
  2073. }
  2074. var badCharacters = address.match(v6.RE_BAD_CHARACTERS);
  2075. if (badCharacters) {
  2076. this.valid = false;
  2077. this.error = sprintf('Bad character%s detected in address: %s',
  2078. badCharacters.length > 1 ? 's' : '', badCharacters.join(''));
  2079. this.parseError = address.replace(v6.RE_BAD_CHARACTERS,
  2080. '<span class="parse-error">$1</span>');
  2081. return null;
  2082. }
  2083. var badAddress = address.match(v6.RE_BAD_ADDRESS);
  2084. if (badAddress) {
  2085. this.valid = false;
  2086. this.error = sprintf('Address failed regex: %s', badAddress.join(''));
  2087. this.parseError = address.replace(v6.RE_BAD_ADDRESS,
  2088. '<span class="parse-error">$1</span>');
  2089. return null;
  2090. }
  2091. var groups = [];
  2092. var halves = address.split('::');
  2093. if (halves.length === 2) {
  2094. var first = halves[0].split(':');
  2095. var last = halves[1].split(':');
  2096. if (first.length === 1 &&
  2097. first[0] === '') {
  2098. first = [];
  2099. }
  2100. if (last.length === 1 &&
  2101. last[0] === '') {
  2102. last = [];
  2103. }
  2104. var remaining = this.groups - (first.length + last.length);
  2105. if (!remaining) {
  2106. this.valid = false;
  2107. this.error = 'Error parsing groups';
  2108. return null;
  2109. }
  2110. this.elidedGroups = remaining;
  2111. this.elisionBegin = first.length;
  2112. this.elisionEnd = first.length + this.elidedGroups;
  2113. first.forEach(function (group) {
  2114. groups.push(group);
  2115. });
  2116. for (var i = 0; i < remaining; i++) {
  2117. groups.push(0);
  2118. }
  2119. last.forEach(function (group) {
  2120. groups.push(group);
  2121. });
  2122. } else if (halves.length === 1) {
  2123. groups = address.split(':');
  2124. this.elidedGroups = 0;
  2125. } else {
  2126. this.valid = false;
  2127. this.error = 'Too many :: groups found';
  2128. return null;
  2129. }
  2130. groups = groups.map(function (g) {
  2131. return sprintf('%x', parseInt(g, 16));
  2132. });
  2133. if (groups.length !== this.groups) {
  2134. this.valid = false;
  2135. this.error = 'Incorrect number of groups found';
  2136. return null;
  2137. }
  2138. this.valid = true;
  2139. return groups;
  2140. };
  2141. /*
  2142. * Returns the canonical form of the address
  2143. */
  2144. v6.Address.prototype.canonicalForm = function () {
  2145. if (!this.valid) {
  2146. return null;
  2147. }
  2148. return this.parsedAddress.map(function (n) {
  2149. return sprintf('%04x', parseInt(n, 16));
  2150. }).join(':');
  2151. };
  2152. /*
  2153. * Returns the decimal form of the address
  2154. */
  2155. v6.Address.prototype.decimal = function () {
  2156. if (!this.valid) {
  2157. return null;
  2158. }
  2159. return this.parsedAddress.map(function (n) {
  2160. return sprintf('%05d', parseInt(n, 16));
  2161. }).join(':');
  2162. };
  2163. /*
  2164. * Returns the address as a BigInteger
  2165. */
  2166. v6.Address.prototype.bigInteger = function () {
  2167. if (!this.valid) {
  2168. return null;
  2169. }
  2170. return new BigInteger(this.parsedAddress.map(function (n) {
  2171. return sprintf('%04x', parseInt(n, 16));
  2172. }).join(''), 16);
  2173. };
  2174. v6.Address.prototype.tov4 = function () {
  2175. var binary = this.binaryZeroPad().split('');
  2176. return v4.Address.fromHex(new BigInteger(binary.slice(96, 128)
  2177. .join(''), 2).toString(16));
  2178. };
  2179. /*
  2180. * Returns the v4-in-v6 form of the address
  2181. */
  2182. v6.Address.prototype.v4inv6 = function () {
  2183. var address4 = this.tov4();
  2184. var address6 = new v6.Address(this.parsedAddress.slice(0, 6).join(':'), 6);
  2185. var correct = address6.correctForm();
  2186. var infix = '';
  2187. if (!/:$/.test(correct)) {
  2188. infix = ':';
  2189. }
  2190. return address6.correctForm() + infix + address4.address;
  2191. };
  2192. /*
  2193. * Returns an object containing the Teredo properties of the address
  2194. */
  2195. v6.Address.prototype.teredo = function () {
  2196. /*
  2197. - Bits 0 to 31 are set to the Teredo prefix (normally 2001:0000::/32).
  2198. - Bits 32 to 63 embed the primary IPv4 address of the Teredo server that
  2199. is used.
  2200. - Bits 64 to 79 can be used to define some flags. Currently only the
  2201. higher order bit is used; it is set to 1 if the Teredo client is
  2202. located behind a cone NAT, 0 otherwise. For Microsoft's Windows Vista
  2203. and Windows Server 2008 implementations, more bits are used. In those
  2204. implementations, the format for these 16 bits is "CRAAAAUG AAAAAAAA",
  2205. where "C" remains the "Cone" flag. The "R" bit is reserved for future
  2206. use. The "U" bit is for the Universal/Local flag (set to 0). The "G" bit
  2207. is Individual/Group flag (set to 0). The A bits are set to a 12-bit
  2208. randomly generated number chosen by the Teredo client to introduce
  2209. additional protection for the Teredo node against IPv6-based scanning
  2210. attacks.
  2211. - Bits 80 to 95 contains the obfuscated UDP port number. This is the
  2212. port number that is mapped by the NAT to the Teredo client with all
  2213. bits inverted.
  2214. - Bits 96 to 127 contains the obfuscated IPv4 address. This is the
  2215. public IPv4 address of the NAT with all bits inverted.
  2216. */
  2217. var prefix = this.getBitsBase16(0, 32);
  2218. var udpPort = this.getBits(80, 96).xor(new BigInteger('ffff', 16)).toString();
  2219. var server4 = v4.Address.fromHex(this.getBitsBase16(32, 64));
  2220. var client4 = v4.Address.fromHex(this.getBits(96, 128)
  2221. .xor(new BigInteger('ffffffff', 16)).toString(16));
  2222. var flags = this.getBits(64, 80);
  2223. var flagsBase2 = this.getBitsBase2(64, 80);
  2224. var coneNat = flags.testBit(15);
  2225. var reserved = flags.testBit(14);
  2226. var groupIndividual = flags.testBit(8);
  2227. var universalLocal = flags.testBit(9);
  2228. var nonce = new BigInteger(flagsBase2.slice(2, 6) +
  2229. flagsBase2.slice(8, 16), 2).toString(10);
  2230. return {
  2231. prefix: sprintf('%s:%s', prefix.slice(0, 4), prefix.slice(4, 8)),
  2232. server4: server4.address,
  2233. client4: client4.address,
  2234. flags: flagsBase2,
  2235. coneNat: coneNat,
  2236. microsoft: {
  2237. reserved: reserved,
  2238. universalLocal: universalLocal,
  2239. groupIndividual: groupIndividual,
  2240. nonce: nonce
  2241. },
  2242. udpPort: udpPort
  2243. };
  2244. };
  2245. /*
  2246. * Returns an object containing the 6to4 properties of the address
  2247. */
  2248. v6.Address.prototype.six2four = function () {
  2249. /*
  2250. - Bits 0 to 15 are set to the 6to4 prefix (2002::/16).
  2251. - Bits 16 to 48 embed the IPv4 address of the 6to4 gateway that is used.
  2252. */
  2253. var prefix = this.getBitsBase16(0, 16);
  2254. var gateway = v4.Address.fromHex(this.getBitsBase16(16, 48));
  2255. return {
  2256. prefix: sprintf('%s', prefix.slice(0, 4)),
  2257. gateway: gateway.address
  2258. };
  2259. };
  2260. /*
  2261. * Returns a v6 6to4 address from a v6 v4inv6 address.
  2262. */
  2263. v6.Address.prototype.get6to4 = function () {
  2264. if (!this.is4()) {
  2265. return null;
  2266. }
  2267. var addr6to4 = [
  2268. '2002',
  2269. this.getBitsBase16(96, 112),
  2270. this.getBitsBase16(112, 128),
  2271. '',
  2272. '/16'
  2273. ].join(':');
  2274. return new v6.Address(addr6to4);
  2275. };
  2276. v6.Address.prototype.toByteArray = function () {
  2277. return this.bigInteger().toByteArray();
  2278. };
  2279. v6.Address.prototype.toUnsignedByteArray = function () {
  2280. return this.toByteArray().map(function (b) {
  2281. return b & 0xFF;
  2282. });
  2283. };
  2284. v6.Address.fromUnsignedByteArray = function (bytes) {
  2285. var BYTE_MAX = new BigInteger('256', 10);
  2286. var result = new BigInteger('0', 10);
  2287. var multiplier = new BigInteger('1', 10);
  2288. for (var i = bytes.length - 1; i >= 0; i--) {
  2289. result = result.add(
  2290. multiplier.multiply(new BigInteger(bytes[i].toString(10), 10)));
  2291. multiplier = multiplier.multiply(BYTE_MAX);
  2292. }
  2293. return v6.Address.fromBigInteger(result);
  2294. };
  2295. v6.Address.fromByteArray = function (bytes) {
  2296. return this.fromUnsignedByteArray(bytes.map(function (b) {
  2297. return b & 0xFF;
  2298. }));
  2299. };
  2300. },{"./common.js":6,"./ipv4.js":7,"./v6/attributes.js":10,"./v6/constants.js":11,"./v6/helpers.js":12,"./v6/html.js":13,"./v6/regular-expressions.js":14,"jsbn":15,"lodash.find":29,"lodash.merge":36,"sprintf":44}],9:[function(require,module,exports){
  2301. exports.BITS = 32;
  2302. exports.GROUPS = 4;
  2303. exports.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
  2304. exports.RE_SUBNET_STRING = /\/\d{1,2}$/;
  2305. },{}],10:[function(require,module,exports){
  2306. 'use strict';
  2307. var common = require('../common.js');
  2308. var v6 = require('./constants.js');
  2309. /*
  2310. * Returns true if the address is valid, false otherwise
  2311. */
  2312. exports.isValid = function () {
  2313. return this.valid;
  2314. };
  2315. /*
  2316. * Returns true if the given address is in the subnet of the current address
  2317. */
  2318. exports.isInSubnet = common.isInSubnet;
  2319. /*
  2320. * Returns true if the address is correct, false otherwise
  2321. */
  2322. exports.isCorrect = common.isCorrect(v6.BITS);
  2323. /*
  2324. * Returns true if the address is in the canonical form, false otherwise
  2325. */
  2326. exports.isCanonical = common.falseIfInvalid(function () {
  2327. return this.addressMinusSuffix === this.canonicalForm();
  2328. });
  2329. /*
  2330. * Returns true if the address is a link local address, false otherwise
  2331. */
  2332. exports.isLinkLocal = common.falseIfInvalid(function () {
  2333. // Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10'
  2334. if (this.getBitsBase2(0, 64) ===
  2335. '1111111010000000000000000000000000000000000000000000000000000000') {
  2336. return true;
  2337. }
  2338. return false;
  2339. });
  2340. /*
  2341. * Returns true if the address is a multicast address, false otherwise
  2342. */
  2343. exports.isMulticast = common.falseIfInvalid(function () {
  2344. return this.getType() === 'Multicast';
  2345. });
  2346. /*
  2347. * Returns true if the address is a v4-in-v6 address, false otherwise
  2348. */
  2349. exports.is4 = common.falseIfInvalid(function () {
  2350. return this.v4;
  2351. });
  2352. /*
  2353. * Returns true if the address is a Teredo address, false otherwise
  2354. */
  2355. exports.isTeredo = common.falseIfInvalid(function () {
  2356. return this.isInSubnet(new this.constructor('2001::/32'));
  2357. });
  2358. /*
  2359. * Returns true if the address is a 6to4 address, false otherwise
  2360. */
  2361. exports.is6to4 = common.falseIfInvalid(function () {
  2362. return this.isInSubnet(new this.constructor('2002::/16'));
  2363. });
  2364. /*
  2365. * Returns true if the address is a loopback address, false otherwise
  2366. */
  2367. exports.isLoopback = common.falseIfInvalid(function () {
  2368. return this.getType() === 'Loopback';
  2369. });
  2370. },{"../common.js":6,"./constants.js":11}],11:[function(require,module,exports){
  2371. exports.BITS = 128;
  2372. exports.GROUPS = 8;
  2373. exports.SCOPES = {
  2374. 0: 'Reserved',
  2375. 1: 'Interface local',
  2376. 2: 'Link local',
  2377. 4: 'Admin local',
  2378. 5: 'Site local',
  2379. 8: 'Organization local',
  2380. 15: 'Global',
  2381. 16: 'Reserved'
  2382. };
  2383. // TODO: Add ff0x::fb, etc. for multicast DNS
  2384. exports.TYPES = {
  2385. 'ff01::1/128': 'Multicast (All nodes on this interface)',
  2386. 'ff01::2/128': 'Multicast (All routers on this interface)',
  2387. 'ff02::1/128': 'Multicast (All nodes on this link)',
  2388. 'ff02::2/128': 'Multicast (All routers on this link)',
  2389. 'ff05::2/128': 'Multicast (All routers in this site)',
  2390. 'ff02::5/128': 'Multicast (OSPFv3 AllSPF routers)',
  2391. 'ff02::6/128': 'Multicast (OSPFv3 AllDR routers)',
  2392. 'ff02::9/128': 'Multicast (RIP routers)',
  2393. 'ff02::a/128': 'Multicast (EIGRP routers)',
  2394. 'ff02::d/128': 'Multicast (PIM routers)',
  2395. 'ff02::16/128': 'Multicast (MLDv2 reports)',
  2396. 'ff01::fb/128': 'Multicast (mDNSv6)',
  2397. 'ff02::fb/128': 'Multicast (mDNSv6)',
  2398. 'ff05::fb/128': 'Multicast (mDNSv6)',
  2399. 'ff02::1:2/128': 'Multicast (All DHCP servers and relay agents on this link)',
  2400. 'ff05::1:2/128': 'Multicast (All DHCP servers and relay agents in this site)',
  2401. 'ff02::1:3/128': 'Multicast (All DHCP servers on this link)',
  2402. 'ff05::1:3/128': 'Multicast (All DHCP servers in this site)',
  2403. '::/128': 'Unspecified',
  2404. '::1/128': 'Loopback',
  2405. 'ff00::/8': 'Multicast',
  2406. 'fe80::/10': 'Link-local unicast'
  2407. };
  2408. exports.RE_BAD_CHARACTERS = /([^0-9a-f:\/%])/ig;
  2409. exports.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/ig;
  2410. exports.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
  2411. exports.RE_ZONE_STRING = /%.*$/;
  2412. exports.RE_URL = new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);
  2413. exports.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
  2414. },{}],12:[function(require,module,exports){
  2415. 'use strict';
  2416. var sprintf = require('sprintf');
  2417. /*
  2418. * Returns the string with all zeroes contained in a <span>
  2419. */
  2420. var spanAllZeroes = exports.spanAllZeroes = function (s) {
  2421. return s.replace(/(0+)/g, '<span class="zero">$1</span>');
  2422. };
  2423. /*
  2424. * Returns the string with each character contained in a <span>
  2425. */
  2426. exports.spanAll = function (s, optionalOffset) {
  2427. if (optionalOffset === undefined) {
  2428. optionalOffset = 0;
  2429. }
  2430. var letters = s.split('');
  2431. return letters.map(function (n, i) {
  2432. return sprintf('<span class="digit value-%s position-%d">%s</span>', n,
  2433. i + optionalOffset,
  2434. spanAllZeroes(n)); // XXX Use #base-2 .value-0 instead?
  2435. }).join('');
  2436. };
  2437. function spanLeadingZeroesSimple(group) {
  2438. return group.replace(/^(0+)/, '<span class="zero">$1</span>');
  2439. }
  2440. /*
  2441. * Returns the string with leading zeroes contained in a <span>
  2442. */
  2443. exports.spanLeadingZeroes = function (address) {
  2444. var groups = address.split(':');
  2445. return groups.map(function (g) {
  2446. return spanLeadingZeroesSimple(g);
  2447. }).join(':');
  2448. };
  2449. /*
  2450. * Groups an address
  2451. */
  2452. exports.simpleGroup = function (addressString, offset) {
  2453. var groups = addressString.split(':');
  2454. if (!offset) {
  2455. offset = 0;
  2456. }
  2457. return groups.map(function (g, i) {
  2458. if (/group-v4/.test(g)) {
  2459. return g;
  2460. }
  2461. return sprintf('<span class="hover-group group-%d">%s</span>',
  2462. i + offset,
  2463. spanLeadingZeroesSimple(g));
  2464. }).join(':');
  2465. };
  2466. },{"sprintf":44}],13:[function(require,module,exports){
  2467. 'use strict';
  2468. var constants4 = require('../v4/constants.js');
  2469. var helpers = require('./helpers.js');
  2470. var sprintf = require('sprintf').sprintf;
  2471. /*
  2472. * Returns the address in link form with a default port of 80
  2473. */
  2474. exports.href = function (optionalPort) {
  2475. if (optionalPort === undefined) {
  2476. optionalPort = '';
  2477. } else {
  2478. optionalPort = sprintf(':%s', optionalPort);
  2479. }
  2480. return sprintf('http://[%s]%s/', this.correctForm(), optionalPort);
  2481. };
  2482. /*
  2483. * Returns a link suitable for conveying the address via a URL hash
  2484. */
  2485. exports.link = function (options) {
  2486. if (!options) {
  2487. options = {};
  2488. }
  2489. if (options.className === undefined) {
  2490. options.className = '';
  2491. }
  2492. if (options.prefix === undefined) {
  2493. options.prefix = '/#address=';
  2494. }
  2495. if (options.v4 === undefined) {
  2496. options.v4 = false;
  2497. }
  2498. var formFunction = this.correctForm;
  2499. if (options.v4) {
  2500. formFunction = this.v4inv6;
  2501. }
  2502. if (options.className) {
  2503. return sprintf('<a href="%1$s%2$s" class="%3$s">%2$s</a>',
  2504. options.prefix, formFunction.call(this), options.className);
  2505. }
  2506. return sprintf('<a href="%1$s%2$s">%2$s</a>', options.prefix,
  2507. formFunction.call(this));
  2508. };
  2509. /*
  2510. * Groups an address
  2511. */
  2512. exports.group = function () {
  2513. var address4 = this.address.match(constants4.RE_ADDRESS);
  2514. var i;
  2515. if (address4) {
  2516. // The IPv4 case
  2517. var segments = address4[0].split('.');
  2518. this.address = this.address.replace(constants4.RE_ADDRESS,
  2519. sprintf('<span class="hover-group group-v4 group-6">%s</span>' +
  2520. '.' +
  2521. '<span class="hover-group group-v4 group-7">%s</span>',
  2522. segments.slice(0, 2).join('.'),
  2523. segments.slice(2, 4).join('.')));
  2524. }
  2525. if (this.elidedGroups === 0) {
  2526. // The simple case
  2527. return helpers.simpleGroup(this.address);
  2528. }
  2529. // The elided case
  2530. var output = [];
  2531. var halves = this.address.split('::');
  2532. if (halves[0].length) {
  2533. output.push(helpers.simpleGroup(halves[0]));
  2534. } else {
  2535. output.push('');
  2536. }
  2537. var classes = ['hover-group'];
  2538. for (i = this.elisionBegin;
  2539. i < this.elisionBegin + this.elidedGroups; i++) {
  2540. classes.push(sprintf('group-%d', i));
  2541. }
  2542. output.push(sprintf('<span class="%s"></span>', classes.join(' ')));
  2543. if (halves[1].length) {
  2544. output.push(helpers.simpleGroup(halves[1], this.elisionEnd));
  2545. } else {
  2546. output.push('');
  2547. }
  2548. return output.join(':');
  2549. };
  2550. },{"../v4/constants.js":9,"./helpers.js":12,"sprintf":44}],14:[function(require,module,exports){
  2551. 'use strict';
  2552. var sprintf = require('sprintf').sprintf;
  2553. var v6 = require('./constants.js');
  2554. function groupPossibilities(possibilities) {
  2555. return sprintf('(%s)', possibilities.join('|'));
  2556. }
  2557. function padGroup(group) {
  2558. if (group.length < 4) {
  2559. return sprintf('0{0,%d}%s', 4 - group.length, group);
  2560. }
  2561. return group;
  2562. }
  2563. function simpleRegularExpression(groups) {
  2564. var zeroIndexes = [];
  2565. groups.forEach(function (group, i) {
  2566. var groupInteger = parseInt(group, 16);
  2567. if (groupInteger === 0) {
  2568. zeroIndexes.push(i);
  2569. }
  2570. });
  2571. // You can technically elide a single 0, this creates the regular expressions
  2572. // to match that eventuality
  2573. var possibilities = zeroIndexes.map(function (zeroIndex) {
  2574. return groups.map(function (group, i) {
  2575. if (i === zeroIndex) {
  2576. var elision = (i === 0 || i === v6.GROUPS - 1) ? ':' : '';
  2577. return groupPossibilities([padGroup(group), elision]);
  2578. }
  2579. return padGroup(group);
  2580. }).join(':');
  2581. });
  2582. // The simplest case
  2583. possibilities.push(groups.map(padGroup).join(':'));
  2584. return groupPossibilities(possibilities);
  2585. }
  2586. function possibleElisions(elidedGroups, moreLeft, moreRight) {
  2587. var left = moreLeft ? '' : ':';
  2588. var right = moreRight ? '' : ':';
  2589. var possibilities = [];
  2590. // 1. elision of everything (::)
  2591. if (!moreLeft && !moreRight) {
  2592. possibilities.push('::');
  2593. }
  2594. // 2. complete elision of the middle
  2595. if (moreLeft && moreRight) {
  2596. possibilities.push('');
  2597. }
  2598. if ((moreRight && !moreLeft) || (!moreRight && moreLeft)) {
  2599. // 3. complete elision of one side
  2600. possibilities.push(':');
  2601. }
  2602. // 4. elision from the left side
  2603. possibilities.push(sprintf('%s(:0{1,4}){1,%d}', left, elidedGroups - 1));
  2604. // 5. elision from the right side
  2605. possibilities.push(sprintf('(0{1,4}:){1,%d}%s', elidedGroups - 1, right));
  2606. // 6. no elision
  2607. possibilities.push(sprintf('(0{1,4}:){%d}0{1,4}', elidedGroups - 1));
  2608. // 7. elision (including sloppy elision) from the middle
  2609. for (var groups = 1; groups < elidedGroups - 1; groups++) {
  2610. for (var position = 1; position < elidedGroups - groups; position++) {
  2611. possibilities.push(sprintf('(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}',
  2612. position,
  2613. elidedGroups - position - groups - 1));
  2614. }
  2615. }
  2616. return groupPossibilities(possibilities);
  2617. }
  2618. /*
  2619. * Generate a regular expression string that can be used to find or validate all
  2620. * variations of this address.
  2621. */
  2622. exports.regularExpressionString = function (optionalSubString) {
  2623. if (optionalSubString === undefined) {
  2624. optionalSubString = false;
  2625. }
  2626. var output = [];
  2627. // TODO: revisit why this is necessary
  2628. var address6 = new this.constructor(this.correctForm());
  2629. if (address6.elidedGroups === 0) {
  2630. // The simple case
  2631. output.push(simpleRegularExpression(address6.parsedAddress));
  2632. } else if (address6.elidedGroups === v6.GROUPS) {
  2633. // A completely elided address
  2634. output.push(possibleElisions(v6.GROUPS));
  2635. } else {
  2636. // A partially elided address
  2637. var halves = address6.address.split('::');
  2638. if (halves[0].length) {
  2639. output.push(simpleRegularExpression(halves[0].split(':')));
  2640. }
  2641. output.push(possibleElisions(address6.elidedGroups,
  2642. halves[0].length !== 0,
  2643. halves[1].length !== 0));
  2644. if (halves[1].length) {
  2645. output.push(simpleRegularExpression(halves[1].split(':')));
  2646. }
  2647. output = [output.join(':')];
  2648. }
  2649. if (!optionalSubString) {
  2650. output = [].concat('(?=^|\\b|[^\\w\\:])(', output, ')(?=[^\\w\\:]|\\b|$)');
  2651. }
  2652. return output.join('');
  2653. };
  2654. /*
  2655. * Generate a regular expression that can be used to find or validate all
  2656. * variations of this address.
  2657. */
  2658. exports.regularExpression = function (optionalSubstring) {
  2659. return new RegExp(this.regularExpressionString(optionalSubstring), 'i');
  2660. };
  2661. },{"./constants.js":11,"sprintf":44}],15:[function(require,module,exports){
  2662. (function(){
  2663. // Copyright (c) 2005 Tom Wu
  2664. // All Rights Reserved.
  2665. // See "LICENSE" for details.
  2666. // Basic JavaScript BN library - subset useful for RSA encryption.
  2667. // Bits per digit
  2668. var dbits;
  2669. // JavaScript engine analysis
  2670. var canary = 0xdeadbeefcafe;
  2671. var j_lm = ((canary&0xffffff)==0xefcafe);
  2672. // (public) Constructor
  2673. function BigInteger(a,b,c) {
  2674. if(a != null)
  2675. if("number" == typeof a) this.fromNumber(a,b,c);
  2676. else if(b == null && "string" != typeof a) this.fromString(a,256);
  2677. else this.fromString(a,b);
  2678. }
  2679. // return new, unset BigInteger
  2680. function nbi() { return new BigInteger(null); }
  2681. // am: Compute w_j += (x*this_i), propagate carries,
  2682. // c is initial carry, returns final carry.
  2683. // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
  2684. // We need to select the fastest one that works in this environment.
  2685. // am1: use a single mult and divide to get the high bits,
  2686. // max digit bits should be 26 because
  2687. // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
  2688. function am1(i,x,w,j,c,n) {
  2689. while(--n >= 0) {
  2690. var v = x*this[i++]+w[j]+c;
  2691. c = Math.floor(v/0x4000000);
  2692. w[j++] = v&0x3ffffff;
  2693. }
  2694. return c;
  2695. }
  2696. // am2 avoids a big mult-and-extract completely.
  2697. // Max digit bits should be <= 30 because we do bitwise ops
  2698. // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
  2699. function am2(i,x,w,j,c,n) {
  2700. var xl = x&0x7fff, xh = x>>15;
  2701. while(--n >= 0) {
  2702. var l = this[i]&0x7fff;
  2703. var h = this[i++]>>15;
  2704. var m = xh*l+h*xl;
  2705. l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
  2706. c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
  2707. w[j++] = l&0x3fffffff;
  2708. }
  2709. return c;
  2710. }
  2711. // Alternately, set max digit bits to 28 since some
  2712. // browsers slow down when dealing with 32-bit numbers.
  2713. function am3(i,x,w,j,c,n) {
  2714. var xl = x&0x3fff, xh = x>>14;
  2715. while(--n >= 0) {
  2716. var l = this[i]&0x3fff;
  2717. var h = this[i++]>>14;
  2718. var m = xh*l+h*xl;
  2719. l = xl*l+((m&0x3fff)<<14)+w[j]+c;
  2720. c = (l>>28)+(m>>14)+xh*h;
  2721. w[j++] = l&0xfffffff;
  2722. }
  2723. return c;
  2724. }
  2725. var inBrowser = typeof navigator !== "undefined";
  2726. if(inBrowser && j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
  2727. BigInteger.prototype.am = am2;
  2728. dbits = 30;
  2729. }
  2730. else if(inBrowser && j_lm && (navigator.appName != "Netscape")) {
  2731. BigInteger.prototype.am = am1;
  2732. dbits = 26;
  2733. }
  2734. else { // Mozilla/Netscape seems to prefer am3
  2735. BigInteger.prototype.am = am3;
  2736. dbits = 28;
  2737. }
  2738. BigInteger.prototype.DB = dbits;
  2739. BigInteger.prototype.DM = ((1<<dbits)-1);
  2740. BigInteger.prototype.DV = (1<<dbits);
  2741. var BI_FP = 52;
  2742. BigInteger.prototype.FV = Math.pow(2,BI_FP);
  2743. BigInteger.prototype.F1 = BI_FP-dbits;
  2744. BigInteger.prototype.F2 = 2*dbits-BI_FP;
  2745. // Digit conversions
  2746. var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
  2747. var BI_RC = new Array();
  2748. var rr,vv;
  2749. rr = "0".charCodeAt(0);
  2750. for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
  2751. rr = "a".charCodeAt(0);
  2752. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  2753. rr = "A".charCodeAt(0);
  2754. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  2755. function int2char(n) { return BI_RM.charAt(n); }
  2756. function intAt(s,i) {
  2757. var c = BI_RC[s.charCodeAt(i)];
  2758. return (c==null)?-1:c;
  2759. }
  2760. // (protected) copy this to r
  2761. function bnpCopyTo(r) {
  2762. for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
  2763. r.t = this.t;
  2764. r.s = this.s;
  2765. }
  2766. // (protected) set from integer value x, -DV <= x < DV
  2767. function bnpFromInt(x) {
  2768. this.t = 1;
  2769. this.s = (x<0)?-1:0;
  2770. if(x > 0) this[0] = x;
  2771. else if(x < -1) this[0] = x+DV;
  2772. else this.t = 0;
  2773. }
  2774. // return bigint initialized to value
  2775. function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
  2776. // (protected) set from string and radix
  2777. function bnpFromString(s,b) {
  2778. var k;
  2779. if(b == 16) k = 4;
  2780. else if(b == 8) k = 3;
  2781. else if(b == 256) k = 8; // byte array
  2782. else if(b == 2) k = 1;
  2783. else if(b == 32) k = 5;
  2784. else if(b == 4) k = 2;
  2785. else { this.fromRadix(s,b); return; }
  2786. this.t = 0;
  2787. this.s = 0;
  2788. var i = s.length, mi = false, sh = 0;
  2789. while(--i >= 0) {
  2790. var x = (k==8)?s[i]&0xff:intAt(s,i);
  2791. if(x < 0) {
  2792. if(s.charAt(i) == "-") mi = true;
  2793. continue;
  2794. }
  2795. mi = false;
  2796. if(sh == 0)
  2797. this[this.t++] = x;
  2798. else if(sh+k > this.DB) {
  2799. this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
  2800. this[this.t++] = (x>>(this.DB-sh));
  2801. }
  2802. else
  2803. this[this.t-1] |= x<<sh;
  2804. sh += k;
  2805. if(sh >= this.DB) sh -= this.DB;
  2806. }
  2807. if(k == 8 && (s[0]&0x80) != 0) {
  2808. this.s = -1;
  2809. if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
  2810. }
  2811. this.clamp();
  2812. if(mi) BigInteger.ZERO.subTo(this,this);
  2813. }
  2814. // (protected) clamp off excess high words
  2815. function bnpClamp() {
  2816. var c = this.s&this.DM;
  2817. while(this.t > 0 && this[this.t-1] == c) --this.t;
  2818. }
  2819. // (public) return string representation in given radix
  2820. function bnToString(b) {
  2821. if(this.s < 0) return "-"+this.negate().toString(b);
  2822. var k;
  2823. if(b == 16) k = 4;
  2824. else if(b == 8) k = 3;
  2825. else if(b == 2) k = 1;
  2826. else if(b == 32) k = 5;
  2827. else if(b == 4) k = 2;
  2828. else return this.toRadix(b);
  2829. var km = (1<<k)-1, d, m = false, r = "", i = this.t;
  2830. var p = this.DB-(i*this.DB)%k;
  2831. if(i-- > 0) {
  2832. if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
  2833. while(i >= 0) {
  2834. if(p < k) {
  2835. d = (this[i]&((1<<p)-1))<<(k-p);
  2836. d |= this[--i]>>(p+=this.DB-k);
  2837. }
  2838. else {
  2839. d = (this[i]>>(p-=k))&km;
  2840. if(p <= 0) { p += this.DB; --i; }
  2841. }
  2842. if(d > 0) m = true;
  2843. if(m) r += int2char(d);
  2844. }
  2845. }
  2846. return m?r:"0";
  2847. }
  2848. // (public) -this
  2849. function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
  2850. // (public) |this|
  2851. function bnAbs() { return (this.s<0)?this.negate():this; }
  2852. // (public) return + if this > a, - if this < a, 0 if equal
  2853. function bnCompareTo(a) {
  2854. var r = this.s-a.s;
  2855. if(r != 0) return r;
  2856. var i = this.t;
  2857. r = i-a.t;
  2858. if(r != 0) return (this.s<0)?-r:r;
  2859. while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
  2860. return 0;
  2861. }
  2862. // returns bit length of the integer x
  2863. function nbits(x) {
  2864. var r = 1, t;
  2865. if((t=x>>>16) != 0) { x = t; r += 16; }
  2866. if((t=x>>8) != 0) { x = t; r += 8; }
  2867. if((t=x>>4) != 0) { x = t; r += 4; }
  2868. if((t=x>>2) != 0) { x = t; r += 2; }
  2869. if((t=x>>1) != 0) { x = t; r += 1; }
  2870. return r;
  2871. }
  2872. // (public) return the number of bits in "this"
  2873. function bnBitLength() {
  2874. if(this.t <= 0) return 0;
  2875. return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
  2876. }
  2877. // (protected) r = this << n*DB
  2878. function bnpDLShiftTo(n,r) {
  2879. var i;
  2880. for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
  2881. for(i = n-1; i >= 0; --i) r[i] = 0;
  2882. r.t = this.t+n;
  2883. r.s = this.s;
  2884. }
  2885. // (protected) r = this >> n*DB
  2886. function bnpDRShiftTo(n,r) {
  2887. for(var i = n; i < this.t; ++i) r[i-n] = this[i];
  2888. r.t = Math.max(this.t-n,0);
  2889. r.s = this.s;
  2890. }
  2891. // (protected) r = this << n
  2892. function bnpLShiftTo(n,r) {
  2893. var bs = n%this.DB;
  2894. var cbs = this.DB-bs;
  2895. var bm = (1<<cbs)-1;
  2896. var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
  2897. for(i = this.t-1; i >= 0; --i) {
  2898. r[i+ds+1] = (this[i]>>cbs)|c;
  2899. c = (this[i]&bm)<<bs;
  2900. }
  2901. for(i = ds-1; i >= 0; --i) r[i] = 0;
  2902. r[ds] = c;
  2903. r.t = this.t+ds+1;
  2904. r.s = this.s;
  2905. r.clamp();
  2906. }
  2907. // (protected) r = this >> n
  2908. function bnpRShiftTo(n,r) {
  2909. r.s = this.s;
  2910. var ds = Math.floor(n/this.DB);
  2911. if(ds >= this.t) { r.t = 0; return; }
  2912. var bs = n%this.DB;
  2913. var cbs = this.DB-bs;
  2914. var bm = (1<<bs)-1;
  2915. r[0] = this[ds]>>bs;
  2916. for(var i = ds+1; i < this.t; ++i) {
  2917. r[i-ds-1] |= (this[i]&bm)<<cbs;
  2918. r[i-ds] = this[i]>>bs;
  2919. }
  2920. if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
  2921. r.t = this.t-ds;
  2922. r.clamp();
  2923. }
  2924. // (protected) r = this - a
  2925. function bnpSubTo(a,r) {
  2926. var i = 0, c = 0, m = Math.min(a.t,this.t);
  2927. while(i < m) {
  2928. c += this[i]-a[i];
  2929. r[i++] = c&this.DM;
  2930. c >>= this.DB;
  2931. }
  2932. if(a.t < this.t) {
  2933. c -= a.s;
  2934. while(i < this.t) {
  2935. c += this[i];
  2936. r[i++] = c&this.DM;
  2937. c >>= this.DB;
  2938. }
  2939. c += this.s;
  2940. }
  2941. else {
  2942. c += this.s;
  2943. while(i < a.t) {
  2944. c -= a[i];
  2945. r[i++] = c&this.DM;
  2946. c >>= this.DB;
  2947. }
  2948. c -= a.s;
  2949. }
  2950. r.s = (c<0)?-1:0;
  2951. if(c < -1) r[i++] = this.DV+c;
  2952. else if(c > 0) r[i++] = c;
  2953. r.t = i;
  2954. r.clamp();
  2955. }
  2956. // (protected) r = this * a, r != this,a (HAC 14.12)
  2957. // "this" should be the larger one if appropriate.
  2958. function bnpMultiplyTo(a,r) {
  2959. var x = this.abs(), y = a.abs();
  2960. var i = x.t;
  2961. r.t = i+y.t;
  2962. while(--i >= 0) r[i] = 0;
  2963. for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
  2964. r.s = 0;
  2965. r.clamp();
  2966. if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
  2967. }
  2968. // (protected) r = this^2, r != this (HAC 14.16)
  2969. function bnpSquareTo(r) {
  2970. var x = this.abs();
  2971. var i = r.t = 2*x.t;
  2972. while(--i >= 0) r[i] = 0;
  2973. for(i = 0; i < x.t-1; ++i) {
  2974. var c = x.am(i,x[i],r,2*i,0,1);
  2975. if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
  2976. r[i+x.t] -= x.DV;
  2977. r[i+x.t+1] = 1;
  2978. }
  2979. }
  2980. if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
  2981. r.s = 0;
  2982. r.clamp();
  2983. }
  2984. // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
  2985. // r != q, this != m. q or r may be null.
  2986. function bnpDivRemTo(m,q,r) {
  2987. var pm = m.abs();
  2988. if(pm.t <= 0) return;
  2989. var pt = this.abs();
  2990. if(pt.t < pm.t) {
  2991. if(q != null) q.fromInt(0);
  2992. if(r != null) this.copyTo(r);
  2993. return;
  2994. }
  2995. if(r == null) r = nbi();
  2996. var y = nbi(), ts = this.s, ms = m.s;
  2997. var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
  2998. if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
  2999. else { pm.copyTo(y); pt.copyTo(r); }
  3000. var ys = y.t;
  3001. var y0 = y[ys-1];
  3002. if(y0 == 0) return;
  3003. var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
  3004. var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
  3005. var i = r.t, j = i-ys, t = (q==null)?nbi():q;
  3006. y.dlShiftTo(j,t);
  3007. if(r.compareTo(t) >= 0) {
  3008. r[r.t++] = 1;
  3009. r.subTo(t,r);
  3010. }
  3011. BigInteger.ONE.dlShiftTo(ys,t);
  3012. t.subTo(y,y); // "negative" y so we can replace sub with am later
  3013. while(y.t < ys) y[y.t++] = 0;
  3014. while(--j >= 0) {
  3015. // Estimate quotient digit
  3016. var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
  3017. if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
  3018. y.dlShiftTo(j,t);
  3019. r.subTo(t,r);
  3020. while(r[i] < --qd) r.subTo(t,r);
  3021. }
  3022. }
  3023. if(q != null) {
  3024. r.drShiftTo(ys,q);
  3025. if(ts != ms) BigInteger.ZERO.subTo(q,q);
  3026. }
  3027. r.t = ys;
  3028. r.clamp();
  3029. if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
  3030. if(ts < 0) BigInteger.ZERO.subTo(r,r);
  3031. }
  3032. // (public) this mod a
  3033. function bnMod(a) {
  3034. var r = nbi();
  3035. this.abs().divRemTo(a,null,r);
  3036. if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
  3037. return r;
  3038. }
  3039. // Modular reduction using "classic" algorithm
  3040. function Classic(m) { this.m = m; }
  3041. function cConvert(x) {
  3042. if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
  3043. else return x;
  3044. }
  3045. function cRevert(x) { return x; }
  3046. function cReduce(x) { x.divRemTo(this.m,null,x); }
  3047. function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3048. function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3049. Classic.prototype.convert = cConvert;
  3050. Classic.prototype.revert = cRevert;
  3051. Classic.prototype.reduce = cReduce;
  3052. Classic.prototype.mulTo = cMulTo;
  3053. Classic.prototype.sqrTo = cSqrTo;
  3054. // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
  3055. // justification:
  3056. // xy == 1 (mod m)
  3057. // xy = 1+km
  3058. // xy(2-xy) = (1+km)(1-km)
  3059. // x[y(2-xy)] = 1-k^2m^2
  3060. // x[y(2-xy)] == 1 (mod m^2)
  3061. // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
  3062. // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
  3063. // JS multiply "overflows" differently from C/C++, so care is needed here.
  3064. function bnpInvDigit() {
  3065. if(this.t < 1) return 0;
  3066. var x = this[0];
  3067. if((x&1) == 0) return 0;
  3068. var y = x&3; // y == 1/x mod 2^2
  3069. y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
  3070. y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
  3071. y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
  3072. // last step - calculate inverse mod DV directly;
  3073. // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
  3074. y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
  3075. // we really want the negative inverse, and -DV < y < DV
  3076. return (y>0)?this.DV-y:-y;
  3077. }
  3078. // Montgomery reduction
  3079. function Montgomery(m) {
  3080. this.m = m;
  3081. this.mp = m.invDigit();
  3082. this.mpl = this.mp&0x7fff;
  3083. this.mph = this.mp>>15;
  3084. this.um = (1<<(m.DB-15))-1;
  3085. this.mt2 = 2*m.t;
  3086. }
  3087. // xR mod m
  3088. function montConvert(x) {
  3089. var r = nbi();
  3090. x.abs().dlShiftTo(this.m.t,r);
  3091. r.divRemTo(this.m,null,r);
  3092. if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
  3093. return r;
  3094. }
  3095. // x/R mod m
  3096. function montRevert(x) {
  3097. var r = nbi();
  3098. x.copyTo(r);
  3099. this.reduce(r);
  3100. return r;
  3101. }
  3102. // x = x/R mod m (HAC 14.32)
  3103. function montReduce(x) {
  3104. while(x.t <= this.mt2) // pad x so am has enough room later
  3105. x[x.t++] = 0;
  3106. for(var i = 0; i < this.m.t; ++i) {
  3107. // faster way of calculating u0 = x[i]*mp mod DV
  3108. var j = x[i]&0x7fff;
  3109. var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
  3110. // use am to combine the multiply-shift-add into one call
  3111. j = i+this.m.t;
  3112. x[j] += this.m.am(0,u0,x,i,0,this.m.t);
  3113. // propagate carry
  3114. while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
  3115. }
  3116. x.clamp();
  3117. x.drShiftTo(this.m.t,x);
  3118. if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
  3119. }
  3120. // r = "x^2/R mod m"; x != r
  3121. function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3122. // r = "xy/R mod m"; x,y != r
  3123. function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3124. Montgomery.prototype.convert = montConvert;
  3125. Montgomery.prototype.revert = montRevert;
  3126. Montgomery.prototype.reduce = montReduce;
  3127. Montgomery.prototype.mulTo = montMulTo;
  3128. Montgomery.prototype.sqrTo = montSqrTo;
  3129. // (protected) true iff this is even
  3130. function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
  3131. // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
  3132. function bnpExp(e,z) {
  3133. if(e > 0xffffffff || e < 1) return BigInteger.ONE;
  3134. var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
  3135. g.copyTo(r);
  3136. while(--i >= 0) {
  3137. z.sqrTo(r,r2);
  3138. if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
  3139. else { var t = r; r = r2; r2 = t; }
  3140. }
  3141. return z.revert(r);
  3142. }
  3143. // (public) this^e % m, 0 <= e < 2^32
  3144. function bnModPowInt(e,m) {
  3145. var z;
  3146. if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
  3147. return this.exp(e,z);
  3148. }
  3149. // protected
  3150. BigInteger.prototype.copyTo = bnpCopyTo;
  3151. BigInteger.prototype.fromInt = bnpFromInt;
  3152. BigInteger.prototype.fromString = bnpFromString;
  3153. BigInteger.prototype.clamp = bnpClamp;
  3154. BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
  3155. BigInteger.prototype.drShiftTo = bnpDRShiftTo;
  3156. BigInteger.prototype.lShiftTo = bnpLShiftTo;
  3157. BigInteger.prototype.rShiftTo = bnpRShiftTo;
  3158. BigInteger.prototype.subTo = bnpSubTo;
  3159. BigInteger.prototype.multiplyTo = bnpMultiplyTo;
  3160. BigInteger.prototype.squareTo = bnpSquareTo;
  3161. BigInteger.prototype.divRemTo = bnpDivRemTo;
  3162. BigInteger.prototype.invDigit = bnpInvDigit;
  3163. BigInteger.prototype.isEven = bnpIsEven;
  3164. BigInteger.prototype.exp = bnpExp;
  3165. // public
  3166. BigInteger.prototype.toString = bnToString;
  3167. BigInteger.prototype.negate = bnNegate;
  3168. BigInteger.prototype.abs = bnAbs;
  3169. BigInteger.prototype.compareTo = bnCompareTo;
  3170. BigInteger.prototype.bitLength = bnBitLength;
  3171. BigInteger.prototype.mod = bnMod;
  3172. BigInteger.prototype.modPowInt = bnModPowInt;
  3173. // "constants"
  3174. BigInteger.ZERO = nbv(0);
  3175. BigInteger.ONE = nbv(1);
  3176. // Copyright (c) 2005-2009 Tom Wu
  3177. // All Rights Reserved.
  3178. // See "LICENSE" for details.
  3179. // Extended JavaScript BN functions, required for RSA private ops.
  3180. // Version 1.1: new BigInteger("0", 10) returns "proper" zero
  3181. // Version 1.2: square() API, isProbablePrime fix
  3182. // (public)
  3183. function bnClone() { var r = nbi(); this.copyTo(r); return r; }
  3184. // (public) return value as integer
  3185. function bnIntValue() {
  3186. if(this.s < 0) {
  3187. if(this.t == 1) return this[0]-this.DV;
  3188. else if(this.t == 0) return -1;
  3189. }
  3190. else if(this.t == 1) return this[0];
  3191. else if(this.t == 0) return 0;
  3192. // assumes 16 < DB < 32
  3193. return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
  3194. }
  3195. // (public) return value as byte
  3196. function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
  3197. // (public) return value as short (assumes DB>=16)
  3198. function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
  3199. // (protected) return x s.t. r^x < DV
  3200. function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
  3201. // (public) 0 if this == 0, 1 if this > 0
  3202. function bnSigNum() {
  3203. if(this.s < 0) return -1;
  3204. else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
  3205. else return 1;
  3206. }
  3207. // (protected) convert to radix string
  3208. function bnpToRadix(b) {
  3209. if(b == null) b = 10;
  3210. if(this.signum() == 0 || b < 2 || b > 36) return "0";
  3211. var cs = this.chunkSize(b);
  3212. var a = Math.pow(b,cs);
  3213. var d = nbv(a), y = nbi(), z = nbi(), r = "";
  3214. this.divRemTo(d,y,z);
  3215. while(y.signum() > 0) {
  3216. r = (a+z.intValue()).toString(b).substr(1) + r;
  3217. y.divRemTo(d,y,z);
  3218. }
  3219. return z.intValue().toString(b) + r;
  3220. }
  3221. // (protected) convert from radix string
  3222. function bnpFromRadix(s,b) {
  3223. this.fromInt(0);
  3224. if(b == null) b = 10;
  3225. var cs = this.chunkSize(b);
  3226. var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
  3227. for(var i = 0; i < s.length; ++i) {
  3228. var x = intAt(s,i);
  3229. if(x < 0) {
  3230. if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
  3231. continue;
  3232. }
  3233. w = b*w+x;
  3234. if(++j >= cs) {
  3235. this.dMultiply(d);
  3236. this.dAddOffset(w,0);
  3237. j = 0;
  3238. w = 0;
  3239. }
  3240. }
  3241. if(j > 0) {
  3242. this.dMultiply(Math.pow(b,j));
  3243. this.dAddOffset(w,0);
  3244. }
  3245. if(mi) BigInteger.ZERO.subTo(this,this);
  3246. }
  3247. // (protected) alternate constructor
  3248. function bnpFromNumber(a,b,c) {
  3249. if("number" == typeof b) {
  3250. // new BigInteger(int,int,RNG)
  3251. if(a < 2) this.fromInt(1);
  3252. else {
  3253. this.fromNumber(a,c);
  3254. if(!this.testBit(a-1)) // force MSB set
  3255. this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
  3256. if(this.isEven()) this.dAddOffset(1,0); // force odd
  3257. while(!this.isProbablePrime(b)) {
  3258. this.dAddOffset(2,0);
  3259. if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
  3260. }
  3261. }
  3262. }
  3263. else {
  3264. // new BigInteger(int,RNG)
  3265. var x = new Array(), t = a&7;
  3266. x.length = (a>>3)+1;
  3267. b.nextBytes(x);
  3268. if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
  3269. this.fromString(x,256);
  3270. }
  3271. }
  3272. // (public) convert to bigendian byte array
  3273. function bnToByteArray() {
  3274. var i = this.t, r = new Array();
  3275. r[0] = this.s;
  3276. var p = this.DB-(i*this.DB)%8, d, k = 0;
  3277. if(i-- > 0) {
  3278. if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p)
  3279. r[k++] = d|(this.s<<(this.DB-p));
  3280. while(i >= 0) {
  3281. if(p < 8) {
  3282. d = (this[i]&((1<<p)-1))<<(8-p);
  3283. d |= this[--i]>>(p+=this.DB-8);
  3284. }
  3285. else {
  3286. d = (this[i]>>(p-=8))&0xff;
  3287. if(p <= 0) { p += this.DB; --i; }
  3288. }
  3289. if((d&0x80) != 0) d |= -256;
  3290. if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
  3291. if(k > 0 || d != this.s) r[k++] = d;
  3292. }
  3293. }
  3294. return r;
  3295. }
  3296. function bnEquals(a) { return(this.compareTo(a)==0); }
  3297. function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
  3298. function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
  3299. // (protected) r = this op a (bitwise)
  3300. function bnpBitwiseTo(a,op,r) {
  3301. var i, f, m = Math.min(a.t,this.t);
  3302. for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
  3303. if(a.t < this.t) {
  3304. f = a.s&this.DM;
  3305. for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
  3306. r.t = this.t;
  3307. }
  3308. else {
  3309. f = this.s&this.DM;
  3310. for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
  3311. r.t = a.t;
  3312. }
  3313. r.s = op(this.s,a.s);
  3314. r.clamp();
  3315. }
  3316. // (public) this & a
  3317. function op_and(x,y) { return x&y; }
  3318. function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
  3319. // (public) this | a
  3320. function op_or(x,y) { return x|y; }
  3321. function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
  3322. // (public) this ^ a
  3323. function op_xor(x,y) { return x^y; }
  3324. function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
  3325. // (public) this & ~a
  3326. function op_andnot(x,y) { return x&~y; }
  3327. function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
  3328. // (public) ~this
  3329. function bnNot() {
  3330. var r = nbi();
  3331. for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
  3332. r.t = this.t;
  3333. r.s = ~this.s;
  3334. return r;
  3335. }
  3336. // (public) this << n
  3337. function bnShiftLeft(n) {
  3338. var r = nbi();
  3339. if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
  3340. return r;
  3341. }
  3342. // (public) this >> n
  3343. function bnShiftRight(n) {
  3344. var r = nbi();
  3345. if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
  3346. return r;
  3347. }
  3348. // return index of lowest 1-bit in x, x < 2^31
  3349. function lbit(x) {
  3350. if(x == 0) return -1;
  3351. var r = 0;
  3352. if((x&0xffff) == 0) { x >>= 16; r += 16; }
  3353. if((x&0xff) == 0) { x >>= 8; r += 8; }
  3354. if((x&0xf) == 0) { x >>= 4; r += 4; }
  3355. if((x&3) == 0) { x >>= 2; r += 2; }
  3356. if((x&1) == 0) ++r;
  3357. return r;
  3358. }
  3359. // (public) returns index of lowest 1-bit (or -1 if none)
  3360. function bnGetLowestSetBit() {
  3361. for(var i = 0; i < this.t; ++i)
  3362. if(this[i] != 0) return i*this.DB+lbit(this[i]);
  3363. if(this.s < 0) return this.t*this.DB;
  3364. return -1;
  3365. }
  3366. // return number of 1 bits in x
  3367. function cbit(x) {
  3368. var r = 0;
  3369. while(x != 0) { x &= x-1; ++r; }
  3370. return r;
  3371. }
  3372. // (public) return number of set bits
  3373. function bnBitCount() {
  3374. var r = 0, x = this.s&this.DM;
  3375. for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
  3376. return r;
  3377. }
  3378. // (public) true iff nth bit is set
  3379. function bnTestBit(n) {
  3380. var j = Math.floor(n/this.DB);
  3381. if(j >= this.t) return(this.s!=0);
  3382. return((this[j]&(1<<(n%this.DB)))!=0);
  3383. }
  3384. // (protected) this op (1<<n)
  3385. function bnpChangeBit(n,op) {
  3386. var r = BigInteger.ONE.shiftLeft(n);
  3387. this.bitwiseTo(r,op,r);
  3388. return r;
  3389. }
  3390. // (public) this | (1<<n)
  3391. function bnSetBit(n) { return this.changeBit(n,op_or); }
  3392. // (public) this & ~(1<<n)
  3393. function bnClearBit(n) { return this.changeBit(n,op_andnot); }
  3394. // (public) this ^ (1<<n)
  3395. function bnFlipBit(n) { return this.changeBit(n,op_xor); }
  3396. // (protected) r = this + a
  3397. function bnpAddTo(a,r) {
  3398. var i = 0, c = 0, m = Math.min(a.t,this.t);
  3399. while(i < m) {
  3400. c += this[i]+a[i];
  3401. r[i++] = c&this.DM;
  3402. c >>= this.DB;
  3403. }
  3404. if(a.t < this.t) {
  3405. c += a.s;
  3406. while(i < this.t) {
  3407. c += this[i];
  3408. r[i++] = c&this.DM;
  3409. c >>= this.DB;
  3410. }
  3411. c += this.s;
  3412. }
  3413. else {
  3414. c += this.s;
  3415. while(i < a.t) {
  3416. c += a[i];
  3417. r[i++] = c&this.DM;
  3418. c >>= this.DB;
  3419. }
  3420. c += a.s;
  3421. }
  3422. r.s = (c<0)?-1:0;
  3423. if(c > 0) r[i++] = c;
  3424. else if(c < -1) r[i++] = this.DV+c;
  3425. r.t = i;
  3426. r.clamp();
  3427. }
  3428. // (public) this + a
  3429. function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
  3430. // (public) this - a
  3431. function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
  3432. // (public) this * a
  3433. function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
  3434. // (public) this^2
  3435. function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
  3436. // (public) this / a
  3437. function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
  3438. // (public) this % a
  3439. function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
  3440. // (public) [this/a,this%a]
  3441. function bnDivideAndRemainder(a) {
  3442. var q = nbi(), r = nbi();
  3443. this.divRemTo(a,q,r);
  3444. return new Array(q,r);
  3445. }
  3446. // (protected) this *= n, this >= 0, 1 < n < DV
  3447. function bnpDMultiply(n) {
  3448. this[this.t] = this.am(0,n-1,this,0,0,this.t);
  3449. ++this.t;
  3450. this.clamp();
  3451. }
  3452. // (protected) this += n << w words, this >= 0
  3453. function bnpDAddOffset(n,w) {
  3454. if(n == 0) return;
  3455. while(this.t <= w) this[this.t++] = 0;
  3456. this[w] += n;
  3457. while(this[w] >= this.DV) {
  3458. this[w] -= this.DV;
  3459. if(++w >= this.t) this[this.t++] = 0;
  3460. ++this[w];
  3461. }
  3462. }
  3463. // A "null" reducer
  3464. function NullExp() {}
  3465. function nNop(x) { return x; }
  3466. function nMulTo(x,y,r) { x.multiplyTo(y,r); }
  3467. function nSqrTo(x,r) { x.squareTo(r); }
  3468. NullExp.prototype.convert = nNop;
  3469. NullExp.prototype.revert = nNop;
  3470. NullExp.prototype.mulTo = nMulTo;
  3471. NullExp.prototype.sqrTo = nSqrTo;
  3472. // (public) this^e
  3473. function bnPow(e) { return this.exp(e,new NullExp()); }
  3474. // (protected) r = lower n words of "this * a", a.t <= n
  3475. // "this" should be the larger one if appropriate.
  3476. function bnpMultiplyLowerTo(a,n,r) {
  3477. var i = Math.min(this.t+a.t,n);
  3478. r.s = 0; // assumes a,this >= 0
  3479. r.t = i;
  3480. while(i > 0) r[--i] = 0;
  3481. var j;
  3482. for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
  3483. for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
  3484. r.clamp();
  3485. }
  3486. // (protected) r = "this * a" without lower n words, n > 0
  3487. // "this" should be the larger one if appropriate.
  3488. function bnpMultiplyUpperTo(a,n,r) {
  3489. --n;
  3490. var i = r.t = this.t+a.t-n;
  3491. r.s = 0; // assumes a,this >= 0
  3492. while(--i >= 0) r[i] = 0;
  3493. for(i = Math.max(n-this.t,0); i < a.t; ++i)
  3494. r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
  3495. r.clamp();
  3496. r.drShiftTo(1,r);
  3497. }
  3498. // Barrett modular reduction
  3499. function Barrett(m) {
  3500. // setup Barrett
  3501. this.r2 = nbi();
  3502. this.q3 = nbi();
  3503. BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
  3504. this.mu = this.r2.divide(m);
  3505. this.m = m;
  3506. }
  3507. function barrettConvert(x) {
  3508. if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
  3509. else if(x.compareTo(this.m) < 0) return x;
  3510. else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
  3511. }
  3512. function barrettRevert(x) { return x; }
  3513. // x = x mod m (HAC 14.42)
  3514. function barrettReduce(x) {
  3515. x.drShiftTo(this.m.t-1,this.r2);
  3516. if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
  3517. this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
  3518. this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
  3519. while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
  3520. x.subTo(this.r2,x);
  3521. while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
  3522. }
  3523. // r = x^2 mod m; x != r
  3524. function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
  3525. // r = x*y mod m; x,y != r
  3526. function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
  3527. Barrett.prototype.convert = barrettConvert;
  3528. Barrett.prototype.revert = barrettRevert;
  3529. Barrett.prototype.reduce = barrettReduce;
  3530. Barrett.prototype.mulTo = barrettMulTo;
  3531. Barrett.prototype.sqrTo = barrettSqrTo;
  3532. // (public) this^e % m (HAC 14.85)
  3533. function bnModPow(e,m) {
  3534. var i = e.bitLength(), k, r = nbv(1), z;
  3535. if(i <= 0) return r;
  3536. else if(i < 18) k = 1;
  3537. else if(i < 48) k = 3;
  3538. else if(i < 144) k = 4;
  3539. else if(i < 768) k = 5;
  3540. else k = 6;
  3541. if(i < 8)
  3542. z = new Classic(m);
  3543. else if(m.isEven())
  3544. z = new Barrett(m);
  3545. else
  3546. z = new Montgomery(m);
  3547. // precomputation
  3548. var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
  3549. g[1] = z.convert(this);
  3550. if(k > 1) {
  3551. var g2 = nbi();
  3552. z.sqrTo(g[1],g2);
  3553. while(n <= km) {
  3554. g[n] = nbi();
  3555. z.mulTo(g2,g[n-2],g[n]);
  3556. n += 2;
  3557. }
  3558. }
  3559. var j = e.t-1, w, is1 = true, r2 = nbi(), t;
  3560. i = nbits(e[j])-1;
  3561. while(j >= 0) {
  3562. if(i >= k1) w = (e[j]>>(i-k1))&km;
  3563. else {
  3564. w = (e[j]&((1<<(i+1))-1))<<(k1-i);
  3565. if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
  3566. }
  3567. n = k;
  3568. while((w&1) == 0) { w >>= 1; --n; }
  3569. if((i -= n) < 0) { i += this.DB; --j; }
  3570. if(is1) { // ret == 1, don't bother squaring or multiplying it
  3571. g[w].copyTo(r);
  3572. is1 = false;
  3573. }
  3574. else {
  3575. while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
  3576. if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
  3577. z.mulTo(r2,g[w],r);
  3578. }
  3579. while(j >= 0 && (e[j]&(1<<i)) == 0) {
  3580. z.sqrTo(r,r2); t = r; r = r2; r2 = t;
  3581. if(--i < 0) { i = this.DB-1; --j; }
  3582. }
  3583. }
  3584. return z.revert(r);
  3585. }
  3586. // (public) gcd(this,a) (HAC 14.54)
  3587. function bnGCD(a) {
  3588. var x = (this.s<0)?this.negate():this.clone();
  3589. var y = (a.s<0)?a.negate():a.clone();
  3590. if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
  3591. var i = x.getLowestSetBit(), g = y.getLowestSetBit();
  3592. if(g < 0) return x;
  3593. if(i < g) g = i;
  3594. if(g > 0) {
  3595. x.rShiftTo(g,x);
  3596. y.rShiftTo(g,y);
  3597. }
  3598. while(x.signum() > 0) {
  3599. if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
  3600. if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
  3601. if(x.compareTo(y) >= 0) {
  3602. x.subTo(y,x);
  3603. x.rShiftTo(1,x);
  3604. }
  3605. else {
  3606. y.subTo(x,y);
  3607. y.rShiftTo(1,y);
  3608. }
  3609. }
  3610. if(g > 0) y.lShiftTo(g,y);
  3611. return y;
  3612. }
  3613. // (protected) this % n, n < 2^26
  3614. function bnpModInt(n) {
  3615. if(n <= 0) return 0;
  3616. var d = this.DV%n, r = (this.s<0)?n-1:0;
  3617. if(this.t > 0)
  3618. if(d == 0) r = this[0]%n;
  3619. else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
  3620. return r;
  3621. }
  3622. // (public) 1/this % m (HAC 14.61)
  3623. function bnModInverse(m) {
  3624. var ac = m.isEven();
  3625. if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
  3626. var u = m.clone(), v = this.clone();
  3627. var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
  3628. while(u.signum() != 0) {
  3629. while(u.isEven()) {
  3630. u.rShiftTo(1,u);
  3631. if(ac) {
  3632. if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
  3633. a.rShiftTo(1,a);
  3634. }
  3635. else if(!b.isEven()) b.subTo(m,b);
  3636. b.rShiftTo(1,b);
  3637. }
  3638. while(v.isEven()) {
  3639. v.rShiftTo(1,v);
  3640. if(ac) {
  3641. if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
  3642. c.rShiftTo(1,c);
  3643. }
  3644. else if(!d.isEven()) d.subTo(m,d);
  3645. d.rShiftTo(1,d);
  3646. }
  3647. if(u.compareTo(v) >= 0) {
  3648. u.subTo(v,u);
  3649. if(ac) a.subTo(c,a);
  3650. b.subTo(d,b);
  3651. }
  3652. else {
  3653. v.subTo(u,v);
  3654. if(ac) c.subTo(a,c);
  3655. d.subTo(b,d);
  3656. }
  3657. }
  3658. if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
  3659. if(d.compareTo(m) >= 0) return d.subtract(m);
  3660. if(d.signum() < 0) d.addTo(m,d); else return d;
  3661. if(d.signum() < 0) return d.add(m); else return d;
  3662. }
  3663. var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
  3664. var lplim = (1<<26)/lowprimes[lowprimes.length-1];
  3665. // (public) test primality with certainty >= 1-.5^t
  3666. function bnIsProbablePrime(t) {
  3667. var i, x = this.abs();
  3668. if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) {
  3669. for(i = 0; i < lowprimes.length; ++i)
  3670. if(x[0] == lowprimes[i]) return true;
  3671. return false;
  3672. }
  3673. if(x.isEven()) return false;
  3674. i = 1;
  3675. while(i < lowprimes.length) {
  3676. var m = lowprimes[i], j = i+1;
  3677. while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
  3678. m = x.modInt(m);
  3679. while(i < j) if(m%lowprimes[i++] == 0) return false;
  3680. }
  3681. return x.millerRabin(t);
  3682. }
  3683. // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
  3684. function bnpMillerRabin(t) {
  3685. var n1 = this.subtract(BigInteger.ONE);
  3686. var k = n1.getLowestSetBit();
  3687. if(k <= 0) return false;
  3688. var r = n1.shiftRight(k);
  3689. t = (t+1)>>1;
  3690. if(t > lowprimes.length) t = lowprimes.length;
  3691. var a = nbi();
  3692. for(var i = 0; i < t; ++i) {
  3693. //Pick bases at random, instead of starting at 2
  3694. a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);
  3695. var y = a.modPow(r,this);
  3696. if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
  3697. var j = 1;
  3698. while(j++ < k && y.compareTo(n1) != 0) {
  3699. y = y.modPowInt(2,this);
  3700. if(y.compareTo(BigInteger.ONE) == 0) return false;
  3701. }
  3702. if(y.compareTo(n1) != 0) return false;
  3703. }
  3704. }
  3705. return true;
  3706. }
  3707. // protected
  3708. BigInteger.prototype.chunkSize = bnpChunkSize;
  3709. BigInteger.prototype.toRadix = bnpToRadix;
  3710. BigInteger.prototype.fromRadix = bnpFromRadix;
  3711. BigInteger.prototype.fromNumber = bnpFromNumber;
  3712. BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
  3713. BigInteger.prototype.changeBit = bnpChangeBit;
  3714. BigInteger.prototype.addTo = bnpAddTo;
  3715. BigInteger.prototype.dMultiply = bnpDMultiply;
  3716. BigInteger.prototype.dAddOffset = bnpDAddOffset;
  3717. BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
  3718. BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
  3719. BigInteger.prototype.modInt = bnpModInt;
  3720. BigInteger.prototype.millerRabin = bnpMillerRabin;
  3721. // public
  3722. BigInteger.prototype.clone = bnClone;
  3723. BigInteger.prototype.intValue = bnIntValue;
  3724. BigInteger.prototype.byteValue = bnByteValue;
  3725. BigInteger.prototype.shortValue = bnShortValue;
  3726. BigInteger.prototype.signum = bnSigNum;
  3727. BigInteger.prototype.toByteArray = bnToByteArray;
  3728. BigInteger.prototype.equals = bnEquals;
  3729. BigInteger.prototype.min = bnMin;
  3730. BigInteger.prototype.max = bnMax;
  3731. BigInteger.prototype.and = bnAnd;
  3732. BigInteger.prototype.or = bnOr;
  3733. BigInteger.prototype.xor = bnXor;
  3734. BigInteger.prototype.andNot = bnAndNot;
  3735. BigInteger.prototype.not = bnNot;
  3736. BigInteger.prototype.shiftLeft = bnShiftLeft;
  3737. BigInteger.prototype.shiftRight = bnShiftRight;
  3738. BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
  3739. BigInteger.prototype.bitCount = bnBitCount;
  3740. BigInteger.prototype.testBit = bnTestBit;
  3741. BigInteger.prototype.setBit = bnSetBit;
  3742. BigInteger.prototype.clearBit = bnClearBit;
  3743. BigInteger.prototype.flipBit = bnFlipBit;
  3744. BigInteger.prototype.add = bnAdd;
  3745. BigInteger.prototype.subtract = bnSubtract;
  3746. BigInteger.prototype.multiply = bnMultiply;
  3747. BigInteger.prototype.divide = bnDivide;
  3748. BigInteger.prototype.remainder = bnRemainder;
  3749. BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
  3750. BigInteger.prototype.modPow = bnModPow;
  3751. BigInteger.prototype.modInverse = bnModInverse;
  3752. BigInteger.prototype.pow = bnPow;
  3753. BigInteger.prototype.gcd = bnGCD;
  3754. BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
  3755. // JSBN-specific extension
  3756. BigInteger.prototype.square = bnSquare;
  3757. // BigInteger interfaces not implemented in jsbn:
  3758. // BigInteger(int signum, byte[] magnitude)
  3759. // double doubleValue()
  3760. // float floatValue()
  3761. // int hashCode()
  3762. // long longValue()
  3763. // static BigInteger valueOf(long val)
  3764. if (typeof exports !== 'undefined') {
  3765. exports = module.exports = BigInteger;
  3766. } else {
  3767. this.BigInteger = BigInteger;
  3768. }
  3769. }).call(this);
  3770. },{}],16:[function(require,module,exports){
  3771. /**
  3772. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  3773. * Build: `lodash modern modularize exports="npm" -o ./`
  3774. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3775. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  3776. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3777. * Available under MIT license <https://lodash.com/license>
  3778. */
  3779. /**
  3780. * Copies the values of `source` to `array`.
  3781. *
  3782. * @private
  3783. * @param {Array} source The array to copy values from.
  3784. * @param {Array} [array=[]] The array to copy values to.
  3785. * @returns {Array} Returns `array`.
  3786. */
  3787. function arrayCopy(source, array) {
  3788. var index = -1,
  3789. length = source.length;
  3790. array || (array = Array(length));
  3791. while (++index < length) {
  3792. array[index] = source[index];
  3793. }
  3794. return array;
  3795. }
  3796. module.exports = arrayCopy;
  3797. },{}],17:[function(require,module,exports){
  3798. /**
  3799. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  3800. * Build: `lodash modern modularize exports="npm" -o ./`
  3801. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3802. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  3803. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3804. * Available under MIT license <https://lodash.com/license>
  3805. */
  3806. /**
  3807. * A specialized version of `_.forEach` for arrays without support for callback
  3808. * shorthands or `this` binding.
  3809. *
  3810. * @private
  3811. * @param {Array} array The array to iterate over.
  3812. * @param {Function} iteratee The function invoked per iteration.
  3813. * @returns {Array} Returns `array`.
  3814. */
  3815. function arrayEach(array, iteratee) {
  3816. var index = -1,
  3817. length = array.length;
  3818. while (++index < length) {
  3819. if (iteratee(array[index], index, array) === false) {
  3820. break;
  3821. }
  3822. }
  3823. return array;
  3824. }
  3825. module.exports = arrayEach;
  3826. },{}],18:[function(require,module,exports){
  3827. /**
  3828. * lodash 3.3.1 (Custom Build) <https://lodash.com/>
  3829. * Build: `lodash modern modularize exports="npm" -o ./`
  3830. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  3831. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  3832. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  3833. * Available under MIT license <https://lodash.com/license>
  3834. */
  3835. var baseIsEqual = require('lodash._baseisequal'),
  3836. bindCallback = require('lodash._bindcallback'),
  3837. isArray = require('lodash.isarray'),
  3838. pairs = require('lodash.pairs');
  3839. /** Used to match property names within property paths. */
  3840. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  3841. reIsPlainProp = /^\w*$/,
  3842. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  3843. /** Used to match backslashes in property paths. */
  3844. var reEscapeChar = /\\(\\)?/g;
  3845. /**
  3846. * Converts `value` to a string if it's not one. An empty string is returned
  3847. * for `null` or `undefined` values.
  3848. *
  3849. * @private
  3850. * @param {*} value The value to process.
  3851. * @returns {string} Returns the string.
  3852. */
  3853. function baseToString(value) {
  3854. return value == null ? '' : (value + '');
  3855. }
  3856. /**
  3857. * The base implementation of `_.callback` which supports specifying the
  3858. * number of arguments to provide to `func`.
  3859. *
  3860. * @private
  3861. * @param {*} [func=_.identity] The value to convert to a callback.
  3862. * @param {*} [thisArg] The `this` binding of `func`.
  3863. * @param {number} [argCount] The number of arguments to provide to `func`.
  3864. * @returns {Function} Returns the callback.
  3865. */
  3866. function baseCallback(func, thisArg, argCount) {
  3867. var type = typeof func;
  3868. if (type == 'function') {
  3869. return thisArg === undefined
  3870. ? func
  3871. : bindCallback(func, thisArg, argCount);
  3872. }
  3873. if (func == null) {
  3874. return identity;
  3875. }
  3876. if (type == 'object') {
  3877. return baseMatches(func);
  3878. }
  3879. return thisArg === undefined
  3880. ? property(func)
  3881. : baseMatchesProperty(func, thisArg);
  3882. }
  3883. /**
  3884. * The base implementation of `get` without support for string paths
  3885. * and default values.
  3886. *
  3887. * @private
  3888. * @param {Object} object The object to query.
  3889. * @param {Array} path The path of the property to get.
  3890. * @param {string} [pathKey] The key representation of path.
  3891. * @returns {*} Returns the resolved value.
  3892. */
  3893. function baseGet(object, path, pathKey) {
  3894. if (object == null) {
  3895. return;
  3896. }
  3897. if (pathKey !== undefined && pathKey in toObject(object)) {
  3898. path = [pathKey];
  3899. }
  3900. var index = 0,
  3901. length = path.length;
  3902. while (object != null && index < length) {
  3903. object = object[path[index++]];
  3904. }
  3905. return (index && index == length) ? object : undefined;
  3906. }
  3907. /**
  3908. * The base implementation of `_.isMatch` without support for callback
  3909. * shorthands and `this` binding.
  3910. *
  3911. * @private
  3912. * @param {Object} object The object to inspect.
  3913. * @param {Array} matchData The propery names, values, and compare flags to match.
  3914. * @param {Function} [customizer] The function to customize comparing objects.
  3915. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3916. */
  3917. function baseIsMatch(object, matchData, customizer) {
  3918. var index = matchData.length,
  3919. length = index,
  3920. noCustomizer = !customizer;
  3921. if (object == null) {
  3922. return !length;
  3923. }
  3924. object = toObject(object);
  3925. while (index--) {
  3926. var data = matchData[index];
  3927. if ((noCustomizer && data[2])
  3928. ? data[1] !== object[data[0]]
  3929. : !(data[0] in object)
  3930. ) {
  3931. return false;
  3932. }
  3933. }
  3934. while (++index < length) {
  3935. data = matchData[index];
  3936. var key = data[0],
  3937. objValue = object[key],
  3938. srcValue = data[1];
  3939. if (noCustomizer && data[2]) {
  3940. if (objValue === undefined && !(key in object)) {
  3941. return false;
  3942. }
  3943. } else {
  3944. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  3945. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  3946. return false;
  3947. }
  3948. }
  3949. }
  3950. return true;
  3951. }
  3952. /**
  3953. * The base implementation of `_.matches` which does not clone `source`.
  3954. *
  3955. * @private
  3956. * @param {Object} source The object of property values to match.
  3957. * @returns {Function} Returns the new function.
  3958. */
  3959. function baseMatches(source) {
  3960. var matchData = getMatchData(source);
  3961. if (matchData.length == 1 && matchData[0][2]) {
  3962. var key = matchData[0][0],
  3963. value = matchData[0][1];
  3964. return function(object) {
  3965. if (object == null) {
  3966. return false;
  3967. }
  3968. return object[key] === value && (value !== undefined || (key in toObject(object)));
  3969. };
  3970. }
  3971. return function(object) {
  3972. return baseIsMatch(object, matchData);
  3973. };
  3974. }
  3975. /**
  3976. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  3977. *
  3978. * @private
  3979. * @param {string} path The path of the property to get.
  3980. * @param {*} srcValue The value to compare.
  3981. * @returns {Function} Returns the new function.
  3982. */
  3983. function baseMatchesProperty(path, srcValue) {
  3984. var isArr = isArray(path),
  3985. isCommon = isKey(path) && isStrictComparable(srcValue),
  3986. pathKey = (path + '');
  3987. path = toPath(path);
  3988. return function(object) {
  3989. if (object == null) {
  3990. return false;
  3991. }
  3992. var key = pathKey;
  3993. object = toObject(object);
  3994. if ((isArr || !isCommon) && !(key in object)) {
  3995. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  3996. if (object == null) {
  3997. return false;
  3998. }
  3999. key = last(path);
  4000. object = toObject(object);
  4001. }
  4002. return object[key] === srcValue
  4003. ? (srcValue !== undefined || (key in object))
  4004. : baseIsEqual(srcValue, object[key], undefined, true);
  4005. };
  4006. }
  4007. /**
  4008. * The base implementation of `_.property` without support for deep paths.
  4009. *
  4010. * @private
  4011. * @param {string} key The key of the property to get.
  4012. * @returns {Function} Returns the new function.
  4013. */
  4014. function baseProperty(key) {
  4015. return function(object) {
  4016. return object == null ? undefined : object[key];
  4017. };
  4018. }
  4019. /**
  4020. * A specialized version of `baseProperty` which supports deep paths.
  4021. *
  4022. * @private
  4023. * @param {Array|string} path The path of the property to get.
  4024. * @returns {Function} Returns the new function.
  4025. */
  4026. function basePropertyDeep(path) {
  4027. var pathKey = (path + '');
  4028. path = toPath(path);
  4029. return function(object) {
  4030. return baseGet(object, path, pathKey);
  4031. };
  4032. }
  4033. /**
  4034. * The base implementation of `_.slice` without an iteratee call guard.
  4035. *
  4036. * @private
  4037. * @param {Array} array The array to slice.
  4038. * @param {number} [start=0] The start position.
  4039. * @param {number} [end=array.length] The end position.
  4040. * @returns {Array} Returns the slice of `array`.
  4041. */
  4042. function baseSlice(array, start, end) {
  4043. var index = -1,
  4044. length = array.length;
  4045. start = start == null ? 0 : (+start || 0);
  4046. if (start < 0) {
  4047. start = -start > length ? 0 : (length + start);
  4048. }
  4049. end = (end === undefined || end > length) ? length : (+end || 0);
  4050. if (end < 0) {
  4051. end += length;
  4052. }
  4053. length = start > end ? 0 : ((end - start) >>> 0);
  4054. start >>>= 0;
  4055. var result = Array(length);
  4056. while (++index < length) {
  4057. result[index] = array[index + start];
  4058. }
  4059. return result;
  4060. }
  4061. /**
  4062. * Gets the propery names, values, and compare flags of `object`.
  4063. *
  4064. * @private
  4065. * @param {Object} object The object to query.
  4066. * @returns {Array} Returns the match data of `object`.
  4067. */
  4068. function getMatchData(object) {
  4069. var result = pairs(object),
  4070. length = result.length;
  4071. while (length--) {
  4072. result[length][2] = isStrictComparable(result[length][1]);
  4073. }
  4074. return result;
  4075. }
  4076. /**
  4077. * Checks if `value` is a property name and not a property path.
  4078. *
  4079. * @private
  4080. * @param {*} value The value to check.
  4081. * @param {Object} [object] The object to query keys on.
  4082. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  4083. */
  4084. function isKey(value, object) {
  4085. var type = typeof value;
  4086. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  4087. return true;
  4088. }
  4089. if (isArray(value)) {
  4090. return false;
  4091. }
  4092. var result = !reIsDeepProp.test(value);
  4093. return result || (object != null && value in toObject(object));
  4094. }
  4095. /**
  4096. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  4097. *
  4098. * @private
  4099. * @param {*} value The value to check.
  4100. * @returns {boolean} Returns `true` if `value` if suitable for strict
  4101. * equality comparisons, else `false`.
  4102. */
  4103. function isStrictComparable(value) {
  4104. return value === value && !isObject(value);
  4105. }
  4106. /**
  4107. * Converts `value` to an object if it's not one.
  4108. *
  4109. * @private
  4110. * @param {*} value The value to process.
  4111. * @returns {Object} Returns the object.
  4112. */
  4113. function toObject(value) {
  4114. return isObject(value) ? value : Object(value);
  4115. }
  4116. /**
  4117. * Converts `value` to property path array if it's not one.
  4118. *
  4119. * @private
  4120. * @param {*} value The value to process.
  4121. * @returns {Array} Returns the property path array.
  4122. */
  4123. function toPath(value) {
  4124. if (isArray(value)) {
  4125. return value;
  4126. }
  4127. var result = [];
  4128. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  4129. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  4130. });
  4131. return result;
  4132. }
  4133. /**
  4134. * Gets the last element of `array`.
  4135. *
  4136. * @static
  4137. * @memberOf _
  4138. * @category Array
  4139. * @param {Array} array The array to query.
  4140. * @returns {*} Returns the last element of `array`.
  4141. * @example
  4142. *
  4143. * _.last([1, 2, 3]);
  4144. * // => 3
  4145. */
  4146. function last(array) {
  4147. var length = array ? array.length : 0;
  4148. return length ? array[length - 1] : undefined;
  4149. }
  4150. /**
  4151. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4152. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4153. *
  4154. * @static
  4155. * @memberOf _
  4156. * @category Lang
  4157. * @param {*} value The value to check.
  4158. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4159. * @example
  4160. *
  4161. * _.isObject({});
  4162. * // => true
  4163. *
  4164. * _.isObject([1, 2, 3]);
  4165. * // => true
  4166. *
  4167. * _.isObject(1);
  4168. * // => false
  4169. */
  4170. function isObject(value) {
  4171. // Avoid a V8 JIT bug in Chrome 19-20.
  4172. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4173. var type = typeof value;
  4174. return !!value && (type == 'object' || type == 'function');
  4175. }
  4176. /**
  4177. * This method returns the first argument provided to it.
  4178. *
  4179. * @static
  4180. * @memberOf _
  4181. * @category Utility
  4182. * @param {*} value Any value.
  4183. * @returns {*} Returns `value`.
  4184. * @example
  4185. *
  4186. * var object = { 'user': 'fred' };
  4187. *
  4188. * _.identity(object) === object;
  4189. * // => true
  4190. */
  4191. function identity(value) {
  4192. return value;
  4193. }
  4194. /**
  4195. * Creates a function that returns the property value at `path` on a
  4196. * given object.
  4197. *
  4198. * @static
  4199. * @memberOf _
  4200. * @category Utility
  4201. * @param {Array|string} path The path of the property to get.
  4202. * @returns {Function} Returns the new function.
  4203. * @example
  4204. *
  4205. * var objects = [
  4206. * { 'a': { 'b': { 'c': 2 } } },
  4207. * { 'a': { 'b': { 'c': 1 } } }
  4208. * ];
  4209. *
  4210. * _.map(objects, _.property('a.b.c'));
  4211. * // => [2, 1]
  4212. *
  4213. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  4214. * // => [1, 2]
  4215. */
  4216. function property(path) {
  4217. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  4218. }
  4219. module.exports = baseCallback;
  4220. },{"lodash._baseisequal":24,"lodash._bindcallback":25,"lodash.isarray":31,"lodash.pairs":37}],19:[function(require,module,exports){
  4221. /**
  4222. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  4223. * Build: `lodash modern modularize exports="npm" -o ./`
  4224. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4225. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4226. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4227. * Available under MIT license <https://lodash.com/license>
  4228. */
  4229. /**
  4230. * Copies properties of `source` to `object`.
  4231. *
  4232. * @private
  4233. * @param {Object} source The object to copy properties from.
  4234. * @param {Array} props The property names to copy.
  4235. * @param {Object} [object={}] The object to copy properties to.
  4236. * @returns {Object} Returns `object`.
  4237. */
  4238. function baseCopy(source, props, object) {
  4239. object || (object = {});
  4240. var index = -1,
  4241. length = props.length;
  4242. while (++index < length) {
  4243. var key = props[index];
  4244. object[key] = source[key];
  4245. }
  4246. return object;
  4247. }
  4248. module.exports = baseCopy;
  4249. },{}],20:[function(require,module,exports){
  4250. /**
  4251. * lodash 3.0.4 (Custom Build) <https://lodash.com/>
  4252. * Build: `lodash modern modularize exports="npm" -o ./`
  4253. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4254. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4255. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4256. * Available under MIT license <https://lodash.com/license>
  4257. */
  4258. var keys = require('lodash.keys');
  4259. /**
  4260. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  4261. * of an array-like value.
  4262. */
  4263. var MAX_SAFE_INTEGER = 9007199254740991;
  4264. /**
  4265. * The base implementation of `_.forEach` without support for callback
  4266. * shorthands and `this` binding.
  4267. *
  4268. * @private
  4269. * @param {Array|Object|string} collection The collection to iterate over.
  4270. * @param {Function} iteratee The function invoked per iteration.
  4271. * @returns {Array|Object|string} Returns `collection`.
  4272. */
  4273. var baseEach = createBaseEach(baseForOwn);
  4274. /**
  4275. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  4276. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  4277. * each property. Iteratee functions may exit iteration early by explicitly
  4278. * returning `false`.
  4279. *
  4280. * @private
  4281. * @param {Object} object The object to iterate over.
  4282. * @param {Function} iteratee The function invoked per iteration.
  4283. * @param {Function} keysFunc The function to get the keys of `object`.
  4284. * @returns {Object} Returns `object`.
  4285. */
  4286. var baseFor = createBaseFor();
  4287. /**
  4288. * The base implementation of `_.forOwn` without support for callback
  4289. * shorthands and `this` binding.
  4290. *
  4291. * @private
  4292. * @param {Object} object The object to iterate over.
  4293. * @param {Function} iteratee The function invoked per iteration.
  4294. * @returns {Object} Returns `object`.
  4295. */
  4296. function baseForOwn(object, iteratee) {
  4297. return baseFor(object, iteratee, keys);
  4298. }
  4299. /**
  4300. * The base implementation of `_.property` without support for deep paths.
  4301. *
  4302. * @private
  4303. * @param {string} key The key of the property to get.
  4304. * @returns {Function} Returns the new function.
  4305. */
  4306. function baseProperty(key) {
  4307. return function(object) {
  4308. return object == null ? undefined : object[key];
  4309. };
  4310. }
  4311. /**
  4312. * Creates a `baseEach` or `baseEachRight` function.
  4313. *
  4314. * @private
  4315. * @param {Function} eachFunc The function to iterate over a collection.
  4316. * @param {boolean} [fromRight] Specify iterating from right to left.
  4317. * @returns {Function} Returns the new base function.
  4318. */
  4319. function createBaseEach(eachFunc, fromRight) {
  4320. return function(collection, iteratee) {
  4321. var length = collection ? getLength(collection) : 0;
  4322. if (!isLength(length)) {
  4323. return eachFunc(collection, iteratee);
  4324. }
  4325. var index = fromRight ? length : -1,
  4326. iterable = toObject(collection);
  4327. while ((fromRight ? index-- : ++index < length)) {
  4328. if (iteratee(iterable[index], index, iterable) === false) {
  4329. break;
  4330. }
  4331. }
  4332. return collection;
  4333. };
  4334. }
  4335. /**
  4336. * Creates a base function for `_.forIn` or `_.forInRight`.
  4337. *
  4338. * @private
  4339. * @param {boolean} [fromRight] Specify iterating from right to left.
  4340. * @returns {Function} Returns the new base function.
  4341. */
  4342. function createBaseFor(fromRight) {
  4343. return function(object, iteratee, keysFunc) {
  4344. var iterable = toObject(object),
  4345. props = keysFunc(object),
  4346. length = props.length,
  4347. index = fromRight ? length : -1;
  4348. while ((fromRight ? index-- : ++index < length)) {
  4349. var key = props[index];
  4350. if (iteratee(iterable[key], key, iterable) === false) {
  4351. break;
  4352. }
  4353. }
  4354. return object;
  4355. };
  4356. }
  4357. /**
  4358. * Gets the "length" property value of `object`.
  4359. *
  4360. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  4361. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  4362. *
  4363. * @private
  4364. * @param {Object} object The object to query.
  4365. * @returns {*} Returns the "length" value.
  4366. */
  4367. var getLength = baseProperty('length');
  4368. /**
  4369. * Checks if `value` is a valid array-like length.
  4370. *
  4371. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  4372. *
  4373. * @private
  4374. * @param {*} value The value to check.
  4375. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  4376. */
  4377. function isLength(value) {
  4378. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4379. }
  4380. /**
  4381. * Converts `value` to an object if it's not one.
  4382. *
  4383. * @private
  4384. * @param {*} value The value to process.
  4385. * @returns {Object} Returns the object.
  4386. */
  4387. function toObject(value) {
  4388. return isObject(value) ? value : Object(value);
  4389. }
  4390. /**
  4391. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4392. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4393. *
  4394. * @static
  4395. * @memberOf _
  4396. * @category Lang
  4397. * @param {*} value The value to check.
  4398. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4399. * @example
  4400. *
  4401. * _.isObject({});
  4402. * // => true
  4403. *
  4404. * _.isObject([1, 2, 3]);
  4405. * // => true
  4406. *
  4407. * _.isObject(1);
  4408. * // => false
  4409. */
  4410. function isObject(value) {
  4411. // Avoid a V8 JIT bug in Chrome 19-20.
  4412. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4413. var type = typeof value;
  4414. return !!value && (type == 'object' || type == 'function');
  4415. }
  4416. module.exports = baseEach;
  4417. },{"lodash.keys":34}],21:[function(require,module,exports){
  4418. /**
  4419. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  4420. * Build: `lodash modern modularize exports="npm" -o ./`
  4421. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4422. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  4423. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4424. * Available under MIT license <https://lodash.com/license>
  4425. */
  4426. /**
  4427. * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
  4428. * without support for callback shorthands and `this` binding, which iterates
  4429. * over `collection` using the provided `eachFunc`.
  4430. *
  4431. * @private
  4432. * @param {Array|Object|string} collection The collection to search.
  4433. * @param {Function} predicate The function invoked per iteration.
  4434. * @param {Function} eachFunc The function to iterate over `collection`.
  4435. * @param {boolean} [retKey] Specify returning the key of the found element
  4436. * instead of the element itself.
  4437. * @returns {*} Returns the found element or its key, else `undefined`.
  4438. */
  4439. function baseFind(collection, predicate, eachFunc, retKey) {
  4440. var result;
  4441. eachFunc(collection, function(value, key, collection) {
  4442. if (predicate(value, key, collection)) {
  4443. result = retKey ? key : value;
  4444. return false;
  4445. }
  4446. });
  4447. return result;
  4448. }
  4449. module.exports = baseFind;
  4450. },{}],22:[function(require,module,exports){
  4451. /**
  4452. * lodash 3.6.0 (Custom Build) <https://lodash.com/>
  4453. * Build: `lodash modern modularize exports="npm" -o ./`
  4454. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4455. * Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
  4456. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4457. * Available under MIT license <https://lodash.com/license>
  4458. */
  4459. /**
  4460. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  4461. * support for callback shorthands and `this` binding.
  4462. *
  4463. * @private
  4464. * @param {Array} array The array to search.
  4465. * @param {Function} predicate The function invoked per iteration.
  4466. * @param {boolean} [fromRight] Specify iterating from right to left.
  4467. * @returns {number} Returns the index of the matched value, else `-1`.
  4468. */
  4469. function baseFindIndex(array, predicate, fromRight) {
  4470. var length = array.length,
  4471. index = fromRight ? length : -1;
  4472. while ((fromRight ? index-- : ++index < length)) {
  4473. if (predicate(array[index], index, array)) {
  4474. return index;
  4475. }
  4476. }
  4477. return -1;
  4478. }
  4479. module.exports = baseFindIndex;
  4480. },{}],23:[function(require,module,exports){
  4481. /**
  4482. * lodash 3.0.3 (Custom Build) <https://lodash.com/>
  4483. * Build: `lodash modularize exports="npm" -o ./`
  4484. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  4485. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4486. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4487. * Available under MIT license <https://lodash.com/license>
  4488. */
  4489. /**
  4490. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  4491. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  4492. * each property. Iteratee functions may exit iteration early by explicitly
  4493. * returning `false`.
  4494. *
  4495. * @private
  4496. * @param {Object} object The object to iterate over.
  4497. * @param {Function} iteratee The function invoked per iteration.
  4498. * @param {Function} keysFunc The function to get the keys of `object`.
  4499. * @returns {Object} Returns `object`.
  4500. */
  4501. var baseFor = createBaseFor();
  4502. /**
  4503. * Creates a base function for methods like `_.forIn`.
  4504. *
  4505. * @private
  4506. * @param {boolean} [fromRight] Specify iterating from right to left.
  4507. * @returns {Function} Returns the new base function.
  4508. */
  4509. function createBaseFor(fromRight) {
  4510. return function(object, iteratee, keysFunc) {
  4511. var index = -1,
  4512. iterable = Object(object),
  4513. props = keysFunc(object),
  4514. length = props.length;
  4515. while (length--) {
  4516. var key = props[fromRight ? length : ++index];
  4517. if (iteratee(iterable[key], key, iterable) === false) {
  4518. break;
  4519. }
  4520. }
  4521. return object;
  4522. };
  4523. }
  4524. module.exports = baseFor;
  4525. },{}],24:[function(require,module,exports){
  4526. /**
  4527. * lodash 3.0.7 (Custom Build) <https://lodash.com/>
  4528. * Build: `lodash modern modularize exports="npm" -o ./`
  4529. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4530. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4531. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4532. * Available under MIT license <https://lodash.com/license>
  4533. */
  4534. var isArray = require('lodash.isarray'),
  4535. isTypedArray = require('lodash.istypedarray'),
  4536. keys = require('lodash.keys');
  4537. /** `Object#toString` result references. */
  4538. var argsTag = '[object Arguments]',
  4539. arrayTag = '[object Array]',
  4540. boolTag = '[object Boolean]',
  4541. dateTag = '[object Date]',
  4542. errorTag = '[object Error]',
  4543. numberTag = '[object Number]',
  4544. objectTag = '[object Object]',
  4545. regexpTag = '[object RegExp]',
  4546. stringTag = '[object String]';
  4547. /**
  4548. * Checks if `value` is object-like.
  4549. *
  4550. * @private
  4551. * @param {*} value The value to check.
  4552. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4553. */
  4554. function isObjectLike(value) {
  4555. return !!value && typeof value == 'object';
  4556. }
  4557. /** Used for native method references. */
  4558. var objectProto = Object.prototype;
  4559. /** Used to check objects for own properties. */
  4560. var hasOwnProperty = objectProto.hasOwnProperty;
  4561. /**
  4562. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  4563. * of values.
  4564. */
  4565. var objToString = objectProto.toString;
  4566. /**
  4567. * A specialized version of `_.some` for arrays without support for callback
  4568. * shorthands and `this` binding.
  4569. *
  4570. * @private
  4571. * @param {Array} array The array to iterate over.
  4572. * @param {Function} predicate The function invoked per iteration.
  4573. * @returns {boolean} Returns `true` if any element passes the predicate check,
  4574. * else `false`.
  4575. */
  4576. function arraySome(array, predicate) {
  4577. var index = -1,
  4578. length = array.length;
  4579. while (++index < length) {
  4580. if (predicate(array[index], index, array)) {
  4581. return true;
  4582. }
  4583. }
  4584. return false;
  4585. }
  4586. /**
  4587. * The base implementation of `_.isEqual` without support for `this` binding
  4588. * `customizer` functions.
  4589. *
  4590. * @private
  4591. * @param {*} value The value to compare.
  4592. * @param {*} other The other value to compare.
  4593. * @param {Function} [customizer] The function to customize comparing values.
  4594. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4595. * @param {Array} [stackA] Tracks traversed `value` objects.
  4596. * @param {Array} [stackB] Tracks traversed `other` objects.
  4597. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4598. */
  4599. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  4600. if (value === other) {
  4601. return true;
  4602. }
  4603. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  4604. return value !== value && other !== other;
  4605. }
  4606. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  4607. }
  4608. /**
  4609. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4610. * deep comparisons and tracks traversed objects enabling objects with circular
  4611. * references to be compared.
  4612. *
  4613. * @private
  4614. * @param {Object} object The object to compare.
  4615. * @param {Object} other The other object to compare.
  4616. * @param {Function} equalFunc The function to determine equivalents of values.
  4617. * @param {Function} [customizer] The function to customize comparing objects.
  4618. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4619. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  4620. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  4621. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4622. */
  4623. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4624. var objIsArr = isArray(object),
  4625. othIsArr = isArray(other),
  4626. objTag = arrayTag,
  4627. othTag = arrayTag;
  4628. if (!objIsArr) {
  4629. objTag = objToString.call(object);
  4630. if (objTag == argsTag) {
  4631. objTag = objectTag;
  4632. } else if (objTag != objectTag) {
  4633. objIsArr = isTypedArray(object);
  4634. }
  4635. }
  4636. if (!othIsArr) {
  4637. othTag = objToString.call(other);
  4638. if (othTag == argsTag) {
  4639. othTag = objectTag;
  4640. } else if (othTag != objectTag) {
  4641. othIsArr = isTypedArray(other);
  4642. }
  4643. }
  4644. var objIsObj = objTag == objectTag,
  4645. othIsObj = othTag == objectTag,
  4646. isSameTag = objTag == othTag;
  4647. if (isSameTag && !(objIsArr || objIsObj)) {
  4648. return equalByTag(object, other, objTag);
  4649. }
  4650. if (!isLoose) {
  4651. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4652. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4653. if (objIsWrapped || othIsWrapped) {
  4654. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  4655. }
  4656. }
  4657. if (!isSameTag) {
  4658. return false;
  4659. }
  4660. // Assume cyclic values are equal.
  4661. // For more information on detecting circular references see https://es5.github.io/#JO.
  4662. stackA || (stackA = []);
  4663. stackB || (stackB = []);
  4664. var length = stackA.length;
  4665. while (length--) {
  4666. if (stackA[length] == object) {
  4667. return stackB[length] == other;
  4668. }
  4669. }
  4670. // Add `object` and `other` to the stack of traversed objects.
  4671. stackA.push(object);
  4672. stackB.push(other);
  4673. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  4674. stackA.pop();
  4675. stackB.pop();
  4676. return result;
  4677. }
  4678. /**
  4679. * A specialized version of `baseIsEqualDeep` for arrays with support for
  4680. * partial deep comparisons.
  4681. *
  4682. * @private
  4683. * @param {Array} array The array to compare.
  4684. * @param {Array} other The other array to compare.
  4685. * @param {Function} equalFunc The function to determine equivalents of values.
  4686. * @param {Function} [customizer] The function to customize comparing arrays.
  4687. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4688. * @param {Array} [stackA] Tracks traversed `value` objects.
  4689. * @param {Array} [stackB] Tracks traversed `other` objects.
  4690. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  4691. */
  4692. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4693. var index = -1,
  4694. arrLength = array.length,
  4695. othLength = other.length;
  4696. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  4697. return false;
  4698. }
  4699. // Ignore non-index properties.
  4700. while (++index < arrLength) {
  4701. var arrValue = array[index],
  4702. othValue = other[index],
  4703. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  4704. if (result !== undefined) {
  4705. if (result) {
  4706. continue;
  4707. }
  4708. return false;
  4709. }
  4710. // Recursively compare arrays (susceptible to call stack limits).
  4711. if (isLoose) {
  4712. if (!arraySome(other, function(othValue) {
  4713. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  4714. })) {
  4715. return false;
  4716. }
  4717. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  4718. return false;
  4719. }
  4720. }
  4721. return true;
  4722. }
  4723. /**
  4724. * A specialized version of `baseIsEqualDeep` for comparing objects of
  4725. * the same `toStringTag`.
  4726. *
  4727. * **Note:** This function only supports comparing values with tags of
  4728. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  4729. *
  4730. * @private
  4731. * @param {Object} value The object to compare.
  4732. * @param {Object} other The other object to compare.
  4733. * @param {string} tag The `toStringTag` of the objects to compare.
  4734. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4735. */
  4736. function equalByTag(object, other, tag) {
  4737. switch (tag) {
  4738. case boolTag:
  4739. case dateTag:
  4740. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  4741. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  4742. return +object == +other;
  4743. case errorTag:
  4744. return object.name == other.name && object.message == other.message;
  4745. case numberTag:
  4746. // Treat `NaN` vs. `NaN` as equal.
  4747. return (object != +object)
  4748. ? other != +other
  4749. : object == +other;
  4750. case regexpTag:
  4751. case stringTag:
  4752. // Coerce regexes to strings and treat strings primitives and string
  4753. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  4754. return object == (other + '');
  4755. }
  4756. return false;
  4757. }
  4758. /**
  4759. * A specialized version of `baseIsEqualDeep` for objects with support for
  4760. * partial deep comparisons.
  4761. *
  4762. * @private
  4763. * @param {Object} object The object to compare.
  4764. * @param {Object} other The other object to compare.
  4765. * @param {Function} equalFunc The function to determine equivalents of values.
  4766. * @param {Function} [customizer] The function to customize comparing values.
  4767. * @param {boolean} [isLoose] Specify performing partial comparisons.
  4768. * @param {Array} [stackA] Tracks traversed `value` objects.
  4769. * @param {Array} [stackB] Tracks traversed `other` objects.
  4770. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4771. */
  4772. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  4773. var objProps = keys(object),
  4774. objLength = objProps.length,
  4775. othProps = keys(other),
  4776. othLength = othProps.length;
  4777. if (objLength != othLength && !isLoose) {
  4778. return false;
  4779. }
  4780. var index = objLength;
  4781. while (index--) {
  4782. var key = objProps[index];
  4783. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  4784. return false;
  4785. }
  4786. }
  4787. var skipCtor = isLoose;
  4788. while (++index < objLength) {
  4789. key = objProps[index];
  4790. var objValue = object[key],
  4791. othValue = other[key],
  4792. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  4793. // Recursively compare objects (susceptible to call stack limits).
  4794. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  4795. return false;
  4796. }
  4797. skipCtor || (skipCtor = key == 'constructor');
  4798. }
  4799. if (!skipCtor) {
  4800. var objCtor = object.constructor,
  4801. othCtor = other.constructor;
  4802. // Non `Object` object instances with different constructors are not equal.
  4803. if (objCtor != othCtor &&
  4804. ('constructor' in object && 'constructor' in other) &&
  4805. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  4806. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  4807. return false;
  4808. }
  4809. }
  4810. return true;
  4811. }
  4812. /**
  4813. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  4814. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4815. *
  4816. * @static
  4817. * @memberOf _
  4818. * @category Lang
  4819. * @param {*} value The value to check.
  4820. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4821. * @example
  4822. *
  4823. * _.isObject({});
  4824. * // => true
  4825. *
  4826. * _.isObject([1, 2, 3]);
  4827. * // => true
  4828. *
  4829. * _.isObject(1);
  4830. * // => false
  4831. */
  4832. function isObject(value) {
  4833. // Avoid a V8 JIT bug in Chrome 19-20.
  4834. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  4835. var type = typeof value;
  4836. return !!value && (type == 'object' || type == 'function');
  4837. }
  4838. module.exports = baseIsEqual;
  4839. },{"lodash.isarray":31,"lodash.istypedarray":33,"lodash.keys":34}],25:[function(require,module,exports){
  4840. /**
  4841. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  4842. * Build: `lodash modern modularize exports="npm" -o ./`
  4843. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4844. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4845. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4846. * Available under MIT license <https://lodash.com/license>
  4847. */
  4848. /**
  4849. * A specialized version of `baseCallback` which only supports `this` binding
  4850. * and specifying the number of arguments to provide to `func`.
  4851. *
  4852. * @private
  4853. * @param {Function} func The function to bind.
  4854. * @param {*} thisArg The `this` binding of `func`.
  4855. * @param {number} [argCount] The number of arguments to provide to `func`.
  4856. * @returns {Function} Returns the callback.
  4857. */
  4858. function bindCallback(func, thisArg, argCount) {
  4859. if (typeof func != 'function') {
  4860. return identity;
  4861. }
  4862. if (thisArg === undefined) {
  4863. return func;
  4864. }
  4865. switch (argCount) {
  4866. case 1: return function(value) {
  4867. return func.call(thisArg, value);
  4868. };
  4869. case 3: return function(value, index, collection) {
  4870. return func.call(thisArg, value, index, collection);
  4871. };
  4872. case 4: return function(accumulator, value, index, collection) {
  4873. return func.call(thisArg, accumulator, value, index, collection);
  4874. };
  4875. case 5: return function(value, other, key, object, source) {
  4876. return func.call(thisArg, value, other, key, object, source);
  4877. };
  4878. }
  4879. return function() {
  4880. return func.apply(thisArg, arguments);
  4881. };
  4882. }
  4883. /**
  4884. * This method returns the first argument provided to it.
  4885. *
  4886. * @static
  4887. * @memberOf _
  4888. * @category Utility
  4889. * @param {*} value Any value.
  4890. * @returns {*} Returns `value`.
  4891. * @example
  4892. *
  4893. * var object = { 'user': 'fred' };
  4894. *
  4895. * _.identity(object) === object;
  4896. * // => true
  4897. */
  4898. function identity(value) {
  4899. return value;
  4900. }
  4901. module.exports = bindCallback;
  4902. },{}],26:[function(require,module,exports){
  4903. /**
  4904. * lodash 3.1.1 (Custom Build) <https://lodash.com/>
  4905. * Build: `lodash modern modularize exports="npm" -o ./`
  4906. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4907. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4908. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4909. * Available under MIT license <https://lodash.com/license>
  4910. */
  4911. var bindCallback = require('lodash._bindcallback'),
  4912. isIterateeCall = require('lodash._isiterateecall'),
  4913. restParam = require('lodash.restparam');
  4914. /**
  4915. * Creates a function that assigns properties of source object(s) to a given
  4916. * destination object.
  4917. *
  4918. * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
  4919. *
  4920. * @private
  4921. * @param {Function} assigner The function to assign values.
  4922. * @returns {Function} Returns the new assigner function.
  4923. */
  4924. function createAssigner(assigner) {
  4925. return restParam(function(object, sources) {
  4926. var index = -1,
  4927. length = object == null ? 0 : sources.length,
  4928. customizer = length > 2 ? sources[length - 2] : undefined,
  4929. guard = length > 2 ? sources[2] : undefined,
  4930. thisArg = length > 1 ? sources[length - 1] : undefined;
  4931. if (typeof customizer == 'function') {
  4932. customizer = bindCallback(customizer, thisArg, 5);
  4933. length -= 2;
  4934. } else {
  4935. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  4936. length -= (customizer ? 1 : 0);
  4937. }
  4938. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  4939. customizer = length < 3 ? undefined : customizer;
  4940. length = 1;
  4941. }
  4942. while (++index < length) {
  4943. var source = sources[index];
  4944. if (source) {
  4945. assigner(object, source, customizer);
  4946. }
  4947. }
  4948. return object;
  4949. });
  4950. }
  4951. module.exports = createAssigner;
  4952. },{"lodash._bindcallback":25,"lodash._isiterateecall":28,"lodash.restparam":38}],27:[function(require,module,exports){
  4953. /**
  4954. * lodash 3.9.1 (Custom Build) <https://lodash.com/>
  4955. * Build: `lodash modern modularize exports="npm" -o ./`
  4956. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  4957. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4958. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4959. * Available under MIT license <https://lodash.com/license>
  4960. */
  4961. /** `Object#toString` result references. */
  4962. var funcTag = '[object Function]';
  4963. /** Used to detect host constructors (Safari > 5). */
  4964. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  4965. /**
  4966. * Checks if `value` is object-like.
  4967. *
  4968. * @private
  4969. * @param {*} value The value to check.
  4970. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4971. */
  4972. function isObjectLike(value) {
  4973. return !!value && typeof value == 'object';
  4974. }
  4975. /** Used for native method references. */
  4976. var objectProto = Object.prototype;
  4977. /** Used to resolve the decompiled source of functions. */
  4978. var fnToString = Function.prototype.toString;
  4979. /** Used to check objects for own properties. */
  4980. var hasOwnProperty = objectProto.hasOwnProperty;
  4981. /**
  4982. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  4983. * of values.
  4984. */
  4985. var objToString = objectProto.toString;
  4986. /** Used to detect if a method is native. */
  4987. var reIsNative = RegExp('^' +
  4988. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  4989. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  4990. );
  4991. /**
  4992. * Gets the native function at `key` of `object`.
  4993. *
  4994. * @private
  4995. * @param {Object} object The object to query.
  4996. * @param {string} key The key of the method to get.
  4997. * @returns {*} Returns the function if it's native, else `undefined`.
  4998. */
  4999. function getNative(object, key) {
  5000. var value = object == null ? undefined : object[key];
  5001. return isNative(value) ? value : undefined;
  5002. }
  5003. /**
  5004. * Checks if `value` is classified as a `Function` object.
  5005. *
  5006. * @static
  5007. * @memberOf _
  5008. * @category Lang
  5009. * @param {*} value The value to check.
  5010. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5011. * @example
  5012. *
  5013. * _.isFunction(_);
  5014. * // => true
  5015. *
  5016. * _.isFunction(/abc/);
  5017. * // => false
  5018. */
  5019. function isFunction(value) {
  5020. // The use of `Object#toString` avoids issues with the `typeof` operator
  5021. // in older versions of Chrome and Safari which return 'function' for regexes
  5022. // and Safari 8 equivalents which return 'object' for typed array constructors.
  5023. return isObject(value) && objToString.call(value) == funcTag;
  5024. }
  5025. /**
  5026. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5027. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5028. *
  5029. * @static
  5030. * @memberOf _
  5031. * @category Lang
  5032. * @param {*} value The value to check.
  5033. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5034. * @example
  5035. *
  5036. * _.isObject({});
  5037. * // => true
  5038. *
  5039. * _.isObject([1, 2, 3]);
  5040. * // => true
  5041. *
  5042. * _.isObject(1);
  5043. * // => false
  5044. */
  5045. function isObject(value) {
  5046. // Avoid a V8 JIT bug in Chrome 19-20.
  5047. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5048. var type = typeof value;
  5049. return !!value && (type == 'object' || type == 'function');
  5050. }
  5051. /**
  5052. * Checks if `value` is a native function.
  5053. *
  5054. * @static
  5055. * @memberOf _
  5056. * @category Lang
  5057. * @param {*} value The value to check.
  5058. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  5059. * @example
  5060. *
  5061. * _.isNative(Array.prototype.push);
  5062. * // => true
  5063. *
  5064. * _.isNative(_);
  5065. * // => false
  5066. */
  5067. function isNative(value) {
  5068. if (value == null) {
  5069. return false;
  5070. }
  5071. if (isFunction(value)) {
  5072. return reIsNative.test(fnToString.call(value));
  5073. }
  5074. return isObjectLike(value) && reIsHostCtor.test(value);
  5075. }
  5076. module.exports = getNative;
  5077. },{}],28:[function(require,module,exports){
  5078. /**
  5079. * lodash 3.0.9 (Custom Build) <https://lodash.com/>
  5080. * Build: `lodash modern modularize exports="npm" -o ./`
  5081. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5082. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5083. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5084. * Available under MIT license <https://lodash.com/license>
  5085. */
  5086. /** Used to detect unsigned integer values. */
  5087. var reIsUint = /^\d+$/;
  5088. /**
  5089. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  5090. * of an array-like value.
  5091. */
  5092. var MAX_SAFE_INTEGER = 9007199254740991;
  5093. /**
  5094. * The base implementation of `_.property` without support for deep paths.
  5095. *
  5096. * @private
  5097. * @param {string} key The key of the property to get.
  5098. * @returns {Function} Returns the new function.
  5099. */
  5100. function baseProperty(key) {
  5101. return function(object) {
  5102. return object == null ? undefined : object[key];
  5103. };
  5104. }
  5105. /**
  5106. * Gets the "length" property value of `object`.
  5107. *
  5108. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  5109. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  5110. *
  5111. * @private
  5112. * @param {Object} object The object to query.
  5113. * @returns {*} Returns the "length" value.
  5114. */
  5115. var getLength = baseProperty('length');
  5116. /**
  5117. * Checks if `value` is array-like.
  5118. *
  5119. * @private
  5120. * @param {*} value The value to check.
  5121. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  5122. */
  5123. function isArrayLike(value) {
  5124. return value != null && isLength(getLength(value));
  5125. }
  5126. /**
  5127. * Checks if `value` is a valid array-like index.
  5128. *
  5129. * @private
  5130. * @param {*} value The value to check.
  5131. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  5132. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  5133. */
  5134. function isIndex(value, length) {
  5135. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  5136. length = length == null ? MAX_SAFE_INTEGER : length;
  5137. return value > -1 && value % 1 == 0 && value < length;
  5138. }
  5139. /**
  5140. * Checks if the provided arguments are from an iteratee call.
  5141. *
  5142. * @private
  5143. * @param {*} value The potential iteratee value argument.
  5144. * @param {*} index The potential iteratee index or key argument.
  5145. * @param {*} object The potential iteratee object argument.
  5146. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  5147. */
  5148. function isIterateeCall(value, index, object) {
  5149. if (!isObject(object)) {
  5150. return false;
  5151. }
  5152. var type = typeof index;
  5153. if (type == 'number'
  5154. ? (isArrayLike(object) && isIndex(index, object.length))
  5155. : (type == 'string' && index in object)) {
  5156. var other = object[index];
  5157. return value === value ? (value === other) : (other !== other);
  5158. }
  5159. return false;
  5160. }
  5161. /**
  5162. * Checks if `value` is a valid array-like length.
  5163. *
  5164. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  5165. *
  5166. * @private
  5167. * @param {*} value The value to check.
  5168. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5169. */
  5170. function isLength(value) {
  5171. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5172. }
  5173. /**
  5174. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5175. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5176. *
  5177. * @static
  5178. * @memberOf _
  5179. * @category Lang
  5180. * @param {*} value The value to check.
  5181. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5182. * @example
  5183. *
  5184. * _.isObject({});
  5185. * // => true
  5186. *
  5187. * _.isObject([1, 2, 3]);
  5188. * // => true
  5189. *
  5190. * _.isObject(1);
  5191. * // => false
  5192. */
  5193. function isObject(value) {
  5194. // Avoid a V8 JIT bug in Chrome 19-20.
  5195. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5196. var type = typeof value;
  5197. return !!value && (type == 'object' || type == 'function');
  5198. }
  5199. module.exports = isIterateeCall;
  5200. },{}],29:[function(require,module,exports){
  5201. /**
  5202. * lodash 3.2.1 (Custom Build) <https://lodash.com/>
  5203. * Build: `lodash modern modularize exports="npm" -o ./`
  5204. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5205. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5206. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5207. * Available under MIT license <https://lodash.com/license>
  5208. */
  5209. var baseCallback = require('lodash._basecallback'),
  5210. baseEach = require('lodash._baseeach'),
  5211. baseFind = require('lodash._basefind'),
  5212. baseFindIndex = require('lodash._basefindindex'),
  5213. isArray = require('lodash.isarray');
  5214. /**
  5215. * Creates a `_.find` or `_.findLast` function.
  5216. *
  5217. * @private
  5218. * @param {Function} eachFunc The function to iterate over a collection.
  5219. * @param {boolean} [fromRight] Specify iterating from right to left.
  5220. * @returns {Function} Returns the new find function.
  5221. */
  5222. function createFind(eachFunc, fromRight) {
  5223. return function(collection, predicate, thisArg) {
  5224. predicate = baseCallback(predicate, thisArg, 3);
  5225. if (isArray(collection)) {
  5226. var index = baseFindIndex(collection, predicate, fromRight);
  5227. return index > -1 ? collection[index] : undefined;
  5228. }
  5229. return baseFind(collection, predicate, eachFunc);
  5230. };
  5231. }
  5232. /**
  5233. * Iterates over elements of `collection`, returning the first element
  5234. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  5235. * invoked with three arguments: (value, index|key, collection).
  5236. *
  5237. * If a property name is provided for `predicate` the created `_.property`
  5238. * style callback returns the property value of the given element.
  5239. *
  5240. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  5241. * style callback returns `true` for elements that have a matching property
  5242. * value, else `false`.
  5243. *
  5244. * If an object is provided for `predicate` the created `_.matches` style
  5245. * callback returns `true` for elements that have the properties of the given
  5246. * object, else `false`.
  5247. *
  5248. * @static
  5249. * @memberOf _
  5250. * @alias detect
  5251. * @category Collection
  5252. * @param {Array|Object|string} collection The collection to search.
  5253. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  5254. * per iteration.
  5255. * @param {*} [thisArg] The `this` binding of `predicate`.
  5256. * @returns {*} Returns the matched element, else `undefined`.
  5257. * @example
  5258. *
  5259. * var users = [
  5260. * { 'user': 'barney', 'age': 36, 'active': true },
  5261. * { 'user': 'fred', 'age': 40, 'active': false },
  5262. * { 'user': 'pebbles', 'age': 1, 'active': true }
  5263. * ];
  5264. *
  5265. * _.result(_.find(users, function(chr) {
  5266. * return chr.age < 40;
  5267. * }), 'user');
  5268. * // => 'barney'
  5269. *
  5270. * // using the `_.matches` callback shorthand
  5271. * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
  5272. * // => 'pebbles'
  5273. *
  5274. * // using the `_.matchesProperty` callback shorthand
  5275. * _.result(_.find(users, 'active', false), 'user');
  5276. * // => 'fred'
  5277. *
  5278. * // using the `_.property` callback shorthand
  5279. * _.result(_.find(users, 'active'), 'user');
  5280. * // => 'barney'
  5281. */
  5282. var find = createFind(baseEach);
  5283. module.exports = find;
  5284. },{"lodash._basecallback":18,"lodash._baseeach":20,"lodash._basefind":21,"lodash._basefindindex":22,"lodash.isarray":31}],30:[function(require,module,exports){
  5285. /**
  5286. * lodash (Custom Build) <https://lodash.com/>
  5287. * Build: `lodash modularize exports="npm" -o ./`
  5288. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5289. * Released under MIT license <https://lodash.com/license>
  5290. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5291. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5292. */
  5293. /** Used as references for various `Number` constants. */
  5294. var MAX_SAFE_INTEGER = 9007199254740991;
  5295. /** `Object#toString` result references. */
  5296. var argsTag = '[object Arguments]',
  5297. funcTag = '[object Function]',
  5298. genTag = '[object GeneratorFunction]';
  5299. /** Used for built-in method references. */
  5300. var objectProto = Object.prototype;
  5301. /** Used to check objects for own properties. */
  5302. var hasOwnProperty = objectProto.hasOwnProperty;
  5303. /**
  5304. * Used to resolve the
  5305. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  5306. * of values.
  5307. */
  5308. var objectToString = objectProto.toString;
  5309. /** Built-in value references. */
  5310. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  5311. /**
  5312. * Checks if `value` is likely an `arguments` object.
  5313. *
  5314. * @static
  5315. * @memberOf _
  5316. * @since 0.1.0
  5317. * @category Lang
  5318. * @param {*} value The value to check.
  5319. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  5320. * else `false`.
  5321. * @example
  5322. *
  5323. * _.isArguments(function() { return arguments; }());
  5324. * // => true
  5325. *
  5326. * _.isArguments([1, 2, 3]);
  5327. * // => false
  5328. */
  5329. function isArguments(value) {
  5330. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  5331. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  5332. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  5333. }
  5334. /**
  5335. * Checks if `value` is array-like. A value is considered array-like if it's
  5336. * not a function and has a `value.length` that's an integer greater than or
  5337. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  5338. *
  5339. * @static
  5340. * @memberOf _
  5341. * @since 4.0.0
  5342. * @category Lang
  5343. * @param {*} value The value to check.
  5344. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  5345. * @example
  5346. *
  5347. * _.isArrayLike([1, 2, 3]);
  5348. * // => true
  5349. *
  5350. * _.isArrayLike(document.body.children);
  5351. * // => true
  5352. *
  5353. * _.isArrayLike('abc');
  5354. * // => true
  5355. *
  5356. * _.isArrayLike(_.noop);
  5357. * // => false
  5358. */
  5359. function isArrayLike(value) {
  5360. return value != null && isLength(value.length) && !isFunction(value);
  5361. }
  5362. /**
  5363. * This method is like `_.isArrayLike` except that it also checks if `value`
  5364. * is an object.
  5365. *
  5366. * @static
  5367. * @memberOf _
  5368. * @since 4.0.0
  5369. * @category Lang
  5370. * @param {*} value The value to check.
  5371. * @returns {boolean} Returns `true` if `value` is an array-like object,
  5372. * else `false`.
  5373. * @example
  5374. *
  5375. * _.isArrayLikeObject([1, 2, 3]);
  5376. * // => true
  5377. *
  5378. * _.isArrayLikeObject(document.body.children);
  5379. * // => true
  5380. *
  5381. * _.isArrayLikeObject('abc');
  5382. * // => false
  5383. *
  5384. * _.isArrayLikeObject(_.noop);
  5385. * // => false
  5386. */
  5387. function isArrayLikeObject(value) {
  5388. return isObjectLike(value) && isArrayLike(value);
  5389. }
  5390. /**
  5391. * Checks if `value` is classified as a `Function` object.
  5392. *
  5393. * @static
  5394. * @memberOf _
  5395. * @since 0.1.0
  5396. * @category Lang
  5397. * @param {*} value The value to check.
  5398. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  5399. * @example
  5400. *
  5401. * _.isFunction(_);
  5402. * // => true
  5403. *
  5404. * _.isFunction(/abc/);
  5405. * // => false
  5406. */
  5407. function isFunction(value) {
  5408. // The use of `Object#toString` avoids issues with the `typeof` operator
  5409. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  5410. var tag = isObject(value) ? objectToString.call(value) : '';
  5411. return tag == funcTag || tag == genTag;
  5412. }
  5413. /**
  5414. * Checks if `value` is a valid array-like length.
  5415. *
  5416. * **Note:** This method is loosely based on
  5417. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  5418. *
  5419. * @static
  5420. * @memberOf _
  5421. * @since 4.0.0
  5422. * @category Lang
  5423. * @param {*} value The value to check.
  5424. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5425. * @example
  5426. *
  5427. * _.isLength(3);
  5428. * // => true
  5429. *
  5430. * _.isLength(Number.MIN_VALUE);
  5431. * // => false
  5432. *
  5433. * _.isLength(Infinity);
  5434. * // => false
  5435. *
  5436. * _.isLength('3');
  5437. * // => false
  5438. */
  5439. function isLength(value) {
  5440. return typeof value == 'number' &&
  5441. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5442. }
  5443. /**
  5444. * Checks if `value` is the
  5445. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  5446. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5447. *
  5448. * @static
  5449. * @memberOf _
  5450. * @since 0.1.0
  5451. * @category Lang
  5452. * @param {*} value The value to check.
  5453. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5454. * @example
  5455. *
  5456. * _.isObject({});
  5457. * // => true
  5458. *
  5459. * _.isObject([1, 2, 3]);
  5460. * // => true
  5461. *
  5462. * _.isObject(_.noop);
  5463. * // => true
  5464. *
  5465. * _.isObject(null);
  5466. * // => false
  5467. */
  5468. function isObject(value) {
  5469. var type = typeof value;
  5470. return !!value && (type == 'object' || type == 'function');
  5471. }
  5472. /**
  5473. * Checks if `value` is object-like. A value is object-like if it's not `null`
  5474. * and has a `typeof` result of "object".
  5475. *
  5476. * @static
  5477. * @memberOf _
  5478. * @since 4.0.0
  5479. * @category Lang
  5480. * @param {*} value The value to check.
  5481. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5482. * @example
  5483. *
  5484. * _.isObjectLike({});
  5485. * // => true
  5486. *
  5487. * _.isObjectLike([1, 2, 3]);
  5488. * // => true
  5489. *
  5490. * _.isObjectLike(_.noop);
  5491. * // => false
  5492. *
  5493. * _.isObjectLike(null);
  5494. * // => false
  5495. */
  5496. function isObjectLike(value) {
  5497. return !!value && typeof value == 'object';
  5498. }
  5499. module.exports = isArguments;
  5500. },{}],31:[function(require,module,exports){
  5501. /**
  5502. * lodash 3.0.4 (Custom Build) <https://lodash.com/>
  5503. * Build: `lodash modern modularize exports="npm" -o ./`
  5504. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5505. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5506. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5507. * Available under MIT license <https://lodash.com/license>
  5508. */
  5509. /** `Object#toString` result references. */
  5510. var arrayTag = '[object Array]',
  5511. funcTag = '[object Function]';
  5512. /** Used to detect host constructors (Safari > 5). */
  5513. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5514. /**
  5515. * Checks if `value` is object-like.
  5516. *
  5517. * @private
  5518. * @param {*} value The value to check.
  5519. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5520. */
  5521. function isObjectLike(value) {
  5522. return !!value && typeof value == 'object';
  5523. }
  5524. /** Used for native method references. */
  5525. var objectProto = Object.prototype;
  5526. /** Used to resolve the decompiled source of functions. */
  5527. var fnToString = Function.prototype.toString;
  5528. /** Used to check objects for own properties. */
  5529. var hasOwnProperty = objectProto.hasOwnProperty;
  5530. /**
  5531. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5532. * of values.
  5533. */
  5534. var objToString = objectProto.toString;
  5535. /** Used to detect if a method is native. */
  5536. var reIsNative = RegExp('^' +
  5537. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  5538. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  5539. );
  5540. /* Native method references for those with the same name as other `lodash` methods. */
  5541. var nativeIsArray = getNative(Array, 'isArray');
  5542. /**
  5543. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  5544. * of an array-like value.
  5545. */
  5546. var MAX_SAFE_INTEGER = 9007199254740991;
  5547. /**
  5548. * Gets the native function at `key` of `object`.
  5549. *
  5550. * @private
  5551. * @param {Object} object The object to query.
  5552. * @param {string} key The key of the method to get.
  5553. * @returns {*} Returns the function if it's native, else `undefined`.
  5554. */
  5555. function getNative(object, key) {
  5556. var value = object == null ? undefined : object[key];
  5557. return isNative(value) ? value : undefined;
  5558. }
  5559. /**
  5560. * Checks if `value` is a valid array-like length.
  5561. *
  5562. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  5563. *
  5564. * @private
  5565. * @param {*} value The value to check.
  5566. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5567. */
  5568. function isLength(value) {
  5569. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5570. }
  5571. /**
  5572. * Checks if `value` is classified as an `Array` object.
  5573. *
  5574. * @static
  5575. * @memberOf _
  5576. * @category Lang
  5577. * @param {*} value The value to check.
  5578. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5579. * @example
  5580. *
  5581. * _.isArray([1, 2, 3]);
  5582. * // => true
  5583. *
  5584. * _.isArray(function() { return arguments; }());
  5585. * // => false
  5586. */
  5587. var isArray = nativeIsArray || function(value) {
  5588. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  5589. };
  5590. /**
  5591. * Checks if `value` is classified as a `Function` object.
  5592. *
  5593. * @static
  5594. * @memberOf _
  5595. * @category Lang
  5596. * @param {*} value The value to check.
  5597. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  5598. * @example
  5599. *
  5600. * _.isFunction(_);
  5601. * // => true
  5602. *
  5603. * _.isFunction(/abc/);
  5604. * // => false
  5605. */
  5606. function isFunction(value) {
  5607. // The use of `Object#toString` avoids issues with the `typeof` operator
  5608. // in older versions of Chrome and Safari which return 'function' for regexes
  5609. // and Safari 8 equivalents which return 'object' for typed array constructors.
  5610. return isObject(value) && objToString.call(value) == funcTag;
  5611. }
  5612. /**
  5613. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  5614. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  5615. *
  5616. * @static
  5617. * @memberOf _
  5618. * @category Lang
  5619. * @param {*} value The value to check.
  5620. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  5621. * @example
  5622. *
  5623. * _.isObject({});
  5624. * // => true
  5625. *
  5626. * _.isObject([1, 2, 3]);
  5627. * // => true
  5628. *
  5629. * _.isObject(1);
  5630. * // => false
  5631. */
  5632. function isObject(value) {
  5633. // Avoid a V8 JIT bug in Chrome 19-20.
  5634. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  5635. var type = typeof value;
  5636. return !!value && (type == 'object' || type == 'function');
  5637. }
  5638. /**
  5639. * Checks if `value` is a native function.
  5640. *
  5641. * @static
  5642. * @memberOf _
  5643. * @category Lang
  5644. * @param {*} value The value to check.
  5645. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  5646. * @example
  5647. *
  5648. * _.isNative(Array.prototype.push);
  5649. * // => true
  5650. *
  5651. * _.isNative(_);
  5652. * // => false
  5653. */
  5654. function isNative(value) {
  5655. if (value == null) {
  5656. return false;
  5657. }
  5658. if (isFunction(value)) {
  5659. return reIsNative.test(fnToString.call(value));
  5660. }
  5661. return isObjectLike(value) && reIsHostCtor.test(value);
  5662. }
  5663. module.exports = isArray;
  5664. },{}],32:[function(require,module,exports){
  5665. /**
  5666. * lodash 3.2.0 (Custom Build) <https://lodash.com/>
  5667. * Build: `lodash modern modularize exports="npm" -o ./`
  5668. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5669. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5670. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5671. * Available under MIT license <https://lodash.com/license>
  5672. */
  5673. var baseFor = require('lodash._basefor'),
  5674. isArguments = require('lodash.isarguments'),
  5675. keysIn = require('lodash.keysin');
  5676. /** `Object#toString` result references. */
  5677. var objectTag = '[object Object]';
  5678. /**
  5679. * Checks if `value` is object-like.
  5680. *
  5681. * @private
  5682. * @param {*} value The value to check.
  5683. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5684. */
  5685. function isObjectLike(value) {
  5686. return !!value && typeof value == 'object';
  5687. }
  5688. /** Used for native method references. */
  5689. var objectProto = Object.prototype;
  5690. /** Used to check objects for own properties. */
  5691. var hasOwnProperty = objectProto.hasOwnProperty;
  5692. /**
  5693. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5694. * of values.
  5695. */
  5696. var objToString = objectProto.toString;
  5697. /**
  5698. * The base implementation of `_.forIn` without support for callback
  5699. * shorthands and `this` binding.
  5700. *
  5701. * @private
  5702. * @param {Object} object The object to iterate over.
  5703. * @param {Function} iteratee The function invoked per iteration.
  5704. * @returns {Object} Returns `object`.
  5705. */
  5706. function baseForIn(object, iteratee) {
  5707. return baseFor(object, iteratee, keysIn);
  5708. }
  5709. /**
  5710. * Checks if `value` is a plain object, that is, an object created by the
  5711. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  5712. *
  5713. * **Note:** This method assumes objects created by the `Object` constructor
  5714. * have no inherited enumerable properties.
  5715. *
  5716. * @static
  5717. * @memberOf _
  5718. * @category Lang
  5719. * @param {*} value The value to check.
  5720. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  5721. * @example
  5722. *
  5723. * function Foo() {
  5724. * this.a = 1;
  5725. * }
  5726. *
  5727. * _.isPlainObject(new Foo);
  5728. * // => false
  5729. *
  5730. * _.isPlainObject([1, 2, 3]);
  5731. * // => false
  5732. *
  5733. * _.isPlainObject({ 'x': 0, 'y': 0 });
  5734. * // => true
  5735. *
  5736. * _.isPlainObject(Object.create(null));
  5737. * // => true
  5738. */
  5739. function isPlainObject(value) {
  5740. var Ctor;
  5741. // Exit early for non `Object` objects.
  5742. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
  5743. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  5744. return false;
  5745. }
  5746. // IE < 9 iterates inherited properties before own properties. If the first
  5747. // iterated property is an object's own property then there are no inherited
  5748. // enumerable properties.
  5749. var result;
  5750. // In most environments an object's own properties are iterated before
  5751. // its inherited properties. If the last iterated property is an object's
  5752. // own property then there are no inherited enumerable properties.
  5753. baseForIn(value, function(subValue, key) {
  5754. result = key;
  5755. });
  5756. return result === undefined || hasOwnProperty.call(value, result);
  5757. }
  5758. module.exports = isPlainObject;
  5759. },{"lodash._basefor":23,"lodash.isarguments":30,"lodash.keysin":35}],33:[function(require,module,exports){
  5760. /**
  5761. * lodash 3.0.6 (Custom Build) <https://lodash.com/>
  5762. * Build: `lodash modularize exports="npm" -o ./`
  5763. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5764. * Released under MIT license <https://lodash.com/license>
  5765. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5766. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5767. */
  5768. /** Used as references for various `Number` constants. */
  5769. var MAX_SAFE_INTEGER = 9007199254740991;
  5770. /** `Object#toString` result references. */
  5771. var argsTag = '[object Arguments]',
  5772. arrayTag = '[object Array]',
  5773. boolTag = '[object Boolean]',
  5774. dateTag = '[object Date]',
  5775. errorTag = '[object Error]',
  5776. funcTag = '[object Function]',
  5777. mapTag = '[object Map]',
  5778. numberTag = '[object Number]',
  5779. objectTag = '[object Object]',
  5780. regexpTag = '[object RegExp]',
  5781. setTag = '[object Set]',
  5782. stringTag = '[object String]',
  5783. weakMapTag = '[object WeakMap]';
  5784. var arrayBufferTag = '[object ArrayBuffer]',
  5785. dataViewTag = '[object DataView]',
  5786. float32Tag = '[object Float32Array]',
  5787. float64Tag = '[object Float64Array]',
  5788. int8Tag = '[object Int8Array]',
  5789. int16Tag = '[object Int16Array]',
  5790. int32Tag = '[object Int32Array]',
  5791. uint8Tag = '[object Uint8Array]',
  5792. uint8ClampedTag = '[object Uint8ClampedArray]',
  5793. uint16Tag = '[object Uint16Array]',
  5794. uint32Tag = '[object Uint32Array]';
  5795. /** Used to identify `toStringTag` values of typed arrays. */
  5796. var typedArrayTags = {};
  5797. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  5798. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  5799. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  5800. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  5801. typedArrayTags[uint32Tag] = true;
  5802. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  5803. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  5804. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  5805. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  5806. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  5807. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  5808. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  5809. typedArrayTags[weakMapTag] = false;
  5810. /** Used for built-in method references. */
  5811. var objectProto = Object.prototype;
  5812. /**
  5813. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  5814. * of values.
  5815. */
  5816. var objectToString = objectProto.toString;
  5817. /**
  5818. * Checks if `value` is a valid array-like length.
  5819. *
  5820. * **Note:** This function is loosely based on
  5821. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  5822. *
  5823. * @static
  5824. * @memberOf _
  5825. * @since 4.0.0
  5826. * @category Lang
  5827. * @param {*} value The value to check.
  5828. * @returns {boolean} Returns `true` if `value` is a valid length,
  5829. * else `false`.
  5830. * @example
  5831. *
  5832. * _.isLength(3);
  5833. * // => true
  5834. *
  5835. * _.isLength(Number.MIN_VALUE);
  5836. * // => false
  5837. *
  5838. * _.isLength(Infinity);
  5839. * // => false
  5840. *
  5841. * _.isLength('3');
  5842. * // => false
  5843. */
  5844. function isLength(value) {
  5845. return typeof value == 'number' &&
  5846. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5847. }
  5848. /**
  5849. * Checks if `value` is object-like. A value is object-like if it's not `null`
  5850. * and has a `typeof` result of "object".
  5851. *
  5852. * @static
  5853. * @memberOf _
  5854. * @since 4.0.0
  5855. * @category Lang
  5856. * @param {*} value The value to check.
  5857. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  5858. * @example
  5859. *
  5860. * _.isObjectLike({});
  5861. * // => true
  5862. *
  5863. * _.isObjectLike([1, 2, 3]);
  5864. * // => true
  5865. *
  5866. * _.isObjectLike(_.noop);
  5867. * // => false
  5868. *
  5869. * _.isObjectLike(null);
  5870. * // => false
  5871. */
  5872. function isObjectLike(value) {
  5873. return !!value && typeof value == 'object';
  5874. }
  5875. /**
  5876. * Checks if `value` is classified as a typed array.
  5877. *
  5878. * @static
  5879. * @memberOf _
  5880. * @since 3.0.0
  5881. * @category Lang
  5882. * @param {*} value The value to check.
  5883. * @returns {boolean} Returns `true` if `value` is correctly classified,
  5884. * else `false`.
  5885. * @example
  5886. *
  5887. * _.isTypedArray(new Uint8Array);
  5888. * // => true
  5889. *
  5890. * _.isTypedArray([]);
  5891. * // => false
  5892. */
  5893. function isTypedArray(value) {
  5894. return isObjectLike(value) &&
  5895. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  5896. }
  5897. module.exports = isTypedArray;
  5898. },{}],34:[function(require,module,exports){
  5899. /**
  5900. * lodash 3.1.2 (Custom Build) <https://lodash.com/>
  5901. * Build: `lodash modern modularize exports="npm" -o ./`
  5902. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5903. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  5904. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  5905. * Available under MIT license <https://lodash.com/license>
  5906. */
  5907. var getNative = require('lodash._getnative'),
  5908. isArguments = require('lodash.isarguments'),
  5909. isArray = require('lodash.isarray');
  5910. /** Used to detect unsigned integer values. */
  5911. var reIsUint = /^\d+$/;
  5912. /** Used for native method references. */
  5913. var objectProto = Object.prototype;
  5914. /** Used to check objects for own properties. */
  5915. var hasOwnProperty = objectProto.hasOwnProperty;
  5916. /* Native method references for those with the same name as other `lodash` methods. */
  5917. var nativeKeys = getNative(Object, 'keys');
  5918. /**
  5919. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  5920. * of an array-like value.
  5921. */
  5922. var MAX_SAFE_INTEGER = 9007199254740991;
  5923. /**
  5924. * The base implementation of `_.property` without support for deep paths.
  5925. *
  5926. * @private
  5927. * @param {string} key The key of the property to get.
  5928. * @returns {Function} Returns the new function.
  5929. */
  5930. function baseProperty(key) {
  5931. return function(object) {
  5932. return object == null ? undefined : object[key];
  5933. };
  5934. }
  5935. /**
  5936. * Gets the "length" property value of `object`.
  5937. *
  5938. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  5939. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  5940. *
  5941. * @private
  5942. * @param {Object} object The object to query.
  5943. * @returns {*} Returns the "length" value.
  5944. */
  5945. var getLength = baseProperty('length');
  5946. /**
  5947. * Checks if `value` is array-like.
  5948. *
  5949. * @private
  5950. * @param {*} value The value to check.
  5951. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  5952. */
  5953. function isArrayLike(value) {
  5954. return value != null && isLength(getLength(value));
  5955. }
  5956. /**
  5957. * Checks if `value` is a valid array-like index.
  5958. *
  5959. * @private
  5960. * @param {*} value The value to check.
  5961. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  5962. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  5963. */
  5964. function isIndex(value, length) {
  5965. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  5966. length = length == null ? MAX_SAFE_INTEGER : length;
  5967. return value > -1 && value % 1 == 0 && value < length;
  5968. }
  5969. /**
  5970. * Checks if `value` is a valid array-like length.
  5971. *
  5972. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  5973. *
  5974. * @private
  5975. * @param {*} value The value to check.
  5976. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  5977. */
  5978. function isLength(value) {
  5979. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  5980. }
  5981. /**
  5982. * A fallback implementation of `Object.keys` which creates an array of the
  5983. * own enumerable property names of `object`.
  5984. *
  5985. * @private
  5986. * @param {Object} object The object to query.
  5987. * @returns {Array} Returns the array of property names.
  5988. */
  5989. function shimKeys(object) {
  5990. var props = keysIn(object),
  5991. propsLength = props.length,
  5992. length = propsLength && object.length;
  5993. var allowIndexes = !!length && isLength(length) &&
  5994. (isArray(object) || isArguments(object));
  5995. var index = -1,
  5996. result = [];
  5997. while (++index < propsLength) {
  5998. var key = props[index];
  5999. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  6000. result.push(key);
  6001. }
  6002. }
  6003. return result;
  6004. }
  6005. /**
  6006. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6007. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6008. *
  6009. * @static
  6010. * @memberOf _
  6011. * @category Lang
  6012. * @param {*} value The value to check.
  6013. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6014. * @example
  6015. *
  6016. * _.isObject({});
  6017. * // => true
  6018. *
  6019. * _.isObject([1, 2, 3]);
  6020. * // => true
  6021. *
  6022. * _.isObject(1);
  6023. * // => false
  6024. */
  6025. function isObject(value) {
  6026. // Avoid a V8 JIT bug in Chrome 19-20.
  6027. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6028. var type = typeof value;
  6029. return !!value && (type == 'object' || type == 'function');
  6030. }
  6031. /**
  6032. * Creates an array of the own enumerable property names of `object`.
  6033. *
  6034. * **Note:** Non-object values are coerced to objects. See the
  6035. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  6036. * for more details.
  6037. *
  6038. * @static
  6039. * @memberOf _
  6040. * @category Object
  6041. * @param {Object} object The object to query.
  6042. * @returns {Array} Returns the array of property names.
  6043. * @example
  6044. *
  6045. * function Foo() {
  6046. * this.a = 1;
  6047. * this.b = 2;
  6048. * }
  6049. *
  6050. * Foo.prototype.c = 3;
  6051. *
  6052. * _.keys(new Foo);
  6053. * // => ['a', 'b'] (iteration order is not guaranteed)
  6054. *
  6055. * _.keys('hi');
  6056. * // => ['0', '1']
  6057. */
  6058. var keys = !nativeKeys ? shimKeys : function(object) {
  6059. var Ctor = object == null ? undefined : object.constructor;
  6060. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  6061. (typeof object != 'function' && isArrayLike(object))) {
  6062. return shimKeys(object);
  6063. }
  6064. return isObject(object) ? nativeKeys(object) : [];
  6065. };
  6066. /**
  6067. * Creates an array of the own and inherited enumerable property names of `object`.
  6068. *
  6069. * **Note:** Non-object values are coerced to objects.
  6070. *
  6071. * @static
  6072. * @memberOf _
  6073. * @category Object
  6074. * @param {Object} object The object to query.
  6075. * @returns {Array} Returns the array of property names.
  6076. * @example
  6077. *
  6078. * function Foo() {
  6079. * this.a = 1;
  6080. * this.b = 2;
  6081. * }
  6082. *
  6083. * Foo.prototype.c = 3;
  6084. *
  6085. * _.keysIn(new Foo);
  6086. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  6087. */
  6088. function keysIn(object) {
  6089. if (object == null) {
  6090. return [];
  6091. }
  6092. if (!isObject(object)) {
  6093. object = Object(object);
  6094. }
  6095. var length = object.length;
  6096. length = (length && isLength(length) &&
  6097. (isArray(object) || isArguments(object)) && length) || 0;
  6098. var Ctor = object.constructor,
  6099. index = -1,
  6100. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  6101. result = Array(length),
  6102. skipIndexes = length > 0;
  6103. while (++index < length) {
  6104. result[index] = (index + '');
  6105. }
  6106. for (var key in object) {
  6107. if (!(skipIndexes && isIndex(key, length)) &&
  6108. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  6109. result.push(key);
  6110. }
  6111. }
  6112. return result;
  6113. }
  6114. module.exports = keys;
  6115. },{"lodash._getnative":27,"lodash.isarguments":30,"lodash.isarray":31}],35:[function(require,module,exports){
  6116. /**
  6117. * lodash 3.0.8 (Custom Build) <https://lodash.com/>
  6118. * Build: `lodash modern modularize exports="npm" -o ./`
  6119. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6120. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6121. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6122. * Available under MIT license <https://lodash.com/license>
  6123. */
  6124. var isArguments = require('lodash.isarguments'),
  6125. isArray = require('lodash.isarray');
  6126. /** Used to detect unsigned integer values. */
  6127. var reIsUint = /^\d+$/;
  6128. /** Used for native method references. */
  6129. var objectProto = Object.prototype;
  6130. /** Used to check objects for own properties. */
  6131. var hasOwnProperty = objectProto.hasOwnProperty;
  6132. /**
  6133. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  6134. * of an array-like value.
  6135. */
  6136. var MAX_SAFE_INTEGER = 9007199254740991;
  6137. /**
  6138. * Checks if `value` is a valid array-like index.
  6139. *
  6140. * @private
  6141. * @param {*} value The value to check.
  6142. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  6143. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  6144. */
  6145. function isIndex(value, length) {
  6146. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  6147. length = length == null ? MAX_SAFE_INTEGER : length;
  6148. return value > -1 && value % 1 == 0 && value < length;
  6149. }
  6150. /**
  6151. * Checks if `value` is a valid array-like length.
  6152. *
  6153. * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
  6154. *
  6155. * @private
  6156. * @param {*} value The value to check.
  6157. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  6158. */
  6159. function isLength(value) {
  6160. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  6161. }
  6162. /**
  6163. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6164. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6165. *
  6166. * @static
  6167. * @memberOf _
  6168. * @category Lang
  6169. * @param {*} value The value to check.
  6170. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6171. * @example
  6172. *
  6173. * _.isObject({});
  6174. * // => true
  6175. *
  6176. * _.isObject([1, 2, 3]);
  6177. * // => true
  6178. *
  6179. * _.isObject(1);
  6180. * // => false
  6181. */
  6182. function isObject(value) {
  6183. // Avoid a V8 JIT bug in Chrome 19-20.
  6184. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6185. var type = typeof value;
  6186. return !!value && (type == 'object' || type == 'function');
  6187. }
  6188. /**
  6189. * Creates an array of the own and inherited enumerable property names of `object`.
  6190. *
  6191. * **Note:** Non-object values are coerced to objects.
  6192. *
  6193. * @static
  6194. * @memberOf _
  6195. * @category Object
  6196. * @param {Object} object The object to query.
  6197. * @returns {Array} Returns the array of property names.
  6198. * @example
  6199. *
  6200. * function Foo() {
  6201. * this.a = 1;
  6202. * this.b = 2;
  6203. * }
  6204. *
  6205. * Foo.prototype.c = 3;
  6206. *
  6207. * _.keysIn(new Foo);
  6208. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  6209. */
  6210. function keysIn(object) {
  6211. if (object == null) {
  6212. return [];
  6213. }
  6214. if (!isObject(object)) {
  6215. object = Object(object);
  6216. }
  6217. var length = object.length;
  6218. length = (length && isLength(length) &&
  6219. (isArray(object) || isArguments(object)) && length) || 0;
  6220. var Ctor = object.constructor,
  6221. index = -1,
  6222. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  6223. result = Array(length),
  6224. skipIndexes = length > 0;
  6225. while (++index < length) {
  6226. result[index] = (index + '');
  6227. }
  6228. for (var key in object) {
  6229. if (!(skipIndexes && isIndex(key, length)) &&
  6230. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  6231. result.push(key);
  6232. }
  6233. }
  6234. return result;
  6235. }
  6236. module.exports = keysIn;
  6237. },{"lodash.isarguments":30,"lodash.isarray":31}],36:[function(require,module,exports){
  6238. /**
  6239. * lodash 3.3.2 (Custom Build) <https://lodash.com/>
  6240. * Build: `lodash modern modularize exports="npm" -o ./`
  6241. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6242. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6243. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6244. * Available under MIT license <https://lodash.com/license>
  6245. */
  6246. var arrayCopy = require('lodash._arraycopy'),
  6247. arrayEach = require('lodash._arrayeach'),
  6248. createAssigner = require('lodash._createassigner'),
  6249. isArguments = require('lodash.isarguments'),
  6250. isArray = require('lodash.isarray'),
  6251. isPlainObject = require('lodash.isplainobject'),
  6252. isTypedArray = require('lodash.istypedarray'),
  6253. keys = require('lodash.keys'),
  6254. toPlainObject = require('lodash.toplainobject');
  6255. /**
  6256. * Checks if `value` is object-like.
  6257. *
  6258. * @private
  6259. * @param {*} value The value to check.
  6260. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  6261. */
  6262. function isObjectLike(value) {
  6263. return !!value && typeof value == 'object';
  6264. }
  6265. /**
  6266. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  6267. * of an array-like value.
  6268. */
  6269. var MAX_SAFE_INTEGER = 9007199254740991;
  6270. /**
  6271. * The base implementation of `_.merge` without support for argument juggling,
  6272. * multiple sources, and `this` binding `customizer` functions.
  6273. *
  6274. * @private
  6275. * @param {Object} object The destination object.
  6276. * @param {Object} source The source object.
  6277. * @param {Function} [customizer] The function to customize merged values.
  6278. * @param {Array} [stackA=[]] Tracks traversed source objects.
  6279. * @param {Array} [stackB=[]] Associates values with source counterparts.
  6280. * @returns {Object} Returns `object`.
  6281. */
  6282. function baseMerge(object, source, customizer, stackA, stackB) {
  6283. if (!isObject(object)) {
  6284. return object;
  6285. }
  6286. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  6287. props = isSrcArr ? undefined : keys(source);
  6288. arrayEach(props || source, function(srcValue, key) {
  6289. if (props) {
  6290. key = srcValue;
  6291. srcValue = source[key];
  6292. }
  6293. if (isObjectLike(srcValue)) {
  6294. stackA || (stackA = []);
  6295. stackB || (stackB = []);
  6296. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  6297. }
  6298. else {
  6299. var value = object[key],
  6300. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  6301. isCommon = result === undefined;
  6302. if (isCommon) {
  6303. result = srcValue;
  6304. }
  6305. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  6306. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  6307. object[key] = result;
  6308. }
  6309. }
  6310. });
  6311. return object;
  6312. }
  6313. /**
  6314. * A specialized version of `baseMerge` for arrays and objects which performs
  6315. * deep merges and tracks traversed objects enabling objects with circular
  6316. * references to be merged.
  6317. *
  6318. * @private
  6319. * @param {Object} object The destination object.
  6320. * @param {Object} source The source object.
  6321. * @param {string} key The key of the value to merge.
  6322. * @param {Function} mergeFunc The function to merge values.
  6323. * @param {Function} [customizer] The function to customize merged values.
  6324. * @param {Array} [stackA=[]] Tracks traversed source objects.
  6325. * @param {Array} [stackB=[]] Associates values with source counterparts.
  6326. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6327. */
  6328. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  6329. var length = stackA.length,
  6330. srcValue = source[key];
  6331. while (length--) {
  6332. if (stackA[length] == srcValue) {
  6333. object[key] = stackB[length];
  6334. return;
  6335. }
  6336. }
  6337. var value = object[key],
  6338. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  6339. isCommon = result === undefined;
  6340. if (isCommon) {
  6341. result = srcValue;
  6342. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  6343. result = isArray(value)
  6344. ? value
  6345. : (isArrayLike(value) ? arrayCopy(value) : []);
  6346. }
  6347. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  6348. result = isArguments(value)
  6349. ? toPlainObject(value)
  6350. : (isPlainObject(value) ? value : {});
  6351. }
  6352. else {
  6353. isCommon = false;
  6354. }
  6355. }
  6356. // Add the source value to the stack of traversed objects and associate
  6357. // it with its merged value.
  6358. stackA.push(srcValue);
  6359. stackB.push(result);
  6360. if (isCommon) {
  6361. // Recursively merge objects and arrays (susceptible to call stack limits).
  6362. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  6363. } else if (result === result ? (result !== value) : (value === value)) {
  6364. object[key] = result;
  6365. }
  6366. }
  6367. /**
  6368. * The base implementation of `_.property` without support for deep paths.
  6369. *
  6370. * @private
  6371. * @param {string} key The key of the property to get.
  6372. * @returns {Function} Returns the new function.
  6373. */
  6374. function baseProperty(key) {
  6375. return function(object) {
  6376. return object == null ? undefined : object[key];
  6377. };
  6378. }
  6379. /**
  6380. * Gets the "length" property value of `object`.
  6381. *
  6382. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  6383. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  6384. *
  6385. * @private
  6386. * @param {Object} object The object to query.
  6387. * @returns {*} Returns the "length" value.
  6388. */
  6389. var getLength = baseProperty('length');
  6390. /**
  6391. * Checks if `value` is array-like.
  6392. *
  6393. * @private
  6394. * @param {*} value The value to check.
  6395. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  6396. */
  6397. function isArrayLike(value) {
  6398. return value != null && isLength(getLength(value));
  6399. }
  6400. /**
  6401. * Checks if `value` is a valid array-like length.
  6402. *
  6403. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  6404. *
  6405. * @private
  6406. * @param {*} value The value to check.
  6407. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  6408. */
  6409. function isLength(value) {
  6410. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  6411. }
  6412. /**
  6413. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6414. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6415. *
  6416. * @static
  6417. * @memberOf _
  6418. * @category Lang
  6419. * @param {*} value The value to check.
  6420. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6421. * @example
  6422. *
  6423. * _.isObject({});
  6424. * // => true
  6425. *
  6426. * _.isObject([1, 2, 3]);
  6427. * // => true
  6428. *
  6429. * _.isObject(1);
  6430. * // => false
  6431. */
  6432. function isObject(value) {
  6433. // Avoid a V8 JIT bug in Chrome 19-20.
  6434. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6435. var type = typeof value;
  6436. return !!value && (type == 'object' || type == 'function');
  6437. }
  6438. /**
  6439. * Recursively merges own enumerable properties of the source object(s), that
  6440. * don't resolve to `undefined` into the destination object. Subsequent sources
  6441. * overwrite property assignments of previous sources. If `customizer` is
  6442. * provided it is invoked to produce the merged values of the destination and
  6443. * source properties. If `customizer` returns `undefined` merging is handled
  6444. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  6445. * with five arguments: (objectValue, sourceValue, key, object, source).
  6446. *
  6447. * @static
  6448. * @memberOf _
  6449. * @category Object
  6450. * @param {Object} object The destination object.
  6451. * @param {...Object} [sources] The source objects.
  6452. * @param {Function} [customizer] The function to customize assigned values.
  6453. * @param {*} [thisArg] The `this` binding of `customizer`.
  6454. * @returns {Object} Returns `object`.
  6455. * @example
  6456. *
  6457. * var users = {
  6458. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  6459. * };
  6460. *
  6461. * var ages = {
  6462. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  6463. * };
  6464. *
  6465. * _.merge(users, ages);
  6466. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  6467. *
  6468. * // using a customizer callback
  6469. * var object = {
  6470. * 'fruits': ['apple'],
  6471. * 'vegetables': ['beet']
  6472. * };
  6473. *
  6474. * var other = {
  6475. * 'fruits': ['banana'],
  6476. * 'vegetables': ['carrot']
  6477. * };
  6478. *
  6479. * _.merge(object, other, function(a, b) {
  6480. * if (_.isArray(a)) {
  6481. * return a.concat(b);
  6482. * }
  6483. * });
  6484. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  6485. */
  6486. var merge = createAssigner(baseMerge);
  6487. module.exports = merge;
  6488. },{"lodash._arraycopy":16,"lodash._arrayeach":17,"lodash._createassigner":26,"lodash.isarguments":30,"lodash.isarray":31,"lodash.isplainobject":32,"lodash.istypedarray":33,"lodash.keys":34,"lodash.toplainobject":39}],37:[function(require,module,exports){
  6489. /**
  6490. * lodash 3.0.1 (Custom Build) <https://lodash.com/>
  6491. * Build: `lodash modern modularize exports="npm" -o ./`
  6492. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6493. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6494. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6495. * Available under MIT license <https://lodash.com/license>
  6496. */
  6497. var keys = require('lodash.keys');
  6498. /**
  6499. * Converts `value` to an object if it's not one.
  6500. *
  6501. * @private
  6502. * @param {*} value The value to process.
  6503. * @returns {Object} Returns the object.
  6504. */
  6505. function toObject(value) {
  6506. return isObject(value) ? value : Object(value);
  6507. }
  6508. /**
  6509. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  6510. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6511. *
  6512. * @static
  6513. * @memberOf _
  6514. * @category Lang
  6515. * @param {*} value The value to check.
  6516. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  6517. * @example
  6518. *
  6519. * _.isObject({});
  6520. * // => true
  6521. *
  6522. * _.isObject([1, 2, 3]);
  6523. * // => true
  6524. *
  6525. * _.isObject(1);
  6526. * // => false
  6527. */
  6528. function isObject(value) {
  6529. // Avoid a V8 JIT bug in Chrome 19-20.
  6530. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  6531. var type = typeof value;
  6532. return !!value && (type == 'object' || type == 'function');
  6533. }
  6534. /**
  6535. * Creates a two dimensional array of the key-value pairs for `object`,
  6536. * e.g. `[[key1, value1], [key2, value2]]`.
  6537. *
  6538. * @static
  6539. * @memberOf _
  6540. * @category Object
  6541. * @param {Object} object The object to query.
  6542. * @returns {Array} Returns the new array of key-value pairs.
  6543. * @example
  6544. *
  6545. * _.pairs({ 'barney': 36, 'fred': 40 });
  6546. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  6547. */
  6548. function pairs(object) {
  6549. object = toObject(object);
  6550. var index = -1,
  6551. props = keys(object),
  6552. length = props.length,
  6553. result = Array(length);
  6554. while (++index < length) {
  6555. var key = props[index];
  6556. result[index] = [key, object[key]];
  6557. }
  6558. return result;
  6559. }
  6560. module.exports = pairs;
  6561. },{"lodash.keys":34}],38:[function(require,module,exports){
  6562. /**
  6563. * lodash 3.6.1 (Custom Build) <https://lodash.com/>
  6564. * Build: `lodash modern modularize exports="npm" -o ./`
  6565. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6566. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6567. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6568. * Available under MIT license <https://lodash.com/license>
  6569. */
  6570. /** Used as the `TypeError` message for "Functions" methods. */
  6571. var FUNC_ERROR_TEXT = 'Expected a function';
  6572. /* Native method references for those with the same name as other `lodash` methods. */
  6573. var nativeMax = Math.max;
  6574. /**
  6575. * Creates a function that invokes `func` with the `this` binding of the
  6576. * created function and arguments from `start` and beyond provided as an array.
  6577. *
  6578. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
  6579. *
  6580. * @static
  6581. * @memberOf _
  6582. * @category Function
  6583. * @param {Function} func The function to apply a rest parameter to.
  6584. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6585. * @returns {Function} Returns the new function.
  6586. * @example
  6587. *
  6588. * var say = _.restParam(function(what, names) {
  6589. * return what + ' ' + _.initial(names).join(', ') +
  6590. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  6591. * });
  6592. *
  6593. * say('hello', 'fred', 'barney', 'pebbles');
  6594. * // => 'hello fred, barney, & pebbles'
  6595. */
  6596. function restParam(func, start) {
  6597. if (typeof func != 'function') {
  6598. throw new TypeError(FUNC_ERROR_TEXT);
  6599. }
  6600. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  6601. return function() {
  6602. var args = arguments,
  6603. index = -1,
  6604. length = nativeMax(args.length - start, 0),
  6605. rest = Array(length);
  6606. while (++index < length) {
  6607. rest[index] = args[start + index];
  6608. }
  6609. switch (start) {
  6610. case 0: return func.call(this, rest);
  6611. case 1: return func.call(this, args[0], rest);
  6612. case 2: return func.call(this, args[0], args[1], rest);
  6613. }
  6614. var otherArgs = Array(start + 1);
  6615. index = -1;
  6616. while (++index < start) {
  6617. otherArgs[index] = args[index];
  6618. }
  6619. otherArgs[start] = rest;
  6620. return func.apply(this, otherArgs);
  6621. };
  6622. }
  6623. module.exports = restParam;
  6624. },{}],39:[function(require,module,exports){
  6625. /**
  6626. * lodash 3.0.0 (Custom Build) <https://lodash.com/>
  6627. * Build: `lodash modern modularize exports="npm" -o ./`
  6628. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6629. * Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
  6630. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  6631. * Available under MIT license <https://lodash.com/license>
  6632. */
  6633. var baseCopy = require('lodash._basecopy'),
  6634. keysIn = require('lodash.keysin');
  6635. /**
  6636. * Converts `value` to a plain object flattening inherited enumerable
  6637. * properties of `value` to own properties of the plain object.
  6638. *
  6639. * @static
  6640. * @memberOf _
  6641. * @category Lang
  6642. * @param {*} value The value to convert.
  6643. * @returns {Object} Returns the converted plain object.
  6644. * @example
  6645. *
  6646. * function Foo() {
  6647. * this.b = 2;
  6648. * }
  6649. *
  6650. * Foo.prototype.c = 3;
  6651. *
  6652. * _.assign({ 'a': 1 }, new Foo);
  6653. * // => { 'a': 1, 'b': 2 }
  6654. *
  6655. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  6656. * // => { 'a': 1, 'b': 2, 'c': 3 }
  6657. */
  6658. function toPlainObject(value) {
  6659. return baseCopy(value, keysIn(value));
  6660. }
  6661. module.exports = toPlainObject;
  6662. },{"lodash._basecopy":19,"lodash.keysin":35}],40:[function(require,module,exports){
  6663. (function (global){
  6664. /*! https://mths.be/punycode v1.4.1 by @mathias */
  6665. ;(function(root) {
  6666. /** Detect free variables */
  6667. var freeExports = typeof exports == 'object' && exports &&
  6668. !exports.nodeType && exports;
  6669. var freeModule = typeof module == 'object' && module &&
  6670. !module.nodeType && module;
  6671. var freeGlobal = typeof global == 'object' && global;
  6672. if (
  6673. freeGlobal.global === freeGlobal ||
  6674. freeGlobal.window === freeGlobal ||
  6675. freeGlobal.self === freeGlobal
  6676. ) {
  6677. root = freeGlobal;
  6678. }
  6679. /**
  6680. * The `punycode` object.
  6681. * @name punycode
  6682. * @type Object
  6683. */
  6684. var punycode,
  6685. /** Highest positive signed 32-bit float value */
  6686. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  6687. /** Bootstring parameters */
  6688. base = 36,
  6689. tMin = 1,
  6690. tMax = 26,
  6691. skew = 38,
  6692. damp = 700,
  6693. initialBias = 72,
  6694. initialN = 128, // 0x80
  6695. delimiter = '-', // '\x2D'
  6696. /** Regular expressions */
  6697. regexPunycode = /^xn--/,
  6698. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  6699. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  6700. /** Error messages */
  6701. errors = {
  6702. 'overflow': 'Overflow: input needs wider integers to process',
  6703. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  6704. 'invalid-input': 'Invalid input'
  6705. },
  6706. /** Convenience shortcuts */
  6707. baseMinusTMin = base - tMin,
  6708. floor = Math.floor,
  6709. stringFromCharCode = String.fromCharCode,
  6710. /** Temporary variable */
  6711. key;
  6712. /*--------------------------------------------------------------------------*/
  6713. /**
  6714. * A generic error utility function.
  6715. * @private
  6716. * @param {String} type The error type.
  6717. * @returns {Error} Throws a `RangeError` with the applicable error message.
  6718. */
  6719. function error(type) {
  6720. throw new RangeError(errors[type]);
  6721. }
  6722. /**
  6723. * A generic `Array#map` utility function.
  6724. * @private
  6725. * @param {Array} array The array to iterate over.
  6726. * @param {Function} callback The function that gets called for every array
  6727. * item.
  6728. * @returns {Array} A new array of values returned by the callback function.
  6729. */
  6730. function map(array, fn) {
  6731. var length = array.length;
  6732. var result = [];
  6733. while (length--) {
  6734. result[length] = fn(array[length]);
  6735. }
  6736. return result;
  6737. }
  6738. /**
  6739. * A simple `Array#map`-like wrapper to work with domain name strings or email
  6740. * addresses.
  6741. * @private
  6742. * @param {String} domain The domain name or email address.
  6743. * @param {Function} callback The function that gets called for every
  6744. * character.
  6745. * @returns {Array} A new string of characters returned by the callback
  6746. * function.
  6747. */
  6748. function mapDomain(string, fn) {
  6749. var parts = string.split('@');
  6750. var result = '';
  6751. if (parts.length > 1) {
  6752. // In email addresses, only the domain name should be punycoded. Leave
  6753. // the local part (i.e. everything up to `@`) intact.
  6754. result = parts[0] + '@';
  6755. string = parts[1];
  6756. }
  6757. // Avoid `split(regex)` for IE8 compatibility. See #17.
  6758. string = string.replace(regexSeparators, '\x2E');
  6759. var labels = string.split('.');
  6760. var encoded = map(labels, fn).join('.');
  6761. return result + encoded;
  6762. }
  6763. /**
  6764. * Creates an array containing the numeric code points of each Unicode
  6765. * character in the string. While JavaScript uses UCS-2 internally,
  6766. * this function will convert a pair of surrogate halves (each of which
  6767. * UCS-2 exposes as separate characters) into a single code point,
  6768. * matching UTF-16.
  6769. * @see `punycode.ucs2.encode`
  6770. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6771. * @memberOf punycode.ucs2
  6772. * @name decode
  6773. * @param {String} string The Unicode input string (UCS-2).
  6774. * @returns {Array} The new array of code points.
  6775. */
  6776. function ucs2decode(string) {
  6777. var output = [],
  6778. counter = 0,
  6779. length = string.length,
  6780. value,
  6781. extra;
  6782. while (counter < length) {
  6783. value = string.charCodeAt(counter++);
  6784. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6785. // high surrogate, and there is a next character
  6786. extra = string.charCodeAt(counter++);
  6787. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  6788. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6789. } else {
  6790. // unmatched surrogate; only append this code unit, in case the next
  6791. // code unit is the high surrogate of a surrogate pair
  6792. output.push(value);
  6793. counter--;
  6794. }
  6795. } else {
  6796. output.push(value);
  6797. }
  6798. }
  6799. return output;
  6800. }
  6801. /**
  6802. * Creates a string based on an array of numeric code points.
  6803. * @see `punycode.ucs2.decode`
  6804. * @memberOf punycode.ucs2
  6805. * @name encode
  6806. * @param {Array} codePoints The array of numeric code points.
  6807. * @returns {String} The new Unicode string (UCS-2).
  6808. */
  6809. function ucs2encode(array) {
  6810. return map(array, function(value) {
  6811. var output = '';
  6812. if (value > 0xFFFF) {
  6813. value -= 0x10000;
  6814. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  6815. value = 0xDC00 | value & 0x3FF;
  6816. }
  6817. output += stringFromCharCode(value);
  6818. return output;
  6819. }).join('');
  6820. }
  6821. /**
  6822. * Converts a basic code point into a digit/integer.
  6823. * @see `digitToBasic()`
  6824. * @private
  6825. * @param {Number} codePoint The basic numeric code point value.
  6826. * @returns {Number} The numeric value of a basic code point (for use in
  6827. * representing integers) in the range `0` to `base - 1`, or `base` if
  6828. * the code point does not represent a value.
  6829. */
  6830. function basicToDigit(codePoint) {
  6831. if (codePoint - 48 < 10) {
  6832. return codePoint - 22;
  6833. }
  6834. if (codePoint - 65 < 26) {
  6835. return codePoint - 65;
  6836. }
  6837. if (codePoint - 97 < 26) {
  6838. return codePoint - 97;
  6839. }
  6840. return base;
  6841. }
  6842. /**
  6843. * Converts a digit/integer into a basic code point.
  6844. * @see `basicToDigit()`
  6845. * @private
  6846. * @param {Number} digit The numeric value of a basic code point.
  6847. * @returns {Number} The basic code point whose value (when used for
  6848. * representing integers) is `digit`, which needs to be in the range
  6849. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  6850. * used; else, the lowercase form is used. The behavior is undefined
  6851. * if `flag` is non-zero and `digit` has no uppercase form.
  6852. */
  6853. function digitToBasic(digit, flag) {
  6854. // 0..25 map to ASCII a..z or A..Z
  6855. // 26..35 map to ASCII 0..9
  6856. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  6857. }
  6858. /**
  6859. * Bias adaptation function as per section 3.4 of RFC 3492.
  6860. * https://tools.ietf.org/html/rfc3492#section-3.4
  6861. * @private
  6862. */
  6863. function adapt(delta, numPoints, firstTime) {
  6864. var k = 0;
  6865. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6866. delta += floor(delta / numPoints);
  6867. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  6868. delta = floor(delta / baseMinusTMin);
  6869. }
  6870. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6871. }
  6872. /**
  6873. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  6874. * symbols.
  6875. * @memberOf punycode
  6876. * @param {String} input The Punycode string of ASCII-only symbols.
  6877. * @returns {String} The resulting string of Unicode symbols.
  6878. */
  6879. function decode(input) {
  6880. // Don't use UCS-2
  6881. var output = [],
  6882. inputLength = input.length,
  6883. out,
  6884. i = 0,
  6885. n = initialN,
  6886. bias = initialBias,
  6887. basic,
  6888. j,
  6889. index,
  6890. oldi,
  6891. w,
  6892. k,
  6893. digit,
  6894. t,
  6895. /** Cached calculation results */
  6896. baseMinusT;
  6897. // Handle the basic code points: let `basic` be the number of input code
  6898. // points before the last delimiter, or `0` if there is none, then copy
  6899. // the first basic code points to the output.
  6900. basic = input.lastIndexOf(delimiter);
  6901. if (basic < 0) {
  6902. basic = 0;
  6903. }
  6904. for (j = 0; j < basic; ++j) {
  6905. // if it's not a basic code point
  6906. if (input.charCodeAt(j) >= 0x80) {
  6907. error('not-basic');
  6908. }
  6909. output.push(input.charCodeAt(j));
  6910. }
  6911. // Main decoding loop: start just after the last delimiter if any basic code
  6912. // points were copied; start at the beginning otherwise.
  6913. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  6914. // `index` is the index of the next character to be consumed.
  6915. // Decode a generalized variable-length integer into `delta`,
  6916. // which gets added to `i`. The overflow checking is easier
  6917. // if we increase `i` as we go, then subtract off its starting
  6918. // value at the end to obtain `delta`.
  6919. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  6920. if (index >= inputLength) {
  6921. error('invalid-input');
  6922. }
  6923. digit = basicToDigit(input.charCodeAt(index++));
  6924. if (digit >= base || digit > floor((maxInt - i) / w)) {
  6925. error('overflow');
  6926. }
  6927. i += digit * w;
  6928. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6929. if (digit < t) {
  6930. break;
  6931. }
  6932. baseMinusT = base - t;
  6933. if (w > floor(maxInt / baseMinusT)) {
  6934. error('overflow');
  6935. }
  6936. w *= baseMinusT;
  6937. }
  6938. out = output.length + 1;
  6939. bias = adapt(i - oldi, out, oldi == 0);
  6940. // `i` was supposed to wrap around from `out` to `0`,
  6941. // incrementing `n` each time, so we'll fix that now:
  6942. if (floor(i / out) > maxInt - n) {
  6943. error('overflow');
  6944. }
  6945. n += floor(i / out);
  6946. i %= out;
  6947. // Insert `n` at position `i` of the output
  6948. output.splice(i++, 0, n);
  6949. }
  6950. return ucs2encode(output);
  6951. }
  6952. /**
  6953. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  6954. * Punycode string of ASCII-only symbols.
  6955. * @memberOf punycode
  6956. * @param {String} input The string of Unicode symbols.
  6957. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  6958. */
  6959. function encode(input) {
  6960. var n,
  6961. delta,
  6962. handledCPCount,
  6963. basicLength,
  6964. bias,
  6965. j,
  6966. m,
  6967. q,
  6968. k,
  6969. t,
  6970. currentValue,
  6971. output = [],
  6972. /** `inputLength` will hold the number of code points in `input`. */
  6973. inputLength,
  6974. /** Cached calculation results */
  6975. handledCPCountPlusOne,
  6976. baseMinusT,
  6977. qMinusT;
  6978. // Convert the input in UCS-2 to Unicode
  6979. input = ucs2decode(input);
  6980. // Cache the length
  6981. inputLength = input.length;
  6982. // Initialize the state
  6983. n = initialN;
  6984. delta = 0;
  6985. bias = initialBias;
  6986. // Handle the basic code points
  6987. for (j = 0; j < inputLength; ++j) {
  6988. currentValue = input[j];
  6989. if (currentValue < 0x80) {
  6990. output.push(stringFromCharCode(currentValue));
  6991. }
  6992. }
  6993. handledCPCount = basicLength = output.length;
  6994. // `handledCPCount` is the number of code points that have been handled;
  6995. // `basicLength` is the number of basic code points.
  6996. // Finish the basic string - if it is not empty - with a delimiter
  6997. if (basicLength) {
  6998. output.push(delimiter);
  6999. }
  7000. // Main encoding loop:
  7001. while (handledCPCount < inputLength) {
  7002. // All non-basic code points < n have been handled already. Find the next
  7003. // larger one:
  7004. for (m = maxInt, j = 0; j < inputLength; ++j) {
  7005. currentValue = input[j];
  7006. if (currentValue >= n && currentValue < m) {
  7007. m = currentValue;
  7008. }
  7009. }
  7010. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  7011. // but guard against overflow
  7012. handledCPCountPlusOne = handledCPCount + 1;
  7013. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  7014. error('overflow');
  7015. }
  7016. delta += (m - n) * handledCPCountPlusOne;
  7017. n = m;
  7018. for (j = 0; j < inputLength; ++j) {
  7019. currentValue = input[j];
  7020. if (currentValue < n && ++delta > maxInt) {
  7021. error('overflow');
  7022. }
  7023. if (currentValue == n) {
  7024. // Represent delta as a generalized variable-length integer
  7025. for (q = delta, k = base; /* no condition */; k += base) {
  7026. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  7027. if (q < t) {
  7028. break;
  7029. }
  7030. qMinusT = q - t;
  7031. baseMinusT = base - t;
  7032. output.push(
  7033. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  7034. );
  7035. q = floor(qMinusT / baseMinusT);
  7036. }
  7037. output.push(stringFromCharCode(digitToBasic(q, 0)));
  7038. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  7039. delta = 0;
  7040. ++handledCPCount;
  7041. }
  7042. }
  7043. ++delta;
  7044. ++n;
  7045. }
  7046. return output.join('');
  7047. }
  7048. /**
  7049. * Converts a Punycode string representing a domain name or an email address
  7050. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  7051. * it doesn't matter if you call it on a string that has already been
  7052. * converted to Unicode.
  7053. * @memberOf punycode
  7054. * @param {String} input The Punycoded domain name or email address to
  7055. * convert to Unicode.
  7056. * @returns {String} The Unicode representation of the given Punycode
  7057. * string.
  7058. */
  7059. function toUnicode(input) {
  7060. return mapDomain(input, function(string) {
  7061. return regexPunycode.test(string)
  7062. ? decode(string.slice(4).toLowerCase())
  7063. : string;
  7064. });
  7065. }
  7066. /**
  7067. * Converts a Unicode string representing a domain name or an email address to
  7068. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  7069. * i.e. it doesn't matter if you call it with a domain that's already in
  7070. * ASCII.
  7071. * @memberOf punycode
  7072. * @param {String} input The domain name or email address to convert, as a
  7073. * Unicode string.
  7074. * @returns {String} The Punycode representation of the given domain name or
  7075. * email address.
  7076. */
  7077. function toASCII(input) {
  7078. return mapDomain(input, function(string) {
  7079. return regexNonASCII.test(string)
  7080. ? 'xn--' + encode(string)
  7081. : string;
  7082. });
  7083. }
  7084. /*--------------------------------------------------------------------------*/
  7085. /** Define the public API */
  7086. punycode = {
  7087. /**
  7088. * A string representing the current Punycode.js version number.
  7089. * @memberOf punycode
  7090. * @type String
  7091. */
  7092. 'version': '1.4.1',
  7093. /**
  7094. * An object of methods to convert from JavaScript's internal character
  7095. * representation (UCS-2) to Unicode code points, and back.
  7096. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  7097. * @memberOf punycode
  7098. * @type Object
  7099. */
  7100. 'ucs2': {
  7101. 'decode': ucs2decode,
  7102. 'encode': ucs2encode
  7103. },
  7104. 'decode': decode,
  7105. 'encode': encode,
  7106. 'toASCII': toASCII,
  7107. 'toUnicode': toUnicode
  7108. };
  7109. /** Expose `punycode` */
  7110. // Some AMD build optimizers, like r.js, check for specific condition patterns
  7111. // like the following:
  7112. if (
  7113. typeof define == 'function' &&
  7114. typeof define.amd == 'object' &&
  7115. define.amd
  7116. ) {
  7117. define('punycode', function() {
  7118. return punycode;
  7119. });
  7120. } else if (freeExports && freeModule) {
  7121. if (module.exports == freeExports) {
  7122. // in Node.js, io.js, or RingoJS v0.8.0+
  7123. freeModule.exports = punycode;
  7124. } else {
  7125. // in Narwhal or RingoJS v0.7.0-
  7126. for (key in punycode) {
  7127. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  7128. }
  7129. }
  7130. } else {
  7131. // in Rhino or a web browser
  7132. root.punycode = punycode;
  7133. }
  7134. }(this));
  7135. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  7136. },{}],41:[function(require,module,exports){
  7137. // Copyright Joyent, Inc. and other Node contributors.
  7138. //
  7139. // Permission is hereby granted, free of charge, to any person obtaining a
  7140. // copy of this software and associated documentation files (the
  7141. // "Software"), to deal in the Software without restriction, including
  7142. // without limitation the rights to use, copy, modify, merge, publish,
  7143. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7144. // persons to whom the Software is furnished to do so, subject to the
  7145. // following conditions:
  7146. //
  7147. // The above copyright notice and this permission notice shall be included
  7148. // in all copies or substantial portions of the Software.
  7149. //
  7150. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7151. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7152. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7153. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7154. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7155. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7156. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7157. 'use strict';
  7158. // If obj.hasOwnProperty has been overridden, then calling
  7159. // obj.hasOwnProperty(prop) will break.
  7160. // See: https://github.com/joyent/node/issues/1707
  7161. function hasOwnProperty(obj, prop) {
  7162. return Object.prototype.hasOwnProperty.call(obj, prop);
  7163. }
  7164. module.exports = function(qs, sep, eq, options) {
  7165. sep = sep || '&';
  7166. eq = eq || '=';
  7167. var obj = {};
  7168. if (typeof qs !== 'string' || qs.length === 0) {
  7169. return obj;
  7170. }
  7171. var regexp = /\+/g;
  7172. qs = qs.split(sep);
  7173. var maxKeys = 1000;
  7174. if (options && typeof options.maxKeys === 'number') {
  7175. maxKeys = options.maxKeys;
  7176. }
  7177. var len = qs.length;
  7178. // maxKeys <= 0 means that we should not limit keys count
  7179. if (maxKeys > 0 && len > maxKeys) {
  7180. len = maxKeys;
  7181. }
  7182. for (var i = 0; i < len; ++i) {
  7183. var x = qs[i].replace(regexp, '%20'),
  7184. idx = x.indexOf(eq),
  7185. kstr, vstr, k, v;
  7186. if (idx >= 0) {
  7187. kstr = x.substr(0, idx);
  7188. vstr = x.substr(idx + 1);
  7189. } else {
  7190. kstr = x;
  7191. vstr = '';
  7192. }
  7193. k = decodeURIComponent(kstr);
  7194. v = decodeURIComponent(vstr);
  7195. if (!hasOwnProperty(obj, k)) {
  7196. obj[k] = v;
  7197. } else if (isArray(obj[k])) {
  7198. obj[k].push(v);
  7199. } else {
  7200. obj[k] = [obj[k], v];
  7201. }
  7202. }
  7203. return obj;
  7204. };
  7205. var isArray = Array.isArray || function (xs) {
  7206. return Object.prototype.toString.call(xs) === '[object Array]';
  7207. };
  7208. },{}],42:[function(require,module,exports){
  7209. // Copyright Joyent, Inc. and other Node contributors.
  7210. //
  7211. // Permission is hereby granted, free of charge, to any person obtaining a
  7212. // copy of this software and associated documentation files (the
  7213. // "Software"), to deal in the Software without restriction, including
  7214. // without limitation the rights to use, copy, modify, merge, publish,
  7215. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7216. // persons to whom the Software is furnished to do so, subject to the
  7217. // following conditions:
  7218. //
  7219. // The above copyright notice and this permission notice shall be included
  7220. // in all copies or substantial portions of the Software.
  7221. //
  7222. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7223. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7224. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7225. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7226. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7227. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7228. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7229. 'use strict';
  7230. var stringifyPrimitive = function(v) {
  7231. switch (typeof v) {
  7232. case 'string':
  7233. return v;
  7234. case 'boolean':
  7235. return v ? 'true' : 'false';
  7236. case 'number':
  7237. return isFinite(v) ? v : '';
  7238. default:
  7239. return '';
  7240. }
  7241. };
  7242. module.exports = function(obj, sep, eq, name) {
  7243. sep = sep || '&';
  7244. eq = eq || '=';
  7245. if (obj === null) {
  7246. obj = undefined;
  7247. }
  7248. if (typeof obj === 'object') {
  7249. return map(objectKeys(obj), function(k) {
  7250. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  7251. if (isArray(obj[k])) {
  7252. return map(obj[k], function(v) {
  7253. return ks + encodeURIComponent(stringifyPrimitive(v));
  7254. }).join(sep);
  7255. } else {
  7256. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  7257. }
  7258. }).join(sep);
  7259. }
  7260. if (!name) return '';
  7261. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  7262. encodeURIComponent(stringifyPrimitive(obj));
  7263. };
  7264. var isArray = Array.isArray || function (xs) {
  7265. return Object.prototype.toString.call(xs) === '[object Array]';
  7266. };
  7267. function map (xs, f) {
  7268. if (xs.map) return xs.map(f);
  7269. var res = [];
  7270. for (var i = 0; i < xs.length; i++) {
  7271. res.push(f(xs[i], i));
  7272. }
  7273. return res;
  7274. }
  7275. var objectKeys = Object.keys || function (obj) {
  7276. var res = [];
  7277. for (var key in obj) {
  7278. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  7279. }
  7280. return res;
  7281. };
  7282. },{}],43:[function(require,module,exports){
  7283. 'use strict';
  7284. exports.decode = exports.parse = require('./decode');
  7285. exports.encode = exports.stringify = require('./encode');
  7286. },{"./decode":41,"./encode":42}],44:[function(require,module,exports){
  7287. /**
  7288. sprintf() for JavaScript 0.7-beta1
  7289. http://www.diveintojavascript.com/projects/javascript-sprintf
  7290. Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
  7291. All rights reserved.
  7292. Redistribution and use in source and binary forms, with or without
  7293. modification, are permitted provided that the following conditions are met:
  7294. * Redistributions of source code must retain the above copyright
  7295. notice, this list of conditions and the following disclaimer.
  7296. * Redistributions in binary form must reproduce the above copyright
  7297. notice, this list of conditions and the following disclaimer in the
  7298. documentation and/or other materials provided with the distribution.
  7299. * Neither the name of sprintf() for JavaScript nor the
  7300. names of its contributors may be used to endorse or promote products
  7301. derived from this software without specific prior written permission.
  7302. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  7303. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7304. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  7305. DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
  7306. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7307. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7308. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7309. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7310. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7311. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7312. Changelog:
  7313. 2010.11.07 - 0.7-beta1-node
  7314. - converted it to a node.js compatible module
  7315. 2010.09.06 - 0.7-beta1
  7316. - features: vsprintf, support for named placeholders
  7317. - enhancements: format cache, reduced global namespace pollution
  7318. 2010.05.22 - 0.6:
  7319. - reverted to 0.4 and fixed the bug regarding the sign of the number 0
  7320. Note:
  7321. Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/)
  7322. who warned me about a bug in 0.5, I discovered that the last update was
  7323. a regress. I appologize for that.
  7324. 2010.05.09 - 0.5:
  7325. - bug fix: 0 is now preceeded with a + sign
  7326. - bug fix: the sign was not at the right position on padded results (Kamal Abdali)
  7327. - switched from GPL to BSD license
  7328. 2007.10.21 - 0.4:
  7329. - unit test and patch (David Baird)
  7330. 2007.09.17 - 0.3:
  7331. - bug fix: no longer throws exception on empty paramenters (Hans Pufal)
  7332. 2007.09.11 - 0.2:
  7333. - feature: added argument swapping
  7334. 2007.04.03 - 0.1:
  7335. - initial release
  7336. **/
  7337. var sprintf = (function() {
  7338. function get_type(variable) {
  7339. return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
  7340. }
  7341. function str_repeat(input, multiplier) {
  7342. for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
  7343. return output.join('');
  7344. }
  7345. var str_format = function() {
  7346. if (!str_format.cache.hasOwnProperty(arguments[0])) {
  7347. str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
  7348. }
  7349. return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
  7350. };
  7351. // convert object to simple one line string without indentation or
  7352. // newlines. Note that this implementation does not print array
  7353. // values to their actual place for sparse arrays.
  7354. //
  7355. // For example sparse array like this
  7356. // l = []
  7357. // l[4] = 1
  7358. // Would be printed as "[1]" instead of "[, , , , 1]"
  7359. //
  7360. // If argument 'seen' is not null and array the function will check for
  7361. // circular object references from argument.
  7362. str_format.object_stringify = function(obj, depth, maxdepth, seen) {
  7363. var str = '';
  7364. if (obj != null) {
  7365. switch( typeof(obj) ) {
  7366. case 'function':
  7367. return '[Function' + (obj.name ? ': '+obj.name : '') + ']';
  7368. break;
  7369. case 'object':
  7370. if ( obj instanceof Error) { return '[' + obj.toString() + ']' };
  7371. if (depth >= maxdepth) return '[Object]'
  7372. if (seen) {
  7373. // add object to seen list
  7374. seen = seen.slice(0)
  7375. seen.push(obj);
  7376. }
  7377. if (obj.length != null) { //array
  7378. str += '[';
  7379. var arr = []
  7380. for (var i in obj) {
  7381. if (seen && seen.indexOf(obj[i]) >= 0) arr.push('[Circular]');
  7382. else arr.push(str_format.object_stringify(obj[i], depth+1, maxdepth, seen));
  7383. }
  7384. str += arr.join(', ') + ']';
  7385. } else if ('getMonth' in obj) { // date
  7386. return 'Date(' + obj + ')';
  7387. } else { // object
  7388. str += '{';
  7389. var arr = []
  7390. for (var k in obj) {
  7391. if(obj.hasOwnProperty(k)) {
  7392. if (seen && seen.indexOf(obj[k]) >= 0) arr.push(k + ': [Circular]');
  7393. else arr.push(k +': ' +str_format.object_stringify(obj[k], depth+1, maxdepth, seen));
  7394. }
  7395. }
  7396. str += arr.join(', ') + '}';
  7397. }
  7398. return str;
  7399. break;
  7400. case 'string':
  7401. return '"' + obj + '"';
  7402. break
  7403. }
  7404. }
  7405. return '' + obj;
  7406. }
  7407. str_format.format = function(parse_tree, argv) {
  7408. var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
  7409. for (i = 0; i < tree_length; i++) {
  7410. node_type = get_type(parse_tree[i]);
  7411. if (node_type === 'string') {
  7412. output.push(parse_tree[i]);
  7413. }
  7414. else if (node_type === 'array') {
  7415. match = parse_tree[i]; // convenience purposes only
  7416. if (match[2]) { // keyword argument
  7417. arg = argv[cursor];
  7418. for (k = 0; k < match[2].length; k++) {
  7419. if (!arg.hasOwnProperty(match[2][k])) {
  7420. throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
  7421. }
  7422. arg = arg[match[2][k]];
  7423. }
  7424. }
  7425. else if (match[1]) { // positional argument (explicit)
  7426. arg = argv[match[1]];
  7427. }
  7428. else { // positional argument (implicit)
  7429. arg = argv[cursor++];
  7430. }
  7431. if (/[^sO]/.test(match[8]) && (get_type(arg) != 'number')) {
  7432. throw new Error(sprintf('[sprintf] expecting number but found %s "' + arg + '"', get_type(arg)));
  7433. }
  7434. switch (match[8]) {
  7435. case 'b': arg = arg.toString(2); break;
  7436. case 'c': arg = String.fromCharCode(arg); break;
  7437. case 'd': arg = parseInt(arg, 10); break;
  7438. case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
  7439. case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
  7440. case 'O': arg = str_format.object_stringify(arg, 0, parseInt(match[7]) || 5); break;
  7441. case 'o': arg = arg.toString(8); break;
  7442. case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
  7443. case 'u': arg = Math.abs(arg); break;
  7444. case 'x': arg = arg.toString(16); break;
  7445. case 'X': arg = arg.toString(16).toUpperCase(); break;
  7446. }
  7447. arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
  7448. pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
  7449. pad_length = match[6] - String(arg).length;
  7450. pad = match[6] ? str_repeat(pad_character, pad_length) : '';
  7451. output.push(match[5] ? arg + pad : pad + arg);
  7452. }
  7453. }
  7454. return output.join('');
  7455. };
  7456. str_format.cache = {};
  7457. str_format.parse = function(fmt) {
  7458. var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
  7459. while (_fmt) {
  7460. if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
  7461. parse_tree.push(match[0]);
  7462. }
  7463. else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
  7464. parse_tree.push('%');
  7465. }
  7466. else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(_fmt)) !== null) {
  7467. if (match[2]) {
  7468. arg_names |= 1;
  7469. var field_list = [], replacement_field = match[2], field_match = [];
  7470. if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  7471. field_list.push(field_match[1]);
  7472. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  7473. if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  7474. field_list.push(field_match[1]);
  7475. }
  7476. else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
  7477. field_list.push(field_match[1]);
  7478. }
  7479. else {
  7480. throw new Error('[sprintf] ' + replacement_field);
  7481. }
  7482. }
  7483. }
  7484. else {
  7485. throw new Error('[sprintf] ' + replacement_field);
  7486. }
  7487. match[2] = field_list;
  7488. }
  7489. else {
  7490. arg_names |= 2;
  7491. }
  7492. if (arg_names === 3) {
  7493. throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported');
  7494. }
  7495. parse_tree.push(match);
  7496. }
  7497. else {
  7498. throw new Error('[sprintf] ' + _fmt);
  7499. }
  7500. _fmt = _fmt.substring(match[0].length);
  7501. }
  7502. return parse_tree;
  7503. };
  7504. return str_format;
  7505. })();
  7506. var vsprintf = function(fmt, argv) {
  7507. var argvClone = argv.slice();
  7508. argvClone.unshift(fmt);
  7509. return sprintf.apply(null, argvClone);
  7510. };
  7511. module.exports = sprintf;
  7512. sprintf.sprintf = sprintf;
  7513. sprintf.vsprintf = vsprintf;
  7514. },{}],45:[function(require,module,exports){
  7515. "use strict";
  7516. var allRules = require('./rules.json');
  7517. var cleanHostValue = require('./lib/clean-host.js');
  7518. var escapeRegExp = require('./lib/escape-regexp.js');
  7519. var getRulesForTld = require('./lib/tld-rules.js');
  7520. var getDomain = require('./lib/domain.js');
  7521. var getSubdomain = require('./lib/subdomain.js');
  7522. var isValid = require('./lib/is-valid.js');
  7523. var getPublicSuffix = require('./lib/public-suffix.js');
  7524. var tldExists = require('./lib/tld-exists.js');
  7525. /**
  7526. * Creates a new instance of tldjs
  7527. * @param {Object.<rules,validHosts>} options [description]
  7528. * @return {tldjs|Object} [description]
  7529. */
  7530. function factory(options) {
  7531. var rules = options.rules || allRules || {};
  7532. var validHosts = options.validHosts || [];
  7533. return {
  7534. cleanHostValue: cleanHostValue,
  7535. escapeRegExp: escapeRegExp,
  7536. getRulesForTld: getRulesForTld,
  7537. getDomain: function (host) {
  7538. return getDomain(rules, validHosts, host);
  7539. },
  7540. getSubdomain: function (host) {
  7541. return getSubdomain(rules, validHosts, host);
  7542. },
  7543. isValid: function (host) {
  7544. return isValid(validHosts, host);
  7545. },
  7546. getPublicSuffix: function (host) {
  7547. return getPublicSuffix(rules, host);
  7548. },
  7549. tldExists: function (tld) {
  7550. return tldExists(rules, tld);
  7551. },
  7552. fromUserSettings: factory
  7553. };
  7554. }
  7555. module.exports = factory({ validHosts: [], rules: allRules });
  7556. },{"./lib/clean-host.js":47,"./lib/domain.js":48,"./lib/escape-regexp.js":49,"./lib/is-valid.js":51,"./lib/public-suffix.js":54,"./lib/subdomain.js":56,"./lib/tld-exists.js":57,"./lib/tld-rules.js":58,"./rules.json":59}],46:[function(require,module,exports){
  7557. var some = require('./polyfills/array-some.js');
  7558. /**
  7559. * Returns the best rule for a given host based on candidates
  7560. *
  7561. * @static
  7562. * @param host {String} Hostname to check rules against
  7563. * @param rules {Array} List of rules used to work on
  7564. * @return {Object} Candidate object, with a normal and exception state
  7565. */
  7566. module.exports = function getCandidateRule (host, rules, options) {
  7567. var rule = {'normal': null, 'exception': null};
  7568. options = options || { lazy: false };
  7569. some(rules, function (r) {
  7570. var pattern;
  7571. // sld matching or validHost? escape the loop immediately (except if it's an exception)
  7572. if ('.' + host === r.getNormalXld()) {
  7573. if (options.lazy || r.exception || r.isHost) {
  7574. rule.normal = r;
  7575. }
  7576. return true;
  7577. }
  7578. // otherwise check as a complete host
  7579. // if it's an exception, we want to loop a bit more to a normal rule
  7580. pattern = '.+' + r.getNormalPattern() + '$';
  7581. if ((new RegExp(pattern)).test(host)) {
  7582. rule[r.exception ? 'exception' : 'normal'] = r;
  7583. return !r.exception;
  7584. }
  7585. return false;
  7586. });
  7587. // favouring the exception if encountered
  7588. // previously we were copy-altering a rule, creating inconsistent results based on rule order order
  7589. // @see https://github.com/oncletom/tld.js/pull/35
  7590. if (rule.normal && rule.exception) {
  7591. return rule.exception;
  7592. }
  7593. return rule.normal;
  7594. };
  7595. },{"./polyfills/array-some.js":53}],47:[function(require,module,exports){
  7596. var URL = require('url');
  7597. /**
  7598. * Utility to cleanup the base host value. Also removes url fragments.
  7599. *
  7600. * Works for:
  7601. * - hostname
  7602. * - //hostname
  7603. * - scheme://hostname
  7604. * - scheme+scheme://hostname
  7605. *
  7606. * @param {string} value
  7607. * @return {String}
  7608. */
  7609. // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  7610. var hasPrefixRE = /^(([a-z][a-z0-9+.-]*)?:)?\/\//;
  7611. var invalidHostnameChars = /[^A-Za-z0-9.-]/;
  7612. //@see https://github.com/oncletom/tld.js/issues/95
  7613. function rtrim(value) {
  7614. return String(value).replace(/[.]+$/g, '');
  7615. }
  7616. module.exports = function cleanHostValue(value){
  7617. value = String(value).trim().toLowerCase();
  7618. var parts = URL.parse(hasPrefixRE.test(value) ? value : '//' + value, null, true);
  7619. if (parts.hostname && !invalidHostnameChars.test(parts.hostname)) { return rtrim(parts.hostname); }
  7620. if (!invalidHostnameChars.test(value)) { return rtrim(value); }
  7621. return '';
  7622. };
  7623. },{"url":60}],48:[function(require,module,exports){
  7624. var Rule = require('./rule.js');
  7625. var isValid = require('./is-valid.js');
  7626. var cleanHostValue = require('./clean-host.js');
  7627. var extractTldFromHost = require('./from-host.js');
  7628. var getCandidateRule = require('./canditate-rule.js');
  7629. var getRulesForTld = require('./tld-rules.js');
  7630. /**
  7631. * Detects the domain based on rules and upon and a host string
  7632. *
  7633. * @api
  7634. * @param {string} host
  7635. * @return {String}
  7636. */
  7637. module.exports = function getDomain (allRules, validHosts, host) {
  7638. var domain = null, hostTld, rules, rule;
  7639. var _validHosts = validHosts || [];
  7640. if (isValid(_validHosts, host) === false) {
  7641. return null;
  7642. }
  7643. host = cleanHostValue(host);
  7644. hostTld = extractTldFromHost(host);
  7645. rules = getRulesForTld(allRules, hostTld, new Rule({"firstLevel": hostTld, "isHost": _validHosts.indexOf(hostTld) !== -1}));
  7646. rule = getCandidateRule(host, rules);
  7647. if (rule === null) {
  7648. return null;
  7649. }
  7650. host.replace(new RegExp(rule.getPattern()), function (m, d) {
  7651. domain = d;
  7652. });
  7653. return domain;
  7654. };
  7655. },{"./canditate-rule.js":46,"./clean-host.js":47,"./from-host.js":50,"./is-valid.js":51,"./rule.js":55,"./tld-rules.js":58}],49:[function(require,module,exports){
  7656. /**
  7657. * Escapes RegExp specific chars.
  7658. *
  7659. * @since 1.3.1
  7660. * @see https://github.com/oncletom/tld.js/pull/33
  7661. * @param {String|Mixed} s
  7662. * @returns {string} Escaped string for a safe use in a `new RegExp` expression
  7663. */
  7664. module.exports = function escapeRegExp(s) {
  7665. return String(s).replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
  7666. };
  7667. },{}],50:[function(require,module,exports){
  7668. /**
  7669. * Utility to extract the TLD from a host string
  7670. *
  7671. * @param {string} host
  7672. * @return {String}
  7673. */
  7674. module.exports = function extractTldFromHost(host){
  7675. return host.split('.').pop();
  7676. };
  7677. },{}],51:[function(require,module,exports){
  7678. /**
  7679. * Checking if a host string is valid
  7680. * It's usually a preliminary check before trying to use getDomain or anything else
  7681. *
  7682. * Beware: it does not check if the TLD exists.
  7683. *
  7684. * @api
  7685. * @param host {String}
  7686. * @return {Boolean}
  7687. */
  7688. module.exports = function isValid (validHosts, host) {
  7689. return typeof host === 'string' && (validHosts.indexOf(host) !== -1 || (host.indexOf('.') !== -1 && host[0] !== '.'));
  7690. };
  7691. },{}],52:[function(require,module,exports){
  7692. // Array.map polyfill for IE8
  7693. module.exports = function _mapFunction(thisVal, fun /*, thisArg */) {
  7694. "use strict";
  7695. if (thisVal === void 0 || thisVal === null) {
  7696. throw new TypeError();
  7697. }
  7698. var t = Object(thisVal);
  7699. var len = t.length >>> 0;
  7700. if (typeof fun !== "function") {
  7701. throw new TypeError();
  7702. }
  7703. var res = new Array(len);
  7704. var thisArg = arguments.length >= 3 ? arguments[2] : void 0;
  7705. for (var i = 0; i < len; i++)
  7706. {
  7707. // NOTE: Absolute correctness would demand Object.defineProperty
  7708. // be used. But this method is fairly new, and failure is
  7709. // possible only if Object.prototype or Array.prototype
  7710. // has a property |i| (very unlikely), so use a lesscorrect
  7711. // but more portable alternative.
  7712. if (i in t) {
  7713. res[i] = fun.call(thisArg, t[i], i, t);
  7714. }
  7715. }
  7716. return res;
  7717. };
  7718. },{}],53:[function(require,module,exports){
  7719. // Array.some() polyfill for IE8
  7720. module.exports = function _someFunction(value, fun /*, thisArg */) {
  7721. 'use strict';
  7722. if (value === void 0 || value === null) {
  7723. throw new TypeError();
  7724. }
  7725. var t = Object(value);
  7726. var len = t.length >>> 0;
  7727. if (typeof fun !== 'function') {
  7728. throw new TypeError();
  7729. }
  7730. var thisArg = arguments.length >= 3 ? arguments[2] : void 0;
  7731. for (var i = 0; i < len; i++)
  7732. {
  7733. if (i in t && fun.call(thisArg, t[i], i, t)) {
  7734. return true;
  7735. }
  7736. }
  7737. return false;
  7738. };
  7739. },{}],54:[function(require,module,exports){
  7740. var cleanHostValue = require('./clean-host.js');
  7741. var extractTldFromHost = require('./from-host.js');
  7742. var getCandidateRule = require('./canditate-rule.js');
  7743. var getRulesForTld = require('./tld-rules.js');
  7744. /**
  7745. * Returns the public suffix (including exact matches)
  7746. *
  7747. * @api
  7748. * @since 1.5
  7749. * @param {string} host
  7750. * @return {String}
  7751. */
  7752. module.exports = function getPublicSuffix(allRules, host) {
  7753. var hostTld, rules, rule;
  7754. if (host in allRules){
  7755. return host;
  7756. }
  7757. host = cleanHostValue(host);
  7758. hostTld = extractTldFromHost(host);
  7759. rules = getRulesForTld(allRules, hostTld);
  7760. rule = getCandidateRule(host, rules, { lazy: true });
  7761. if (rule === null) {
  7762. return null;
  7763. }
  7764. return rule.getNormalXld().slice(1);
  7765. };
  7766. },{"./canditate-rule.js":46,"./clean-host.js":47,"./from-host.js":50,"./tld-rules.js":58}],55:[function(require,module,exports){
  7767. "use strict";
  7768. function Rule (data){
  7769. data = data || {};
  7770. this.exception = data.exception || false;
  7771. this.firstLevel = data.firstLevel || '';
  7772. this.secondLevel = data.secondLevel || null;
  7773. this.isHost = data.isHost || false;
  7774. this.source = data.source || '';
  7775. this.wildcard = data.wildcard || false;
  7776. }
  7777. /**
  7778. * Returns the TLD or SLD (Second Level Domain) pattern for a rule
  7779. *
  7780. * @return {String}
  7781. */
  7782. Rule.prototype.getNormalXld = function getNormalXld(){
  7783. return (this.secondLevel ? '.' + this.secondLevel : '') + '.' + this.firstLevel;
  7784. };
  7785. /**
  7786. * Returns a pattern suitable for normal rule
  7787. * Mostly for internal use
  7788. *
  7789. * @return {String}
  7790. */
  7791. Rule.prototype.getNormalPattern = function getNormalPattern(){
  7792. return (this.secondLevel ? '\\.' + this.secondLevel : '') + '\\.' + this.firstLevel;
  7793. };
  7794. /**
  7795. * Returns a pattern suitable for wildcard rule
  7796. * Mostly for internal use
  7797. *
  7798. * @return {String}
  7799. */
  7800. Rule.prototype.getWildcardPattern = function getWildcardPattern(){
  7801. return '\\.[^\\.]+' + this.getNormalXld().replace(/\./g, '\\.');
  7802. };
  7803. /**
  7804. * Returns a pattern suitable for exception rule
  7805. * Mostly for internal use
  7806. *
  7807. * @return {String}
  7808. */
  7809. Rule.prototype.getExceptionPattern = function getExceptionPattern(){
  7810. return (this.secondLevel || '') + '\\.' + this.firstLevel;
  7811. };
  7812. /**
  7813. * Returns the best pattern possible for a rule
  7814. * You just have to test a value against it to check or extract a hostname
  7815. *
  7816. * @api
  7817. * @param {string|undefined} before
  7818. * @param {string|undefined} after
  7819. * @return {String} A pattern to challenge some string against
  7820. */
  7821. Rule.prototype.getPattern = function getPattern(before, after){
  7822. var pattern = '';
  7823. before = (before === undefined) ? '(': before+'';
  7824. after = (after === undefined) ? ')$': after+'';
  7825. if (this.exception === true){
  7826. pattern = this.getExceptionPattern();
  7827. }
  7828. else if (this.isHost === true) {
  7829. pattern = this.firstLevel;
  7830. }
  7831. else{
  7832. pattern = '[^\\.]+' + (this.wildcard ? this.getWildcardPattern() : this.getNormalPattern());
  7833. }
  7834. return before + pattern + after;
  7835. };
  7836. module.exports = Rule;
  7837. },{}],56:[function(require,module,exports){
  7838. var cleanHostValue = require('./clean-host.js');
  7839. var getDomain = require('./domain.js');
  7840. var escapeRegExp = require('./escape-regexp.js');
  7841. /**
  7842. * Returns the subdomain of a host string
  7843. *
  7844. * @api
  7845. * @param {string} host
  7846. * @return {string|null} a subdomain string if any, blank string if subdomain is empty, otherwise null
  7847. */
  7848. module.exports = function getSubdomain(allRules, validHosts, host){
  7849. var domain, r, subdomain;
  7850. host = cleanHostValue(host);
  7851. domain = getDomain(allRules, validHosts, host);
  7852. // No domain found? Just abort, abort!
  7853. if (domain === null){
  7854. return null;
  7855. }
  7856. r = '\\.?'+ escapeRegExp(domain)+'$';
  7857. subdomain = host.replace(new RegExp(r, 'i'), '');
  7858. return subdomain;
  7859. };
  7860. },{"./clean-host.js":47,"./domain.js":48,"./escape-regexp.js":49}],57:[function(require,module,exports){
  7861. var cleanHostValue = require('./clean-host.js');
  7862. var extractTldFromHost = require('./from-host.js');
  7863. /**
  7864. * Checks if the TLD exists for a given host
  7865. *
  7866. * @api
  7867. * @param {string} host
  7868. * @return {boolean}
  7869. */
  7870. module.exports = function tldExists(rules, host){
  7871. var hostTld;
  7872. host = cleanHostValue(host);
  7873. // Easy case, it's a TLD
  7874. if (rules[host]){
  7875. return true;
  7876. }
  7877. // Popping only the TLD of the hostname
  7878. hostTld = extractTldFromHost(host);
  7879. return rules[hostTld] !== undefined;
  7880. };
  7881. },{"./clean-host.js":47,"./from-host.js":50}],58:[function(require,module,exports){
  7882. "use strict";
  7883. var Rule = require('./rule.js');
  7884. var map = require('./polyfills/array-map.js');
  7885. /**
  7886. * Retrieve a subset of rules for a Top-Level-Domain string
  7887. *
  7888. * @param tld {String} Top-Level-Domain string
  7889. * @return {Array} Rules subset
  7890. */
  7891. module.exports = function getRulesForTld (allRules, tld, default_rule) {
  7892. var exception = '!';
  7893. var wildcard = '*';
  7894. var append_tld_rule = true;
  7895. var rules = allRules[tld];
  7896. // Already parsed
  7897. // Array.isArray polyfill for IE8
  7898. if (Object.prototype.toString.call(rules) === '[object Array]') {
  7899. return rules;
  7900. }
  7901. // Nothing found, apply some default value
  7902. if (rules === void 0) {
  7903. return default_rule ? [ default_rule ] : [];
  7904. }
  7905. // Parsing needed
  7906. rules = map(rules.split('|'), function transformAsRule (sld) {
  7907. var first_bit = sld[0];
  7908. if (first_bit === exception || first_bit === wildcard) {
  7909. sld = sld.slice(1);
  7910. if (!sld) {
  7911. append_tld_rule = false;
  7912. }
  7913. }
  7914. return new Rule({
  7915. "firstLevel": tld,
  7916. "secondLevel": sld,
  7917. "exception": first_bit === exception,
  7918. "wildcard": first_bit === wildcard
  7919. });
  7920. });
  7921. // Always prepend to make it the latest rule to be applied
  7922. if (append_tld_rule) {
  7923. rules.unshift(new Rule({
  7924. "firstLevel": tld
  7925. }));
  7926. }
  7927. allRules[tld] = rules.reverse();
  7928. return rules;
  7929. };
  7930. },{"./polyfills/array-map.js":52,"./rule.js":55}],59:[function(require,module,exports){
  7931. module.exports={"ac":"com|edu|gov|net|mil|org","ad":"nom","ae":"co|net|org|sch|ac|gov|mil|blogspot|nom","aero":"accident-investigation|accident-prevention|aerobatic|aeroclub|aerodrome|agents|aircraft|airline|airport|air-surveillance|airtraffic|air-traffic-control|ambulance|amusement|association|author|ballooning|broker|caa|cargo|catering|certification|championship|charter|civilaviation|club|conference|consultant|consulting|control|council|crew|design|dgca|educator|emergency|engine|engineer|entertainment|equipment|exchange|express|federation|flight|freight|fuel|gliding|government|groundhandling|group|hanggliding|homebuilt|insurance|journal|journalist|leasing|logistics|magazine|maintenance|media|microlight|modelling|navigation|parachuting|paragliding|passenger-association|pilot|press|production|recreation|repbody|res|research|rotorcraft|safety|scientist|services|show|skydiving|software|student|trader|trading|trainer|union|workinggroup|works","af":"gov|com|org|net|edu","ag":"com|org|net|co|nom","ai":"off|com|net|org|nom","al":"com|edu|gov|mil|net|org|blogspot|nom","am":"blogspot","ao":"ed|gv|og|co|pb|it","aq":"","ar":"com|edu|gob|gov|int|mil|musica|net|org|tur|blogspot.com","arpa":"e164|in-addr|ip6|iris|uri|urn","as":"gov","asia":"cloudns","at":"ac|co|gv|or|futurehosting|futuremailing|*ex.ortsinfo|*kunden.ortsinfo|blogspot.co|biz|info|priv|12hp|2ix|4lima|lima-city","au":"com|net|org|edu|gov|asn|id|info|conf|oz|act|nsw|nt|qld|sa|tas|vic|wa|act.edu|nsw.edu|nt.edu|qld.edu|sa.edu|tas.edu|vic.edu|wa.edu|qld.gov|sa.gov|tas.gov|vic.gov|wa.gov|blogspot.com","aw":"com","ax":"","az":"com|net|int|gov|org|edu|info|pp|mil|name|pro|biz","ba":"com|edu|gov|mil|net|org|blogspot","bb":"biz|co|com|edu|gov|info|net|org|store|tv","bd":"*","be":"ac|blogspot|*transurl","bf":"gov","bg":"a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|blogspot|barsy","bh":"com|edu|net|org|gov","bi":"co|com|edu|or|org","biz":"cloudns|dyndns|for-better|for-more|for-some|for-the|selfip|webhop|mmafan|myftp|no-ip|dscloud","bj":"asso|barreau|gouv|blogspot","bm":"com|edu|gov|net|org","bn":"*","bo":"com|edu|gov|gob|int|org|net|mil|tv","br":"adm|adv|agr|am|arq|art|ato|b|belem|bio|blog|bmd|cim|cng|cnt|com|coop|cri|def|ecn|eco|edu|emp|eng|esp|etc|eti|far|flog|floripa|fm|fnd|fot|fst|g12|ggf|gov|ac.gov|al.gov|am.gov|ap.gov|ba.gov|ce.gov|df.gov|es.gov|go.gov|ma.gov|mg.gov|ms.gov|mt.gov|pa.gov|pb.gov|pe.gov|pi.gov|pr.gov|rj.gov|rn.gov|ro.gov|rr.gov|rs.gov|sc.gov|se.gov|sp.gov|to.gov|imb|ind|inf|jampa|jor|jus|leg|lel|mat|med|mil|mp|mus|net|*nom|not|ntr|odo|org|poa|ppg|pro|psc|psi|qsl|radio|rec|recife|slg|srv|taxi|teo|tmp|trd|tur|tv|vet|vix|vlog|wiki|zlg|blogspot.com|ac.leg|al.leg|am.leg|ap.leg|ba.leg|ce.leg|df.leg|es.leg|go.leg|ma.leg|mg.leg|ms.leg|mt.leg|pa.leg|pb.leg|pe.leg|pi.leg|pr.leg|rj.leg|rn.leg|ro.leg|rr.leg|rs.leg|sc.leg|se.leg|sp.leg|to.leg","bs":"com|net|org|edu|gov|we","bt":"com|edu|gov|net|org","bv":"","bw":"co|org","by":"gov|mil|com|of|blogspot.com|nym","bz":"com|net|org|edu|gov|za|nym","ca":"ab|bc|mb|nb|nf|nl|ns|nt|nu|on|pe|qc|sk|yk|gc|*awdev|co|blogspot|no-ip","cat":"","cc":"cloudns|ftpaccess|game-server|myphotos|scrapping|twmail|fantasyleague","cd":"gov","cf":"blogspot","cg":"","ch":"square7|blogspot|gotdns|12hp|2ix|4lima|lima-city","ci":"org|or|com|co|edu|ed|ac|net|go|asso|xn--aroport-bya|int|presse|md|gouv","ck":"*|!www","cl":"gov|gob|co|mil|blogspot|nom","cm":"co|com|gov|net","cn":"ac|com|edu|gov|net|org|mil|xn--55qx5d|xn--io0a7i|xn--od0alg|ah|bj|cq|fj|gd|gs|gz|gx|ha|hb|he|hi|hl|hn|jl|js|jx|ln|nm|nx|qh|sc|sd|sh|sn|sx|tj|xj|xz|yn|zj|hk|mo|tw|*compute.amazonaws.com|elasticbeanstalk.cn-north-1.amazonaws.com|*elb.amazonaws.com|s3.cn-north-1.amazonaws.com","co":"arts|com|edu|firm|gov|info|int|mil|net|nom|org|rec|web|blogspot.com|nodum","com":"*compute.amazonaws|*compute-1.amazonaws|us-east-1.amazonaws|*elasticbeanstalk|*elb.amazonaws|s3.amazonaws|s3-ap-northeast-1.amazonaws|s3-ap-northeast-2.amazonaws|s3-ap-south-1.amazonaws|s3-ap-southeast-1.amazonaws|s3-ap-southeast-2.amazonaws|s3-ca-central-1.amazonaws|s3-eu-central-1.amazonaws|s3-eu-west-1.amazonaws|s3-eu-west-2.amazonaws|s3-external-1.amazonaws|s3-fips-us-gov-west-1.amazonaws|s3-sa-east-1.amazonaws|s3-us-gov-west-1.amazonaws|s3-us-east-2.amazonaws|s3-us-west-1.amazonaws|s3-us-west-2.amazonaws|s3.ap-northeast-2.amazonaws|s3.ap-south-1.amazonaws|s3.ca-central-1.amazonaws|s3.eu-central-1.amazonaws|s3.eu-west-2.amazonaws|s3.us-east-2.amazonaws|s3.dualstack.ap-northeast-1.amazonaws|s3.dualstack.ap-northeast-2.amazonaws|s3.dualstack.ap-south-1.amazonaws|s3.dualstack.ap-southeast-1.amazonaws|s3.dualstack.ap-southeast-2.amazonaws|s3.dualstack.ca-central-1.amazonaws|s3.dualstack.eu-central-1.amazonaws|s3.dualstack.eu-west-1.amazonaws|s3.dualstack.eu-west-2.amazonaws|s3.dualstack.sa-east-1.amazonaws|s3.dualstack.us-east-1.amazonaws|s3.dualstack.us-east-2.amazonaws|s3-website-us-east-1.amazonaws|s3-website-us-west-1.amazonaws|s3-website-us-west-2.amazonaws|s3-website-ap-northeast-1.amazonaws|s3-website-ap-southeast-1.amazonaws|s3-website-ap-southeast-2.amazonaws|s3-website-eu-west-1.amazonaws|s3-website-sa-east-1.amazonaws|s3-website.ap-northeast-2.amazonaws|s3-website.ap-south-1.amazonaws|s3-website.ca-central-1.amazonaws|s3-website.eu-central-1.amazonaws|s3-website.eu-west-2.amazonaws|s3-website.us-east-2.amazonaws|on-aptible|myasustor|betainabox|bplaced|ar|br|cn|de|eu|gb|hu|jpn|kr|mex|no|qc|ru|sa|se|uk|us|uy|za|africa|gr|co|xenapponazure|jdevcloud|wpdevcloud|cloudcontrolled|cloudcontrolapp|drayddns|dreamhosters|mydrobo|dyndns-at-home|dyndns-at-work|dyndns-blog|dyndns-free|dyndns-home|dyndns-ip|dyndns-mail|dyndns-office|dyndns-pics|dyndns-remote|dyndns-server|dyndns-web|dyndns-wiki|dyndns-work|blogdns|cechire|dnsalias|dnsdojo|doesntexist|dontexist|doomdns|dyn-o-saur|dynalias|est-a-la-maison|est-a-la-masion|est-le-patron|est-mon-blogueur|from-ak|from-al|from-ar|from-ca|from-ct|from-dc|from-de|from-fl|from-ga|from-hi|from-ia|from-id|from-il|from-in|from-ks|from-ky|from-ma|from-md|from-mi|from-mn|from-mo|from-ms|from-mt|from-nc|from-nd|from-ne|from-nh|from-nj|from-nm|from-nv|from-oh|from-ok|from-or|from-pa|from-pr|from-ri|from-sc|from-sd|from-tn|from-tx|from-ut|from-va|from-vt|from-wa|from-wi|from-wv|from-wy|getmyip|gotdns|hobby-site|homelinux|homeunix|iamallama|is-a-anarchist|is-a-blogger|is-a-bookkeeper|is-a-bulls-fan|is-a-caterer|is-a-chef|is-a-conservative|is-a-cpa|is-a-cubicle-slave|is-a-democrat|is-a-designer|is-a-doctor|is-a-financialadvisor|is-a-geek|is-a-green|is-a-guru|is-a-hard-worker|is-a-hunter|is-a-landscaper|is-a-lawyer|is-a-liberal|is-a-libertarian|is-a-llama|is-a-musician|is-a-nascarfan|is-a-nurse|is-a-painter|is-a-personaltrainer|is-a-photographer|is-a-player|is-a-republican|is-a-rockstar|is-a-socialist|is-a-student|is-a-teacher|is-a-techie|is-a-therapist|is-an-accountant|is-an-actor|is-an-actress|is-an-anarchist|is-an-artist|is-an-engineer|is-an-entertainer|is-certified|is-gone|is-into-anime|is-into-cars|is-into-cartoons|is-into-games|is-leet|is-not-certified|is-slick|is-uberleet|is-with-theband|isa-geek|isa-hockeynut|issmarterthanyou|likes-pie|likescandy|neat-url|saves-the-whales|selfip|sells-for-less|sells-for-u|servebbs|simple-url|space-to-rent|teaches-yoga|writesthisblog|ddnsfree|ddnsgeek|giize|gleeze|kozow|loseyourip|ooguy|theworkpc|mytuleap|eu-1.evennode|eu-2.evennode|eu-3.evennode|eu-4.evennode|us-1.evennode|us-2.evennode|us-3.evennode|us-4.evennode|apps.fbsbx|firebaseapp|flynnhub|freebox-os|freeboxos|githubusercontent|*0emm|appspot|blogspot|codespot|googleapis|googlecode|pagespeedmobilizer|publishproxy|withgoogle|withyoutube|herokuapp|herokussl|*cns.joyent|barsyonline|meteorapp|eu.meteorapp|bitballoon|netlify|4u|nfshost|blogsyte|ciscofreak|damnserver|ditchyourip|dnsiskinky|dynns|geekgalaxy|health-carereform|homesecuritymac|homesecuritypc|myactivedirectory|mysecuritycamera|net-freaks|onthewifi|point2this|quicksytes|securitytactics|serveexchange|servehumour|servep2p|servesarcasm|stufftoread|unusualperson|workisboring|3utilities|ddnsking|myvnc|servebeer|servecounterstrike|serveftp|servegame|servehalflife|servehttp|serveirc|servemp3|servepics|servequake|operaunite|outsystemscloud|ownprovider|pgfog|pagefrontapp|gotpantheon|xen.prgmr|qa2|dev-myqnapcloud|alpha-myqnapcloud|myqnapcloud|*quipelements|rackmaze|rhcloud|logoip|firewall-gateway|myshopblocks|1kapp|appchizi|applinzi|sinaapp|vipsinaapp|bounty-full|alpha.bounty-full|beta.bounty-full|temp-dns|dsmynas|familyds|bloxcms|townnews-staging|hk|remotewd|yolasite","coop":"","cr":"ac|co|ed|fi|go|or|sa","cu":"com|edu|org|net|gov|inf","cv":"blogspot","cw":"com|edu|net|org","cx":"gov|ath|info","cy":"ac|biz|com|ekloges|gov|ltd|name|net|org|parliament|press|pro|tm|blogspot.com","cz":"co|realm|e4|blogspot|cloud.metacentrum|custom.metacentrum","de":"bplaced|square7|com|dyn.cosidns|dynamisches-dns|dnsupdater|internet-dns|l-o-g-i-n|dnshome|fuettertdasnetz|isteingeek|istmein|lebtimnetz|leitungsen|traeumtgerade|ddnss|dyn.ddnss|dyndns.ddnss|dyndns1|dyn-ip24|home-webserver|dyn.home-webserver|myhome-server|goip|blogspot|keymachine|git-repos|lcube-server|svn-repos|barsy|logoip|firewall-gateway|my-gateway|my-router|spdns|taifun-dns|12hp|2ix|4lima|lima-city|dd-dns|dray-dns|draydns|dyn-vpn|dynvpn|mein-vigor|my-vigor|my-wan|syno-ds|synology-diskstation|synology-ds","dj":"","dk":"biz|co|firm|reg|store|blogspot","dm":"com|net|org|edu|gov","do":"art|com|edu|gob|gov|mil|net|org|sld|web","dz":"com|org|net|gov|edu|asso|pol|art","ec":"com|info|net|fin|k12|med|pro|org|edu|gov|gob|mil","edu":"","ee":"edu|gov|riik|lib|med|com|pri|aip|org|fie|blogspot.com","eg":"com|edu|eun|gov|mil|name|net|org|sci|blogspot.com","er":"*","es":"com|nom|org|gob|edu|blogspot.com","et":"com|gov|org|edu|biz|name|info|net","eu":"mycd|cloudns|barsy|wellbeingzone|spdns|*transurl|diskstation","fi":"aland|dy|blogspot|iki","fj":"*","fk":"*","fm":"","fo":"","fr":"com|asso|nom|prd|presse|tm|aeroport|assedic|avocat|avoues|cci|chambagri|chirurgiens-dentistes|experts-comptables|geometre-expert|gouv|greta|huissier-justice|medecin|notaires|pharmacien|port|veterinaire|fbx-os|fbxos|freebox-os|freeboxos|blogspot|on-web|chirurgiens-dentistes-en-france","ga":"","gb":"","gd":"nom","ge":"com|edu|gov|org|mil|net|pvt","gf":"","gg":"co|net|org|cya","gh":"com|edu|gov|org|mil","gi":"com|ltd|gov|mod|edu|org","gl":"co|com|edu|net|org|nom","gm":"","gn":"ac|com|edu|gov|org|net","gov":"","gp":"com|net|mobi|edu|org|asso","gq":"","gr":"com|edu|net|org|gov|blogspot|nym","gs":"","gt":"com|edu|gob|ind|mil|net|org|nom","gu":"*","gw":"","gy":"co|com|edu|gov|net|org","hk":"com|edu|gov|idv|net|org|xn--55qx5d|xn--wcvs22d|xn--lcvr32d|xn--mxtq1m|xn--gmqw5a|xn--ciqpn|xn--gmq050i|xn--zf0avx|xn--io0a7i|xn--mk0axi|xn--od0alg|xn--od0aq3b|xn--tn0ag|xn--uc0atv|xn--uc0ay4a|blogspot|ltd|inc","hm":"","hn":"com|edu|org|net|mil|gob|nom","hr":"iz|from|name|com|blogspot","ht":"com|shop|firm|info|adult|net|pro|org|med|art|coop|pol|asso|edu|rel|gouv|perso","hu":"co|info|org|priv|sport|tm|2000|agrar|bolt|casino|city|erotica|erotika|film|forum|games|hotel|ingatlan|jogasz|konyvelo|lakas|media|news|reklam|sex|shop|suli|szex|tozsde|utazas|video|blogspot","id":"ac|biz|co|desa|go|mil|my|net|or|sch|web|blogspot.co","ie":"gov|blogspot","il":"ac|co|gov|idf|k12|muni|net|org|blogspot.co","im":"ac|co|com|ltd.co|net|org|plc.co|tt|tv|ro|nom","in":"co|firm|net|org|gen|ind|nic|ac|edu|res|gov|mil|cloudns|blogspot|barsy","info":"cloudns|dynamic-dns|dyndns|barrel-of-knowledge|barrell-of-knowledge|for-our|groks-the|groks-this|here-for-more|knowsitall|selfip|webhop|nsupdate|dvrcam|ilovecollege|no-ip","int":"eu","io":"com|backplaneapp|boxfuse|browsersafetymark|dedyn|drud|definima|enonic|customer.enonic|github|gitlab|hasura-app|ngrok|stage.nodeart|nodum|nid|pantheonsite|protonet|vaporcloud|hzc|sandcats|shiftedit|apps.lair|*stolos|spacekit|cust.dev.thingdust|cust.disrec.thingdust|cust.prod.thingdust|cust.testing.thingdust|wedeploy","iq":"gov|edu|mil|com|org|net","ir":"ac|co|gov|id|net|org|sch|xn--mgba3a4f16a|xn--mgba3a4fra","is":"net|com|edu|gov|org|int|cupcake|blogspot","it":"gov|edu|abr|abruzzo|aosta-valley|aostavalley|bas|basilicata|cal|calabria|cam|campania|emilia-romagna|emiliaromagna|emr|friuli-v-giulia|friuli-ve-giulia|friuli-vegiulia|friuli-venezia-giulia|friuli-veneziagiulia|friuli-vgiulia|friuliv-giulia|friulive-giulia|friulivegiulia|friulivenezia-giulia|friuliveneziagiulia|friulivgiulia|fvg|laz|lazio|lig|liguria|lom|lombardia|lombardy|lucania|mar|marche|mol|molise|piedmont|piemonte|pmn|pug|puglia|sar|sardegna|sardinia|sic|sicilia|sicily|taa|tos|toscana|trentino-a-adige|trentino-aadige|trentino-alto-adige|trentino-altoadige|trentino-s-tirol|trentino-stirol|trentino-sud-tirol|trentino-sudtirol|trentino-sued-tirol|trentino-suedtirol|trentinoa-adige|trentinoaadige|trentinoalto-adige|trentinoaltoadige|trentinos-tirol|trentinostirol|trentinosud-tirol|trentinosudtirol|trentinosued-tirol|trentinosuedtirol|tuscany|umb|umbria|val-d-aosta|val-daosta|vald-aosta|valdaosta|valle-aosta|valle-d-aosta|valle-daosta|valleaosta|valled-aosta|valledaosta|vallee-aoste|valleeaoste|vao|vda|ven|veneto|ag|agrigento|al|alessandria|alto-adige|altoadige|an|ancona|andria-barletta-trani|andria-trani-barletta|andriabarlettatrani|andriatranibarletta|ao|aosta|aoste|ap|aq|aquila|ar|arezzo|ascoli-piceno|ascolipiceno|asti|at|av|avellino|ba|balsan|bari|barletta-trani-andria|barlettatraniandria|belluno|benevento|bergamo|bg|bi|biella|bl|bn|bo|bologna|bolzano|bozen|br|brescia|brindisi|bs|bt|bz|ca|cagliari|caltanissetta|campidano-medio|campidanomedio|campobasso|carbonia-iglesias|carboniaiglesias|carrara-massa|carraramassa|caserta|catania|catanzaro|cb|ce|cesena-forli|cesenaforli|ch|chieti|ci|cl|cn|co|como|cosenza|cr|cremona|crotone|cs|ct|cuneo|cz|dell-ogliastra|dellogliastra|en|enna|fc|fe|fermo|ferrara|fg|fi|firenze|florence|fm|foggia|forli-cesena|forlicesena|fr|frosinone|ge|genoa|genova|go|gorizia|gr|grosseto|iglesias-carbonia|iglesiascarbonia|im|imperia|is|isernia|kr|la-spezia|laquila|laspezia|latina|lc|le|lecce|lecco|li|livorno|lo|lodi|lt|lu|lucca|macerata|mantova|massa-carrara|massacarrara|matera|mb|mc|me|medio-campidano|mediocampidano|messina|mi|milan|milano|mn|mo|modena|monza-brianza|monza-e-della-brianza|monza|monzabrianza|monzaebrianza|monzaedellabrianza|ms|mt|na|naples|napoli|no|novara|nu|nuoro|og|ogliastra|olbia-tempio|olbiatempio|or|oristano|ot|pa|padova|padua|palermo|parma|pavia|pc|pd|pe|perugia|pesaro-urbino|pesarourbino|pescara|pg|pi|piacenza|pisa|pistoia|pn|po|pordenone|potenza|pr|prato|pt|pu|pv|pz|ra|ragusa|ravenna|rc|re|reggio-calabria|reggio-emilia|reggiocalabria|reggioemilia|rg|ri|rieti|rimini|rm|rn|ro|roma|rome|rovigo|sa|salerno|sassari|savona|si|siena|siracusa|so|sondrio|sp|sr|ss|suedtirol|sv|ta|taranto|te|tempio-olbia|tempioolbia|teramo|terni|tn|to|torino|tp|tr|trani-andria-barletta|trani-barletta-andria|traniandriabarletta|tranibarlettaandria|trapani|trentino|trento|treviso|trieste|ts|turin|tv|ud|udine|urbino-pesaro|urbinopesaro|va|varese|vb|vc|ve|venezia|venice|verbania|vercelli|verona|vi|vibo-valentia|vibovalentia|vicenza|viterbo|vr|vs|vt|vv|blogspot","je":"co|net|org","jm":"*","jo":"com|org|net|edu|sch|gov|mil|name","jobs":"","jp":"ac|ad|co|ed|go|gr|lg|ne|or|aichi|akita|aomori|chiba|ehime|fukui|fukuoka|fukushima|gifu|gunma|hiroshima|hokkaido|hyogo|ibaraki|ishikawa|iwate|kagawa|kagoshima|kanagawa|kochi|kumamoto|kyoto|mie|miyagi|miyazaki|nagano|nagasaki|nara|niigata|oita|okayama|okinawa|osaka|saga|saitama|shiga|shimane|shizuoka|tochigi|tokushima|tokyo|tottori|toyama|wakayama|yamagata|yamaguchi|yamanashi|xn--4pvxs|xn--vgu402c|xn--c3s14m|xn--f6qx53a|xn--8pvr4u|xn--uist22h|xn--djrs72d6uy|xn--mkru45i|xn--0trq7p7nn|xn--8ltr62k|xn--2m4a15e|xn--efvn9s|xn--32vp30h|xn--4it797k|xn--1lqs71d|xn--5rtp49c|xn--5js045d|xn--ehqz56n|xn--1lqs03n|xn--qqqt11m|xn--kbrq7o|xn--pssu33l|xn--ntsq17g|xn--uisz3g|xn--6btw5a|xn--1ctwo|xn--6orx2r|xn--rht61e|xn--rht27z|xn--djty4k|xn--nit225k|xn--rht3d|xn--klty5x|xn--kltx9a|xn--kltp7d|xn--uuwu58a|xn--zbx025d|xn--ntso0iqx3a|xn--elqq16h|xn--4it168d|xn--klt787d|xn--rny31h|xn--7t0a264c|xn--5rtq34k|xn--k7yn95e|xn--tor131o|xn--d5qv7z876c|*kawasaki|*kitakyushu|*kobe|*nagoya|*sapporo|*sendai|*yokohama|!city.kawasaki|!city.kitakyushu|!city.kobe|!city.nagoya|!city.sapporo|!city.sendai|!city.yokohama|aisai.aichi|ama.aichi|anjo.aichi|asuke.aichi|chiryu.aichi|chita.aichi|fuso.aichi|gamagori.aichi|handa.aichi|hazu.aichi|hekinan.aichi|higashiura.aichi|ichinomiya.aichi|inazawa.aichi|inuyama.aichi|isshiki.aichi|iwakura.aichi|kanie.aichi|kariya.aichi|kasugai.aichi|kira.aichi|kiyosu.aichi|komaki.aichi|konan.aichi|kota.aichi|mihama.aichi|miyoshi.aichi|nishio.aichi|nisshin.aichi|obu.aichi|oguchi.aichi|oharu.aichi|okazaki.aichi|owariasahi.aichi|seto.aichi|shikatsu.aichi|shinshiro.aichi|shitara.aichi|tahara.aichi|takahama.aichi|tobishima.aichi|toei.aichi|togo.aichi|tokai.aichi|tokoname.aichi|toyoake.aichi|toyohashi.aichi|toyokawa.aichi|toyone.aichi|toyota.aichi|tsushima.aichi|yatomi.aichi|akita.akita|daisen.akita|fujisato.akita|gojome.akita|hachirogata.akita|happou.akita|higashinaruse.akita|honjo.akita|honjyo.akita|ikawa.akita|kamikoani.akita|kamioka.akita|katagami.akita|kazuno.akita|kitaakita.akita|kosaka.akita|kyowa.akita|misato.akita|mitane.akita|moriyoshi.akita|nikaho.akita|noshiro.akita|odate.akita|oga.akita|ogata.akita|semboku.akita|yokote.akita|yurihonjo.akita|aomori.aomori|gonohe.aomori|hachinohe.aomori|hashikami.aomori|hiranai.aomori|hirosaki.aomori|itayanagi.aomori|kuroishi.aomori|misawa.aomori|mutsu.aomori|nakadomari.aomori|noheji.aomori|oirase.aomori|owani.aomori|rokunohe.aomori|sannohe.aomori|shichinohe.aomori|shingo.aomori|takko.aomori|towada.aomori|tsugaru.aomori|tsuruta.aomori|abiko.chiba|asahi.chiba|chonan.chiba|chosei.chiba|choshi.chiba|chuo.chiba|funabashi.chiba|futtsu.chiba|hanamigawa.chiba|ichihara.chiba|ichikawa.chiba|ichinomiya.chiba|inzai.chiba|isumi.chiba|kamagaya.chiba|kamogawa.chiba|kashiwa.chiba|katori.chiba|katsuura.chiba|kimitsu.chiba|kisarazu.chiba|kozaki.chiba|kujukuri.chiba|kyonan.chiba|matsudo.chiba|midori.chiba|mihama.chiba|minamiboso.chiba|mobara.chiba|mutsuzawa.chiba|nagara.chiba|nagareyama.chiba|narashino.chiba|narita.chiba|noda.chiba|oamishirasato.chiba|omigawa.chiba|onjuku.chiba|otaki.chiba|sakae.chiba|sakura.chiba|shimofusa.chiba|shirako.chiba|shiroi.chiba|shisui.chiba|sodegaura.chiba|sosa.chiba|tako.chiba|tateyama.chiba|togane.chiba|tohnosho.chiba|tomisato.chiba|urayasu.chiba|yachimata.chiba|yachiyo.chiba|yokaichiba.chiba|yokoshibahikari.chiba|yotsukaido.chiba|ainan.ehime|honai.ehime|ikata.ehime|imabari.ehime|iyo.ehime|kamijima.ehime|kihoku.ehime|kumakogen.ehime|masaki.ehime|matsuno.ehime|matsuyama.ehime|namikata.ehime|niihama.ehime|ozu.ehime|saijo.ehime|seiyo.ehime|shikokuchuo.ehime|tobe.ehime|toon.ehime|uchiko.ehime|uwajima.ehime|yawatahama.ehime|echizen.fukui|eiheiji.fukui|fukui.fukui|ikeda.fukui|katsuyama.fukui|mihama.fukui|minamiechizen.fukui|obama.fukui|ohi.fukui|ono.fukui|sabae.fukui|sakai.fukui|takahama.fukui|tsuruga.fukui|wakasa.fukui|ashiya.fukuoka|buzen.fukuoka|chikugo.fukuoka|chikuho.fukuoka|chikujo.fukuoka|chikushino.fukuoka|chikuzen.fukuoka|chuo.fukuoka|dazaifu.fukuoka|fukuchi.fukuoka|hakata.fukuoka|higashi.fukuoka|hirokawa.fukuoka|hisayama.fukuoka|iizuka.fukuoka|inatsuki.fukuoka|kaho.fukuoka|kasuga.fukuoka|kasuya.fukuoka|kawara.fukuoka|keisen.fukuoka|koga.fukuoka|kurate.fukuoka|kurogi.fukuoka|kurume.fukuoka|minami.fukuoka|miyako.fukuoka|miyama.fukuoka|miyawaka.fukuoka|mizumaki.fukuoka|munakata.fukuoka|nakagawa.fukuoka|nakama.fukuoka|nishi.fukuoka|nogata.fukuoka|ogori.fukuoka|okagaki.fukuoka|okawa.fukuoka|oki.fukuoka|omuta.fukuoka|onga.fukuoka|onojo.fukuoka|oto.fukuoka|saigawa.fukuoka|sasaguri.fukuoka|shingu.fukuoka|shinyoshitomi.fukuoka|shonai.fukuoka|soeda.fukuoka|sue.fukuoka|tachiarai.fukuoka|tagawa.fukuoka|takata.fukuoka|toho.fukuoka|toyotsu.fukuoka|tsuiki.fukuoka|ukiha.fukuoka|umi.fukuoka|usui.fukuoka|yamada.fukuoka|yame.fukuoka|yanagawa.fukuoka|yukuhashi.fukuoka|aizubange.fukushima|aizumisato.fukushima|aizuwakamatsu.fukushima|asakawa.fukushima|bandai.fukushima|date.fukushima|fukushima.fukushima|furudono.fukushima|futaba.fukushima|hanawa.fukushima|higashi.fukushima|hirata.fukushima|hirono.fukushima|iitate.fukushima|inawashiro.fukushima|ishikawa.fukushima|iwaki.fukushima|izumizaki.fukushima|kagamiishi.fukushima|kaneyama.fukushima|kawamata.fukushima|kitakata.fukushima|kitashiobara.fukushima|koori.fukushima|koriyama.fukushima|kunimi.fukushima|miharu.fukushima|mishima.fukushima|namie.fukushima|nango.fukushima|nishiaizu.fukushima|nishigo.fukushima|okuma.fukushima|omotego.fukushima|ono.fukushima|otama.fukushima|samegawa.fukushima|shimogo.fukushima|shirakawa.fukushima|showa.fukushima|soma.fukushima|sukagawa.fukushima|taishin.fukushima|tamakawa.fukushima|tanagura.fukushima|tenei.fukushima|yabuki.fukushima|yamato.fukushima|yamatsuri.fukushima|yanaizu.fukushima|yugawa.fukushima|anpachi.gifu|ena.gifu|gifu.gifu|ginan.gifu|godo.gifu|gujo.gifu|hashima.gifu|hichiso.gifu|hida.gifu|higashishirakawa.gifu|ibigawa.gifu|ikeda.gifu|kakamigahara.gifu|kani.gifu|kasahara.gifu|kasamatsu.gifu|kawaue.gifu|kitagata.gifu|mino.gifu|minokamo.gifu|mitake.gifu|mizunami.gifu|motosu.gifu|nakatsugawa.gifu|ogaki.gifu|sakahogi.gifu|seki.gifu|sekigahara.gifu|shirakawa.gifu|tajimi.gifu|takayama.gifu|tarui.gifu|toki.gifu|tomika.gifu|wanouchi.gifu|yamagata.gifu|yaotsu.gifu|yoro.gifu|annaka.gunma|chiyoda.gunma|fujioka.gunma|higashiagatsuma.gunma|isesaki.gunma|itakura.gunma|kanna.gunma|kanra.gunma|katashina.gunma|kawaba.gunma|kiryu.gunma|kusatsu.gunma|maebashi.gunma|meiwa.gunma|midori.gunma|minakami.gunma|naganohara.gunma|nakanojo.gunma|nanmoku.gunma|numata.gunma|oizumi.gunma|ora.gunma|ota.gunma|shibukawa.gunma|shimonita.gunma|shinto.gunma|showa.gunma|takasaki.gunma|takayama.gunma|tamamura.gunma|tatebayashi.gunma|tomioka.gunma|tsukiyono.gunma|tsumagoi.gunma|ueno.gunma|yoshioka.gunma|asaminami.hiroshima|daiwa.hiroshima|etajima.hiroshima|fuchu.hiroshima|fukuyama.hiroshima|hatsukaichi.hiroshima|higashihiroshima.hiroshima|hongo.hiroshima|jinsekikogen.hiroshima|kaita.hiroshima|kui.hiroshima|kumano.hiroshima|kure.hiroshima|mihara.hiroshima|miyoshi.hiroshima|naka.hiroshima|onomichi.hiroshima|osakikamijima.hiroshima|otake.hiroshima|saka.hiroshima|sera.hiroshima|seranishi.hiroshima|shinichi.hiroshima|shobara.hiroshima|takehara.hiroshima|abashiri.hokkaido|abira.hokkaido|aibetsu.hokkaido|akabira.hokkaido|akkeshi.hokkaido|asahikawa.hokkaido|ashibetsu.hokkaido|ashoro.hokkaido|assabu.hokkaido|atsuma.hokkaido|bibai.hokkaido|biei.hokkaido|bifuka.hokkaido|bihoro.hokkaido|biratori.hokkaido|chippubetsu.hokkaido|chitose.hokkaido|date.hokkaido|ebetsu.hokkaido|embetsu.hokkaido|eniwa.hokkaido|erimo.hokkaido|esan.hokkaido|esashi.hokkaido|fukagawa.hokkaido|fukushima.hokkaido|furano.hokkaido|furubira.hokkaido|haboro.hokkaido|hakodate.hokkaido|hamatonbetsu.hokkaido|hidaka.hokkaido|higashikagura.hokkaido|higashikawa.hokkaido|hiroo.hokkaido|hokuryu.hokkaido|hokuto.hokkaido|honbetsu.hokkaido|horokanai.hokkaido|horonobe.hokkaido|ikeda.hokkaido|imakane.hokkaido|ishikari.hokkaido|iwamizawa.hokkaido|iwanai.hokkaido|kamifurano.hokkaido|kamikawa.hokkaido|kamishihoro.hokkaido|kamisunagawa.hokkaido|kamoenai.hokkaido|kayabe.hokkaido|kembuchi.hokkaido|kikonai.hokkaido|kimobetsu.hokkaido|kitahiroshima.hokkaido|kitami.hokkaido|kiyosato.hokkaido|koshimizu.hokkaido|kunneppu.hokkaido|kuriyama.hokkaido|kuromatsunai.hokkaido|kushiro.hokkaido|kutchan.hokkaido|kyowa.hokkaido|mashike.hokkaido|matsumae.hokkaido|mikasa.hokkaido|minamifurano.hokkaido|mombetsu.hokkaido|moseushi.hokkaido|mukawa.hokkaido|muroran.hokkaido|naie.hokkaido|nakagawa.hokkaido|nakasatsunai.hokkaido|nakatombetsu.hokkaido|nanae.hokkaido|nanporo.hokkaido|nayoro.hokkaido|nemuro.hokkaido|niikappu.hokkaido|niki.hokkaido|nishiokoppe.hokkaido|noboribetsu.hokkaido|numata.hokkaido|obihiro.hokkaido|obira.hokkaido|oketo.hokkaido|okoppe.hokkaido|otaru.hokkaido|otobe.hokkaido|otofuke.hokkaido|otoineppu.hokkaido|oumu.hokkaido|ozora.hokkaido|pippu.hokkaido|rankoshi.hokkaido|rebun.hokkaido|rikubetsu.hokkaido|rishiri.hokkaido|rishirifuji.hokkaido|saroma.hokkaido|sarufutsu.hokkaido|shakotan.hokkaido|shari.hokkaido|shibecha.hokkaido|shibetsu.hokkaido|shikabe.hokkaido|shikaoi.hokkaido|shimamaki.hokkaido|shimizu.hokkaido|shimokawa.hokkaido|shinshinotsu.hokkaido|shintoku.hokkaido|shiranuka.hokkaido|shiraoi.hokkaido|shiriuchi.hokkaido|sobetsu.hokkaido|sunagawa.hokkaido|taiki.hokkaido|takasu.hokkaido|takikawa.hokkaido|takinoue.hokkaido|teshikaga.hokkaido|tobetsu.hokkaido|tohma.hokkaido|tomakomai.hokkaido|tomari.hokkaido|toya.hokkaido|toyako.hokkaido|toyotomi.hokkaido|toyoura.hokkaido|tsubetsu.hokkaido|tsukigata.hokkaido|urakawa.hokkaido|urausu.hokkaido|uryu.hokkaido|utashinai.hokkaido|wakkanai.hokkaido|wassamu.hokkaido|yakumo.hokkaido|yoichi.hokkaido|aioi.hyogo|akashi.hyogo|ako.hyogo|amagasaki.hyogo|aogaki.hyogo|asago.hyogo|ashiya.hyogo|awaji.hyogo|fukusaki.hyogo|goshiki.hyogo|harima.hyogo|himeji.hyogo|ichikawa.hyogo|inagawa.hyogo|itami.hyogo|kakogawa.hyogo|kamigori.hyogo|kamikawa.hyogo|kasai.hyogo|kasuga.hyogo|kawanishi.hyogo|miki.hyogo|minamiawaji.hyogo|nishinomiya.hyogo|nishiwaki.hyogo|ono.hyogo|sanda.hyogo|sannan.hyogo|sasayama.hyogo|sayo.hyogo|shingu.hyogo|shinonsen.hyogo|shiso.hyogo|sumoto.hyogo|taishi.hyogo|taka.hyogo|takarazuka.hyogo|takasago.hyogo|takino.hyogo|tamba.hyogo|tatsuno.hyogo|toyooka.hyogo|yabu.hyogo|yashiro.hyogo|yoka.hyogo|yokawa.hyogo|ami.ibaraki|asahi.ibaraki|bando.ibaraki|chikusei.ibaraki|daigo.ibaraki|fujishiro.ibaraki|hitachi.ibaraki|hitachinaka.ibaraki|hitachiomiya.ibaraki|hitachiota.ibaraki|ibaraki.ibaraki|ina.ibaraki|inashiki.ibaraki|itako.ibaraki|iwama.ibaraki|joso.ibaraki|kamisu.ibaraki|kasama.ibaraki|kashima.ibaraki|kasumigaura.ibaraki|koga.ibaraki|miho.ibaraki|mito.ibaraki|moriya.ibaraki|naka.ibaraki|namegata.ibaraki|oarai.ibaraki|ogawa.ibaraki|omitama.ibaraki|ryugasaki.ibaraki|sakai.ibaraki|sakuragawa.ibaraki|shimodate.ibaraki|shimotsuma.ibaraki|shirosato.ibaraki|sowa.ibaraki|suifu.ibaraki|takahagi.ibaraki|tamatsukuri.ibaraki|tokai.ibaraki|tomobe.ibaraki|tone.ibaraki|toride.ibaraki|tsuchiura.ibaraki|tsukuba.ibaraki|uchihara.ibaraki|ushiku.ibaraki|yachiyo.ibaraki|yamagata.ibaraki|yawara.ibaraki|yuki.ibaraki|anamizu.ishikawa|hakui.ishikawa|hakusan.ishikawa|kaga.ishikawa|kahoku.ishikawa|kanazawa.ishikawa|kawakita.ishikawa|komatsu.ishikawa|nakanoto.ishikawa|nanao.ishikawa|nomi.ishikawa|nonoichi.ishikawa|noto.ishikawa|shika.ishikawa|suzu.ishikawa|tsubata.ishikawa|tsurugi.ishikawa|uchinada.ishikawa|wajima.ishikawa|fudai.iwate|fujisawa.iwate|hanamaki.iwate|hiraizumi.iwate|hirono.iwate|ichinohe.iwate|ichinoseki.iwate|iwaizumi.iwate|iwate.iwate|joboji.iwate|kamaishi.iwate|kanegasaki.iwate|karumai.iwate|kawai.iwate|kitakami.iwate|kuji.iwate|kunohe.iwate|kuzumaki.iwate|miyako.iwate|mizusawa.iwate|morioka.iwate|ninohe.iwate|noda.iwate|ofunato.iwate|oshu.iwate|otsuchi.iwate|rikuzentakata.iwate|shiwa.iwate|shizukuishi.iwate|sumita.iwate|tanohata.iwate|tono.iwate|yahaba.iwate|yamada.iwate|ayagawa.kagawa|higashikagawa.kagawa|kanonji.kagawa|kotohira.kagawa|manno.kagawa|marugame.kagawa|mitoyo.kagawa|naoshima.kagawa|sanuki.kagawa|tadotsu.kagawa|takamatsu.kagawa|tonosho.kagawa|uchinomi.kagawa|utazu.kagawa|zentsuji.kagawa|akune.kagoshima|amami.kagoshima|hioki.kagoshima|isa.kagoshima|isen.kagoshima|izumi.kagoshima|kagoshima.kagoshima|kanoya.kagoshima|kawanabe.kagoshima|kinko.kagoshima|kouyama.kagoshima|makurazaki.kagoshima|matsumoto.kagoshima|minamitane.kagoshima|nakatane.kagoshima|nishinoomote.kagoshima|satsumasendai.kagoshima|soo.kagoshima|tarumizu.kagoshima|yusui.kagoshima|aikawa.kanagawa|atsugi.kanagawa|ayase.kanagawa|chigasaki.kanagawa|ebina.kanagawa|fujisawa.kanagawa|hadano.kanagawa|hakone.kanagawa|hiratsuka.kanagawa|isehara.kanagawa|kaisei.kanagawa|kamakura.kanagawa|kiyokawa.kanagawa|matsuda.kanagawa|minamiashigara.kanagawa|miura.kanagawa|nakai.kanagawa|ninomiya.kanagawa|odawara.kanagawa|oi.kanagawa|oiso.kanagawa|sagamihara.kanagawa|samukawa.kanagawa|tsukui.kanagawa|yamakita.kanagawa|yamato.kanagawa|yokosuka.kanagawa|yugawara.kanagawa|zama.kanagawa|zushi.kanagawa|aki.kochi|geisei.kochi|hidaka.kochi|higashitsuno.kochi|ino.kochi|kagami.kochi|kami.kochi|kitagawa.kochi|kochi.kochi|mihara.kochi|motoyama.kochi|muroto.kochi|nahari.kochi|nakamura.kochi|nankoku.kochi|nishitosa.kochi|niyodogawa.kochi|ochi.kochi|okawa.kochi|otoyo.kochi|otsuki.kochi|sakawa.kochi|sukumo.kochi|susaki.kochi|tosa.kochi|tosashimizu.kochi|toyo.kochi|tsuno.kochi|umaji.kochi|yasuda.kochi|yusuhara.kochi|amakusa.kumamoto|arao.kumamoto|aso.kumamoto|choyo.kumamoto|gyokuto.kumamoto|kamiamakusa.kumamoto|kikuchi.kumamoto|kumamoto.kumamoto|mashiki.kumamoto|mifune.kumamoto|minamata.kumamoto|minamioguni.kumamoto|nagasu.kumamoto|nishihara.kumamoto|oguni.kumamoto|ozu.kumamoto|sumoto.kumamoto|takamori.kumamoto|uki.kumamoto|uto.kumamoto|yamaga.kumamoto|yamato.kumamoto|yatsushiro.kumamoto|ayabe.kyoto|fukuchiyama.kyoto|higashiyama.kyoto|ide.kyoto|ine.kyoto|joyo.kyoto|kameoka.kyoto|kamo.kyoto|kita.kyoto|kizu.kyoto|kumiyama.kyoto|kyotamba.kyoto|kyotanabe.kyoto|kyotango.kyoto|maizuru.kyoto|minami.kyoto|minamiyamashiro.kyoto|miyazu.kyoto|muko.kyoto|nagaokakyo.kyoto|nakagyo.kyoto|nantan.kyoto|oyamazaki.kyoto|sakyo.kyoto|seika.kyoto|tanabe.kyoto|uji.kyoto|ujitawara.kyoto|wazuka.kyoto|yamashina.kyoto|yawata.kyoto|asahi.mie|inabe.mie|ise.mie|kameyama.mie|kawagoe.mie|kiho.mie|kisosaki.mie|kiwa.mie|komono.mie|kumano.mie|kuwana.mie|matsusaka.mie|meiwa.mie|mihama.mie|minamiise.mie|misugi.mie|miyama.mie|nabari.mie|shima.mie|suzuka.mie|tado.mie|taiki.mie|taki.mie|tamaki.mie|toba.mie|tsu.mie|udono.mie|ureshino.mie|watarai.mie|yokkaichi.mie|furukawa.miyagi|higashimatsushima.miyagi|ishinomaki.miyagi|iwanuma.miyagi|kakuda.miyagi|kami.miyagi|kawasaki.miyagi|marumori.miyagi|matsushima.miyagi|minamisanriku.miyagi|misato.miyagi|murata.miyagi|natori.miyagi|ogawara.miyagi|ohira.miyagi|onagawa.miyagi|osaki.miyagi|rifu.miyagi|semine.miyagi|shibata.miyagi|shichikashuku.miyagi|shikama.miyagi|shiogama.miyagi|shiroishi.miyagi|tagajo.miyagi|taiwa.miyagi|tome.miyagi|tomiya.miyagi|wakuya.miyagi|watari.miyagi|yamamoto.miyagi|zao.miyagi|aya.miyazaki|ebino.miyazaki|gokase.miyazaki|hyuga.miyazaki|kadogawa.miyazaki|kawaminami.miyazaki|kijo.miyazaki|kitagawa.miyazaki|kitakata.miyazaki|kitaura.miyazaki|kobayashi.miyazaki|kunitomi.miyazaki|kushima.miyazaki|mimata.miyazaki|miyakonojo.miyazaki|miyazaki.miyazaki|morotsuka.miyazaki|nichinan.miyazaki|nishimera.miyazaki|nobeoka.miyazaki|saito.miyazaki|shiiba.miyazaki|shintomi.miyazaki|takaharu.miyazaki|takanabe.miyazaki|takazaki.miyazaki|tsuno.miyazaki|achi.nagano|agematsu.nagano|anan.nagano|aoki.nagano|asahi.nagano|azumino.nagano|chikuhoku.nagano|chikuma.nagano|chino.nagano|fujimi.nagano|hakuba.nagano|hara.nagano|hiraya.nagano|iida.nagano|iijima.nagano|iiyama.nagano|iizuna.nagano|ikeda.nagano|ikusaka.nagano|ina.nagano|karuizawa.nagano|kawakami.nagano|kiso.nagano|kisofukushima.nagano|kitaaiki.nagano|komagane.nagano|komoro.nagano|matsukawa.nagano|matsumoto.nagano|miasa.nagano|minamiaiki.nagano|minamimaki.nagano|minamiminowa.nagano|minowa.nagano|miyada.nagano|miyota.nagano|mochizuki.nagano|nagano.nagano|nagawa.nagano|nagiso.nagano|nakagawa.nagano|nakano.nagano|nozawaonsen.nagano|obuse.nagano|ogawa.nagano|okaya.nagano|omachi.nagano|omi.nagano|ookuwa.nagano|ooshika.nagano|otaki.nagano|otari.nagano|sakae.nagano|sakaki.nagano|saku.nagano|sakuho.nagano|shimosuwa.nagano|shinanomachi.nagano|shiojiri.nagano|suwa.nagano|suzaka.nagano|takagi.nagano|takamori.nagano|takayama.nagano|tateshina.nagano|tatsuno.nagano|togakushi.nagano|togura.nagano|tomi.nagano|ueda.nagano|wada.nagano|yamagata.nagano|yamanouchi.nagano|yasaka.nagano|yasuoka.nagano|chijiwa.nagasaki|futsu.nagasaki|goto.nagasaki|hasami.nagasaki|hirado.nagasaki|iki.nagasaki|isahaya.nagasaki|kawatana.nagasaki|kuchinotsu.nagasaki|matsuura.nagasaki|nagasaki.nagasaki|obama.nagasaki|omura.nagasaki|oseto.nagasaki|saikai.nagasaki|sasebo.nagasaki|seihi.nagasaki|shimabara.nagasaki|shinkamigoto.nagasaki|togitsu.nagasaki|tsushima.nagasaki|unzen.nagasaki|ando.nara|gose.nara|heguri.nara|higashiyoshino.nara|ikaruga.nara|ikoma.nara|kamikitayama.nara|kanmaki.nara|kashiba.nara|kashihara.nara|katsuragi.nara|kawai.nara|kawakami.nara|kawanishi.nara|koryo.nara|kurotaki.nara|mitsue.nara|miyake.nara|nara.nara|nosegawa.nara|oji.nara|ouda.nara|oyodo.nara|sakurai.nara|sango.nara|shimoichi.nara|shimokitayama.nara|shinjo.nara|soni.nara|takatori.nara|tawaramoto.nara|tenkawa.nara|tenri.nara|uda.nara|yamatokoriyama.nara|yamatotakada.nara|yamazoe.nara|yoshino.nara|aga.niigata|agano.niigata|gosen.niigata|itoigawa.niigata|izumozaki.niigata|joetsu.niigata|kamo.niigata|kariwa.niigata|kashiwazaki.niigata|minamiuonuma.niigata|mitsuke.niigata|muika.niigata|murakami.niigata|myoko.niigata|nagaoka.niigata|niigata.niigata|ojiya.niigata|omi.niigata|sado.niigata|sanjo.niigata|seiro.niigata|seirou.niigata|sekikawa.niigata|shibata.niigata|tagami.niigata|tainai.niigata|tochio.niigata|tokamachi.niigata|tsubame.niigata|tsunan.niigata|uonuma.niigata|yahiko.niigata|yoita.niigata|yuzawa.niigata|beppu.oita|bungoono.oita|bungotakada.oita|hasama.oita|hiji.oita|himeshima.oita|hita.oita|kamitsue.oita|kokonoe.oita|kuju.oita|kunisaki.oita|kusu.oita|oita.oita|saiki.oita|taketa.oita|tsukumi.oita|usa.oita|usuki.oita|yufu.oita|akaiwa.okayama|asakuchi.okayama|bizen.okayama|hayashima.okayama|ibara.okayama|kagamino.okayama|kasaoka.okayama|kibichuo.okayama|kumenan.okayama|kurashiki.okayama|maniwa.okayama|misaki.okayama|nagi.okayama|niimi.okayama|nishiawakura.okayama|okayama.okayama|satosho.okayama|setouchi.okayama|shinjo.okayama|shoo.okayama|soja.okayama|takahashi.okayama|tamano.okayama|tsuyama.okayama|wake.okayama|yakage.okayama|aguni.okinawa|ginowan.okinawa|ginoza.okinawa|gushikami.okinawa|haebaru.okinawa|higashi.okinawa|hirara.okinawa|iheya.okinawa|ishigaki.okinawa|ishikawa.okinawa|itoman.okinawa|izena.okinawa|kadena.okinawa|kin.okinawa|kitadaito.okinawa|kitanakagusuku.okinawa|kumejima.okinawa|kunigami.okinawa|minamidaito.okinawa|motobu.okinawa|nago.okinawa|naha.okinawa|nakagusuku.okinawa|nakijin.okinawa|nanjo.okinawa|nishihara.okinawa|ogimi.okinawa|okinawa.okinawa|onna.okinawa|shimoji.okinawa|taketomi.okinawa|tarama.okinawa|tokashiki.okinawa|tomigusuku.okinawa|tonaki.okinawa|urasoe.okinawa|uruma.okinawa|yaese.okinawa|yomitan.okinawa|yonabaru.okinawa|yonaguni.okinawa|zamami.okinawa|abeno.osaka|chihayaakasaka.osaka|chuo.osaka|daito.osaka|fujiidera.osaka|habikino.osaka|hannan.osaka|higashiosaka.osaka|higashisumiyoshi.osaka|higashiyodogawa.osaka|hirakata.osaka|ibaraki.osaka|ikeda.osaka|izumi.osaka|izumiotsu.osaka|izumisano.osaka|kadoma.osaka|kaizuka.osaka|kanan.osaka|kashiwara.osaka|katano.osaka|kawachinagano.osaka|kishiwada.osaka|kita.osaka|kumatori.osaka|matsubara.osaka|minato.osaka|minoh.osaka|misaki.osaka|moriguchi.osaka|neyagawa.osaka|nishi.osaka|nose.osaka|osakasayama.osaka|sakai.osaka|sayama.osaka|sennan.osaka|settsu.osaka|shijonawate.osaka|shimamoto.osaka|suita.osaka|tadaoka.osaka|taishi.osaka|tajiri.osaka|takaishi.osaka|takatsuki.osaka|tondabayashi.osaka|toyonaka.osaka|toyono.osaka|yao.osaka|ariake.saga|arita.saga|fukudomi.saga|genkai.saga|hamatama.saga|hizen.saga|imari.saga|kamimine.saga|kanzaki.saga|karatsu.saga|kashima.saga|kitagata.saga|kitahata.saga|kiyama.saga|kouhoku.saga|kyuragi.saga|nishiarita.saga|ogi.saga|omachi.saga|ouchi.saga|saga.saga|shiroishi.saga|taku.saga|tara.saga|tosu.saga|yoshinogari.saga|arakawa.saitama|asaka.saitama|chichibu.saitama|fujimi.saitama|fujimino.saitama|fukaya.saitama|hanno.saitama|hanyu.saitama|hasuda.saitama|hatogaya.saitama|hatoyama.saitama|hidaka.saitama|higashichichibu.saitama|higashimatsuyama.saitama|honjo.saitama|ina.saitama|iruma.saitama|iwatsuki.saitama|kamiizumi.saitama|kamikawa.saitama|kamisato.saitama|kasukabe.saitama|kawagoe.saitama|kawaguchi.saitama|kawajima.saitama|kazo.saitama|kitamoto.saitama|koshigaya.saitama|kounosu.saitama|kuki.saitama|kumagaya.saitama|matsubushi.saitama|minano.saitama|misato.saitama|miyashiro.saitama|miyoshi.saitama|moroyama.saitama|nagatoro.saitama|namegawa.saitama|niiza.saitama|ogano.saitama|ogawa.saitama|ogose.saitama|okegawa.saitama|omiya.saitama|otaki.saitama|ranzan.saitama|ryokami.saitama|saitama.saitama|sakado.saitama|satte.saitama|sayama.saitama|shiki.saitama|shiraoka.saitama|soka.saitama|sugito.saitama|toda.saitama|tokigawa.saitama|tokorozawa.saitama|tsurugashima.saitama|urawa.saitama|warabi.saitama|yashio.saitama|yokoze.saitama|yono.saitama|yorii.saitama|yoshida.saitama|yoshikawa.saitama|yoshimi.saitama|aisho.shiga|gamo.shiga|higashiomi.shiga|hikone.shiga|koka.shiga|konan.shiga|kosei.shiga|koto.shiga|kusatsu.shiga|maibara.shiga|moriyama.shiga|nagahama.shiga|nishiazai.shiga|notogawa.shiga|omihachiman.shiga|otsu.shiga|ritto.shiga|ryuoh.shiga|takashima.shiga|takatsuki.shiga|torahime.shiga|toyosato.shiga|yasu.shiga|akagi.shimane|ama.shimane|gotsu.shimane|hamada.shimane|higashiizumo.shimane|hikawa.shimane|hikimi.shimane|izumo.shimane|kakinoki.shimane|masuda.shimane|matsue.shimane|misato.shimane|nishinoshima.shimane|ohda.shimane|okinoshima.shimane|okuizumo.shimane|shimane.shimane|tamayu.shimane|tsuwano.shimane|unnan.shimane|yakumo.shimane|yasugi.shimane|yatsuka.shimane|arai.shizuoka|atami.shizuoka|fuji.shizuoka|fujieda.shizuoka|fujikawa.shizuoka|fujinomiya.shizuoka|fukuroi.shizuoka|gotemba.shizuoka|haibara.shizuoka|hamamatsu.shizuoka|higashiizu.shizuoka|ito.shizuoka|iwata.shizuoka|izu.shizuoka|izunokuni.shizuoka|kakegawa.shizuoka|kannami.shizuoka|kawanehon.shizuoka|kawazu.shizuoka|kikugawa.shizuoka|kosai.shizuoka|makinohara.shizuoka|matsuzaki.shizuoka|minamiizu.shizuoka|mishima.shizuoka|morimachi.shizuoka|nishiizu.shizuoka|numazu.shizuoka|omaezaki.shizuoka|shimada.shizuoka|shimizu.shizuoka|shimoda.shizuoka|shizuoka.shizuoka|susono.shizuoka|yaizu.shizuoka|yoshida.shizuoka|ashikaga.tochigi|bato.tochigi|haga.tochigi|ichikai.tochigi|iwafune.tochigi|kaminokawa.tochigi|kanuma.tochigi|karasuyama.tochigi|kuroiso.tochigi|mashiko.tochigi|mibu.tochigi|moka.tochigi|motegi.tochigi|nasu.tochigi|nasushiobara.tochigi|nikko.tochigi|nishikata.tochigi|nogi.tochigi|ohira.tochigi|ohtawara.tochigi|oyama.tochigi|sakura.tochigi|sano.tochigi|shimotsuke.tochigi|shioya.tochigi|takanezawa.tochigi|tochigi.tochigi|tsuga.tochigi|ujiie.tochigi|utsunomiya.tochigi|yaita.tochigi|aizumi.tokushima|anan.tokushima|ichiba.tokushima|itano.tokushima|kainan.tokushima|komatsushima.tokushima|matsushige.tokushima|mima.tokushima|minami.tokushima|miyoshi.tokushima|mugi.tokushima|nakagawa.tokushima|naruto.tokushima|sanagochi.tokushima|shishikui.tokushima|tokushima.tokushima|wajiki.tokushima|adachi.tokyo|akiruno.tokyo|akishima.tokyo|aogashima.tokyo|arakawa.tokyo|bunkyo.tokyo|chiyoda.tokyo|chofu.tokyo|chuo.tokyo|edogawa.tokyo|fuchu.tokyo|fussa.tokyo|hachijo.tokyo|hachioji.tokyo|hamura.tokyo|higashikurume.tokyo|higashimurayama.tokyo|higashiyamato.tokyo|hino.tokyo|hinode.tokyo|hinohara.tokyo|inagi.tokyo|itabashi.tokyo|katsushika.tokyo|kita.tokyo|kiyose.tokyo|kodaira.tokyo|koganei.tokyo|kokubunji.tokyo|komae.tokyo|koto.tokyo|kouzushima.tokyo|kunitachi.tokyo|machida.tokyo|meguro.tokyo|minato.tokyo|mitaka.tokyo|mizuho.tokyo|musashimurayama.tokyo|musashino.tokyo|nakano.tokyo|nerima.tokyo|ogasawara.tokyo|okutama.tokyo|ome.tokyo|oshima.tokyo|ota.tokyo|setagaya.tokyo|shibuya.tokyo|shinagawa.tokyo|shinjuku.tokyo|suginami.tokyo|sumida.tokyo|tachikawa.tokyo|taito.tokyo|tama.tokyo|toshima.tokyo|chizu.tottori|hino.tottori|kawahara.tottori|koge.tottori|kotoura.tottori|misasa.tottori|nanbu.tottori|nichinan.tottori|sakaiminato.tottori|tottori.tottori|wakasa.tottori|yazu.tottori|yonago.tottori|asahi.toyama|fuchu.toyama|fukumitsu.toyama|funahashi.toyama|himi.toyama|imizu.toyama|inami.toyama|johana.toyama|kamiichi.toyama|kurobe.toyama|nakaniikawa.toyama|namerikawa.toyama|nanto.toyama|nyuzen.toyama|oyabe.toyama|taira.toyama|takaoka.toyama|tateyama.toyama|toga.toyama|tonami.toyama|toyama.toyama|unazuki.toyama|uozu.toyama|yamada.toyama|arida.wakayama|aridagawa.wakayama|gobo.wakayama|hashimoto.wakayama|hidaka.wakayama|hirogawa.wakayama|inami.wakayama|iwade.wakayama|kainan.wakayama|kamitonda.wakayama|katsuragi.wakayama|kimino.wakayama|kinokawa.wakayama|kitayama.wakayama|koya.wakayama|koza.wakayama|kozagawa.wakayama|kudoyama.wakayama|kushimoto.wakayama|mihama.wakayama|misato.wakayama|nachikatsuura.wakayama|shingu.wakayama|shirahama.wakayama|taiji.wakayama|tanabe.wakayama|wakayama.wakayama|yuasa.wakayama|yura.wakayama|asahi.yamagata|funagata.yamagata|higashine.yamagata|iide.yamagata|kahoku.yamagata|kaminoyama.yamagata|kaneyama.yamagata|kawanishi.yamagata|mamurogawa.yamagata|mikawa.yamagata|murayama.yamagata|nagai.yamagata|nakayama.yamagata|nanyo.yamagata|nishikawa.yamagata|obanazawa.yamagata|oe.yamagata|oguni.yamagata|ohkura.yamagata|oishida.yamagata|sagae.yamagata|sakata.yamagata|sakegawa.yamagata|shinjo.yamagata|shirataka.yamagata|shonai.yamagata|takahata.yamagata|tendo.yamagata|tozawa.yamagata|tsuruoka.yamagata|yamagata.yamagata|yamanobe.yamagata|yonezawa.yamagata|yuza.yamagata|abu.yamaguchi|hagi.yamaguchi|hikari.yamaguchi|hofu.yamaguchi|iwakuni.yamaguchi|kudamatsu.yamaguchi|mitou.yamaguchi|nagato.yamaguchi|oshima.yamaguchi|shimonoseki.yamaguchi|shunan.yamaguchi|tabuse.yamaguchi|tokuyama.yamaguchi|toyota.yamaguchi|ube.yamaguchi|yuu.yamaguchi|chuo.yamanashi|doshi.yamanashi|fuefuki.yamanashi|fujikawa.yamanashi|fujikawaguchiko.yamanashi|fujiyoshida.yamanashi|hayakawa.yamanashi|hokuto.yamanashi|ichikawamisato.yamanashi|kai.yamanashi|kofu.yamanashi|koshu.yamanashi|kosuge.yamanashi|minami-alps.yamanashi|minobu.yamanashi|nakamichi.yamanashi|nanbu.yamanashi|narusawa.yamanashi|nirasaki.yamanashi|nishikatsura.yamanashi|oshino.yamanashi|otsuki.yamanashi|showa.yamanashi|tabayama.yamanashi|tsuru.yamanashi|uenohara.yamanashi|yamanakako.yamanashi|yamanashi.yamanashi|blogspot","ke":"*|blogspot.co","kg":"org|net|com|edu|gov|mil","kh":"*","ki":"edu|biz|net|org|gov|info|com","km":"org|nom|gov|prd|tm|edu|mil|ass|com|coop|asso|presse|medecin|notaires|pharmaciens|veterinaire|gouv","kn":"net|org|edu|gov","kp":"com|edu|gov|org|rep|tra","kr":"ac|co|es|go|hs|kg|mil|ms|ne|or|pe|re|sc|busan|chungbuk|chungnam|daegu|daejeon|gangwon|gwangju|gyeongbuk|gyeonggi|gyeongnam|incheon|jeju|jeonbuk|jeonnam|seoul|ulsan|blogspot","kw":"*","ky":"edu|gov|com|org|net","kz":"org|edu|net|gov|mil|com|nym","la":"int|net|info|edu|gov|per|com|org|bnr|c|nym","lb":"com|edu|gov|net|org","lc":"com|net|co|org|edu|gov|oy","li":"blogspot|nom|nym","lk":"gov|sch|net|int|com|org|edu|ngo|soc|web|ltd|assn|grp|hotel|ac","lr":"com|edu|gov|org|net","ls":"co|org","lt":"gov|blogspot|nym","lu":"blogspot|nym","lv":"com|edu|gov|org|mil|id|net|asn|conf","ly":"com|net|gov|plc|edu|sch|med|org|id","ma":"co|net|gov|org|ac|press","mc":"tm|asso","md":"blogspot","me":"co|net|org|edu|ac|gov|its|priv|c66|daplie|localhost.daplie|filegear|brasilia|ddns|dnsfor|hopto|loginto|noip|webhop|nym|diskstation|dscloud|i234|myds|synology|wedeploy|yombo","mg":"org|nom|gov|prd|tm|edu|mil|com|co","mh":"","mil":"","mk":"com|org|net|edu|gov|inf|name|blogspot|nom","ml":"com|edu|gouv|gov|net|org|presse","mm":"*","mn":"gov|edu|org|nyc","mo":"com|net|org|edu|gov","mobi":"dscloud","mp":"","mq":"","mr":"gov|blogspot","ms":"com|edu|gov|net|org","mt":"com|edu|net|org|blogspot.com","mu":"com|net|org|gov|ac|co|or","museum":"academy|agriculture|air|airguard|alabama|alaska|amber|ambulance|american|americana|americanantiques|americanart|amsterdam|and|annefrank|anthro|anthropology|antiques|aquarium|arboretum|archaeological|archaeology|architecture|art|artanddesign|artcenter|artdeco|arteducation|artgallery|arts|artsandcrafts|asmatart|assassination|assisi|association|astronomy|atlanta|austin|australia|automotive|aviation|axis|badajoz|baghdad|bahn|bale|baltimore|barcelona|baseball|basel|baths|bauern|beauxarts|beeldengeluid|bellevue|bergbau|berkeley|berlin|bern|bible|bilbao|bill|birdart|birthplace|bonn|boston|botanical|botanicalgarden|botanicgarden|botany|brandywinevalley|brasil|bristol|british|britishcolumbia|broadcast|brunel|brussel|brussels|bruxelles|building|burghof|bus|bushey|cadaques|california|cambridge|can|canada|capebreton|carrier|cartoonart|casadelamoneda|castle|castres|celtic|center|chattanooga|cheltenham|chesapeakebay|chicago|children|childrens|childrensgarden|chiropractic|chocolate|christiansburg|cincinnati|cinema|circus|civilisation|civilization|civilwar|clinton|clock|coal|coastaldefence|cody|coldwar|collection|colonialwilliamsburg|coloradoplateau|columbia|columbus|communication|communications|community|computer|computerhistory|xn--comunicaes-v6a2o|contemporary|contemporaryart|convent|copenhagen|corporation|xn--correios-e-telecomunicaes-ghc29a|corvette|costume|countryestate|county|crafts|cranbrook|creation|cultural|culturalcenter|culture|cyber|cymru|dali|dallas|database|ddr|decorativearts|delaware|delmenhorst|denmark|depot|design|detroit|dinosaur|discovery|dolls|donostia|durham|eastafrica|eastcoast|education|educational|egyptian|eisenbahn|elburg|elvendrell|embroidery|encyclopedic|england|entomology|environment|environmentalconservation|epilepsy|essex|estate|ethnology|exeter|exhibition|family|farm|farmequipment|farmers|farmstead|field|figueres|filatelia|film|fineart|finearts|finland|flanders|florida|force|fortmissoula|fortworth|foundation|francaise|frankfurt|franziskaner|freemasonry|freiburg|fribourg|frog|fundacio|furniture|gallery|garden|gateway|geelvinck|gemological|geology|georgia|giessen|glas|glass|gorge|grandrapids|graz|guernsey|halloffame|hamburg|handson|harvestcelebration|hawaii|health|heimatunduhren|hellas|helsinki|hembygdsforbund|heritage|histoire|historical|historicalsociety|historichouses|historisch|historisches|history|historyofscience|horology|house|humanities|illustration|imageandsound|indian|indiana|indianapolis|indianmarket|intelligence|interactive|iraq|iron|isleofman|jamison|jefferson|jerusalem|jewelry|jewish|jewishart|jfk|journalism|judaica|judygarland|juedisches|juif|karate|karikatur|kids|koebenhavn|koeln|kunst|kunstsammlung|kunstunddesign|labor|labour|lajolla|lancashire|landes|lans|xn--lns-qla|larsson|lewismiller|lincoln|linz|living|livinghistory|localhistory|london|losangeles|louvre|loyalist|lucerne|luxembourg|luzern|mad|madrid|mallorca|manchester|mansion|mansions|manx|marburg|maritime|maritimo|maryland|marylhurst|media|medical|medizinhistorisches|meeres|memorial|mesaverde|michigan|midatlantic|military|mill|miners|mining|minnesota|missile|missoula|modern|moma|money|monmouth|monticello|montreal|moscow|motorcycle|muenchen|muenster|mulhouse|muncie|museet|museumcenter|museumvereniging|music|national|nationalfirearms|nationalheritage|nativeamerican|naturalhistory|naturalhistorymuseum|naturalsciences|nature|naturhistorisches|natuurwetenschappen|naumburg|naval|nebraska|neues|newhampshire|newjersey|newmexico|newport|newspaper|newyork|niepce|norfolk|north|nrw|nuernberg|nuremberg|nyc|nyny|oceanographic|oceanographique|omaha|online|ontario|openair|oregon|oregontrail|otago|oxford|pacific|paderborn|palace|paleo|palmsprings|panama|paris|pasadena|pharmacy|philadelphia|philadelphiaarea|philately|phoenix|photography|pilots|pittsburgh|planetarium|plantation|plants|plaza|portal|portland|portlligat|posts-and-telecommunications|preservation|presidio|press|project|public|pubol|quebec|railroad|railway|research|resistance|riodejaneiro|rochester|rockart|roma|russia|saintlouis|salem|salvadordali|salzburg|sandiego|sanfrancisco|santabarbara|santacruz|santafe|saskatchewan|satx|savannahga|schlesisches|schoenbrunn|schokoladen|school|schweiz|science|scienceandhistory|scienceandindustry|sciencecenter|sciencecenters|science-fiction|sciencehistory|sciences|sciencesnaturelles|scotland|seaport|settlement|settlers|shell|sherbrooke|sibenik|silk|ski|skole|society|sologne|soundandvision|southcarolina|southwest|space|spy|square|stadt|stalbans|starnberg|state|stateofdelaware|station|steam|steiermark|stjohn|stockholm|stpetersburg|stuttgart|suisse|surgeonshall|surrey|svizzera|sweden|sydney|tank|tcm|technology|telekommunikation|television|texas|textile|theater|time|timekeeping|topology|torino|touch|town|transport|tree|trolley|trust|trustee|uhren|ulm|undersea|university|usa|usantiques|usarts|uscountryestate|usculture|usdecorativearts|usgarden|ushistory|ushuaia|uslivinghistory|utah|uvic|valley|vantaa|versailles|viking|village|virginia|virtual|virtuel|vlaanderen|volkenkunde|wales|wallonie|war|washingtondc|watchandclock|watch-and-clock|western|westfalen|whaling|wildlife|williamsburg|windmill|workshop|york|yorkshire|yosemite|youth|zoological|zoology|xn--9dbhblg6di|xn--h1aegh","mv":"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro","mw":"ac|biz|co|com|coop|edu|gov|int|museum|net|org","mx":"com|org|gob|edu|net|blogspot|nym","my":"com|net|org|gov|edu|mil|name|blogspot","mz":"ac|adv|co|edu|gov|mil|net|org","na":"info|pro|name|school|or|dr|us|mx|ca|in|cc|tv|ws|mobi|co|com|org","name":"forgot.her|forgot.his","nc":"asso|nom","ne":"","net":"*alwaysdata|cloudfront|t3l3p0rt|myfritz|boomla|bplaced|square7|gb|hu|jp|se|uk|in|cloudaccess|cdn77-ssl|r.cdn77|feste-ip|knx-server|static-access|*cryptonomic|at-band-camp|blogdns|broke-it|buyshouses|dnsalias|dnsdojo|does-it|dontexist|dynalias|dynathome|endofinternet|from-az|from-co|from-la|from-ny|gets-it|ham-radio-op|homeftp|homeip|homelinux|homeunix|in-the-band|is-a-chef|is-a-geek|isa-geek|kicks-ass|office-on-the|podzone|scrapper-site|selfip|sells-it|servebbs|serveftp|thruhere|webhop|definima|casacam|dynu|dynv6|twmail|ru|fastlylb|map.fastlylb|freetls.fastly|map.fastly|a.prod.fastly|global.prod.fastly|a.ssl.fastly|b.ssl.fastly|global.ssl.fastly|flynnhosting|cloudfunctions|moonscale|ipifony|barsy|azurewebsites|azure-mobile|cloudapp|eating-organic|mydissent|myeffect|mymediapc|mypsx|mysecuritycamera|nhlfan|no-ip|pgafan|privatizehealthinsurance|bounceme|ddns|redirectme|serveblog|serveminecraft|sytes|rackmaze|firewall-gateway|dsmynas|familyds|za","nf":"com|net|per|rec|web|arts|firm|info|other|store","ng":"com|edu|gov|i|mil|mobi|name|net|org|sch|blogspot.com","ni":"ac|biz|co|com|edu|gob|in|info|int|mil|net|nom|org|web","nl":"bv|virtueeldomein|co|blogspot|*transurl|cistron|demon","no":"fhs|vgs|fylkesbibl|folkebibl|museum|idrett|priv|mil|stat|dep|kommune|herad|aa|ah|bu|fm|hl|hm|jan-mayen|mr|nl|nt|of|ol|oslo|rl|sf|st|svalbard|tm|tr|va|vf|gs.aa|gs.ah|gs.bu|gs.fm|gs.hl|gs.hm|gs.jan-mayen|gs.mr|gs.nl|gs.nt|gs.of|gs.ol|gs.oslo|gs.rl|gs.sf|gs.st|gs.svalbard|gs.tm|gs.tr|gs.va|gs.vf|akrehamn|xn--krehamn-dxa|algard|xn--lgrd-poac|arna|brumunddal|bryne|bronnoysund|xn--brnnysund-m8ac|drobak|xn--drbak-wua|egersund|fetsund|floro|xn--flor-jra|fredrikstad|hokksund|honefoss|xn--hnefoss-q1a|jessheim|jorpeland|xn--jrpeland-54a|kirkenes|kopervik|krokstadelva|langevag|xn--langevg-jxa|leirvik|mjondalen|xn--mjndalen-64a|mo-i-rana|mosjoen|xn--mosjen-eya|nesoddtangen|orkanger|osoyro|xn--osyro-wua|raholt|xn--rholt-mra|sandnessjoen|xn--sandnessjen-ogb|skedsmokorset|slattum|spjelkavik|stathelle|stavern|stjordalshalsen|xn--stjrdalshalsen-sqb|tananger|tranby|vossevangen|afjord|xn--fjord-lra|agdenes|al|xn--l-1fa|alesund|xn--lesund-hua|alstahaug|alta|xn--lt-liac|alaheadju|xn--laheadju-7ya|alvdal|amli|xn--mli-tla|amot|xn--mot-tla|andebu|andoy|xn--andy-ira|andasuolo|ardal|xn--rdal-poa|aremark|arendal|xn--s-1fa|aseral|xn--seral-lra|asker|askim|askvoll|askoy|xn--asky-ira|asnes|xn--snes-poa|audnedaln|aukra|aure|aurland|aurskog-holand|xn--aurskog-hland-jnb|austevoll|austrheim|averoy|xn--avery-yua|balestrand|ballangen|balat|xn--blt-elab|balsfjord|bahccavuotna|xn--bhccavuotna-k7a|bamble|bardu|beardu|beiarn|bajddar|xn--bjddar-pta|baidar|xn--bidr-5nac|berg|bergen|berlevag|xn--berlevg-jxa|bearalvahki|xn--bearalvhki-y4a|bindal|birkenes|bjarkoy|xn--bjarky-fya|bjerkreim|bjugn|bodo|xn--bod-2na|badaddja|xn--bdddj-mrabd|budejju|bokn|bremanger|bronnoy|xn--brnny-wuac|bygland|bykle|barum|xn--brum-voa|bo.telemark|xn--b-5ga.telemark|bo.nordland|xn--b-5ga.nordland|bievat|xn--bievt-0qa|bomlo|xn--bmlo-gra|batsfjord|xn--btsfjord-9za|bahcavuotna|xn--bhcavuotna-s4a|dovre|drammen|drangedal|dyroy|xn--dyry-ira|donna|xn--dnna-gra|eid|eidfjord|eidsberg|eidskog|eidsvoll|eigersund|elverum|enebakk|engerdal|etne|etnedal|evenes|evenassi|xn--eveni-0qa01ga|evje-og-hornnes|farsund|fauske|fuossko|fuoisku|fedje|fet|finnoy|xn--finny-yua|fitjar|fjaler|fjell|flakstad|flatanger|flekkefjord|flesberg|flora|fla|xn--fl-zia|folldal|forsand|fosnes|frei|frogn|froland|frosta|frana|xn--frna-woa|froya|xn--frya-hra|fusa|fyresdal|forde|xn--frde-gra|gamvik|gangaviika|xn--ggaviika-8ya47h|gaular|gausdal|gildeskal|xn--gildeskl-g0a|giske|gjemnes|gjerdrum|gjerstad|gjesdal|gjovik|xn--gjvik-wua|gloppen|gol|gran|grane|granvin|gratangen|grimstad|grong|kraanghke|xn--kranghke-b0a|grue|gulen|hadsel|halden|halsa|hamar|hamaroy|habmer|xn--hbmer-xqa|hapmir|xn--hpmir-xqa|hammerfest|hammarfeasta|xn--hmmrfeasta-s4ac|haram|hareid|harstad|hasvik|aknoluokta|xn--koluokta-7ya57h|hattfjelldal|aarborte|haugesund|hemne|hemnes|hemsedal|heroy.more-og-romsdal|xn--hery-ira.xn--mre-og-romsdal-qqb|heroy.nordland|xn--hery-ira.nordland|hitra|hjartdal|hjelmeland|hobol|xn--hobl-ira|hof|hol|hole|holmestrand|holtalen|xn--holtlen-hxa|hornindal|horten|hurdal|hurum|hvaler|hyllestad|hagebostad|xn--hgebostad-g3a|hoyanger|xn--hyanger-q1a|hoylandet|xn--hylandet-54a|ha|xn--h-2fa|ibestad|inderoy|xn--indery-fya|iveland|jevnaker|jondal|jolster|xn--jlster-bya|karasjok|karasjohka|xn--krjohka-hwab49j|karlsoy|galsa|xn--gls-elac|karmoy|xn--karmy-yua|kautokeino|guovdageaidnu|klepp|klabu|xn--klbu-woa|kongsberg|kongsvinger|kragero|xn--krager-gya|kristiansand|kristiansund|krodsherad|xn--krdsherad-m8a|kvalsund|rahkkeravju|xn--rhkkervju-01af|kvam|kvinesdal|kvinnherad|kviteseid|kvitsoy|xn--kvitsy-fya|kvafjord|xn--kvfjord-nxa|giehtavuoatna|kvanangen|xn--kvnangen-k0a|navuotna|xn--nvuotna-hwa|kafjord|xn--kfjord-iua|gaivuotna|xn--givuotna-8ya|larvik|lavangen|lavagis|loabat|xn--loabt-0qa|lebesby|davvesiida|leikanger|leirfjord|leka|leksvik|lenvik|leangaviika|xn--leagaviika-52b|lesja|levanger|lier|lierne|lillehammer|lillesand|lindesnes|lindas|xn--linds-pra|lom|loppa|lahppi|xn--lhppi-xqa|lund|lunner|luroy|xn--lury-ira|luster|lyngdal|lyngen|ivgu|lardal|lerdal|xn--lrdal-sra|lodingen|xn--ldingen-q1a|lorenskog|xn--lrenskog-54a|loten|xn--lten-gra|malvik|masoy|xn--msy-ula0h|muosat|xn--muost-0qa|mandal|marker|marnardal|masfjorden|meland|meldal|melhus|meloy|xn--mely-ira|meraker|xn--merker-kua|moareke|xn--moreke-jua|midsund|midtre-gauldal|modalen|modum|molde|moskenes|moss|mosvik|malselv|xn--mlselv-iua|malatvuopmi|xn--mlatvuopmi-s4a|namdalseid|aejrie|namsos|namsskogan|naamesjevuemie|xn--nmesjevuemie-tcba|laakesvuemie|nannestad|narvik|narviika|naustdal|nedre-eiker|nes.akershus|nes.buskerud|nesna|nesodden|nesseby|unjarga|xn--unjrga-rta|nesset|nissedal|nittedal|nord-aurdal|nord-fron|nord-odal|norddal|nordkapp|davvenjarga|xn--davvenjrga-y4a|nordre-land|nordreisa|raisa|xn--risa-5na|nore-og-uvdal|notodden|naroy|xn--nry-yla5g|notteroy|xn--nttery-byae|odda|oksnes|xn--ksnes-uua|oppdal|oppegard|xn--oppegrd-ixa|orkdal|orland|xn--rland-uua|orskog|xn--rskog-uua|orsta|xn--rsta-fra|os.hedmark|os.hordaland|osen|osteroy|xn--ostery-fya|ostre-toten|xn--stre-toten-zcb|overhalla|ovre-eiker|xn--vre-eiker-k8a|oyer|xn--yer-zna|oygarden|xn--ygarden-p1a|oystre-slidre|xn--ystre-slidre-ujb|porsanger|porsangu|xn--porsgu-sta26f|porsgrunn|radoy|xn--rady-ira|rakkestad|rana|ruovat|randaberg|rauma|rendalen|rennebu|rennesoy|xn--rennesy-v1a|rindal|ringebu|ringerike|ringsaker|rissa|risor|xn--risr-ira|roan|rollag|rygge|ralingen|xn--rlingen-mxa|rodoy|xn--rdy-0nab|romskog|xn--rmskog-bya|roros|xn--rros-gra|rost|xn--rst-0na|royken|xn--ryken-vua|royrvik|xn--ryrvik-bya|rade|xn--rde-ula|salangen|siellak|saltdal|salat|xn--slt-elab|xn--slat-5na|samnanger|sande.more-og-romsdal|sande.xn--mre-og-romsdal-qqb|sande.vestfold|sandefjord|sandnes|sandoy|xn--sandy-yua|sarpsborg|sauda|sauherad|sel|selbu|selje|seljord|sigdal|siljan|sirdal|skaun|skedsmo|ski|skien|skiptvet|skjervoy|xn--skjervy-v1a|skierva|xn--skierv-uta|skjak|xn--skjk-soa|skodje|skanland|xn--sknland-fxa|skanit|xn--sknit-yqa|smola|xn--smla-hra|snillfjord|snasa|xn--snsa-roa|snoasa|snaase|xn--snase-nra|sogndal|sokndal|sola|solund|songdalen|sortland|spydeberg|stange|stavanger|steigen|steinkjer|stjordal|xn--stjrdal-s1a|stokke|stor-elvdal|stord|stordal|storfjord|omasvuotna|strand|stranda|stryn|sula|suldal|sund|sunndal|surnadal|sveio|svelvik|sykkylven|sogne|xn--sgne-gra|somna|xn--smna-gra|sondre-land|xn--sndre-land-0cb|sor-aurdal|xn--sr-aurdal-l8a|sor-fron|xn--sr-fron-q1a|sor-odal|xn--sr-odal-q1a|sor-varanger|xn--sr-varanger-ggb|matta-varjjat|xn--mtta-vrjjat-k7af|sorfold|xn--srfold-bya|sorreisa|xn--srreisa-q1a|sorum|xn--srum-gra|tana|deatnu|time|tingvoll|tinn|tjeldsund|dielddanuorri|tjome|xn--tjme-hra|tokke|tolga|torsken|tranoy|xn--trany-yua|tromso|xn--troms-zua|tromsa|romsa|trondheim|troandin|trysil|trana|xn--trna-woa|trogstad|xn--trgstad-r1a|tvedestrand|tydal|tynset|tysfjord|divtasvuodna|divttasvuotna|tysnes|tysvar|xn--tysvr-vra|tonsberg|xn--tnsberg-q1a|ullensaker|ullensvang|ulvik|utsira|vadso|xn--vads-jra|cahcesuolo|xn--hcesuolo-7ya35b|vaksdal|valle|vang|vanylven|vardo|xn--vard-jra|varggat|xn--vrggt-xqad|vefsn|vaapste|vega|vegarshei|xn--vegrshei-c0a|vennesla|verdal|verran|vestby|vestnes|vestre-slidre|vestre-toten|vestvagoy|xn--vestvgy-ixa6o|vevelstad|vik|vikna|vindafjord|volda|voss|varoy|xn--vry-yla5g|vagan|xn--vgan-qoa|voagat|vagsoy|xn--vgsy-qoa0j|vaga|xn--vg-yiab|valer.ostfold|xn--vler-qoa.xn--stfold-9xa|valer.hedmark|xn--vler-qoa.hedmark|co|blogspot","np":"*","nr":"biz|info|gov|edu|org|net|com","nu":"merseine|mine|shacknet|nom","nz":"ac|co|cri|geek|gen|govt|health|iwi|kiwi|maori|mil|xn--mori-qsa|net|org|parliament|school|blogspot.co|nym","om":"co|com|edu|gov|med|museum|net|org|pro","onion":"","org":"tele.amune|pimienta|poivron|potager|sweetpepper|ae|us|certmgr|c.cdn77|rsc.cdn77|ssl.origin.cdn77-secure|cloudns|duckdns|tunk|dyndns|blogdns|blogsite|boldlygoingnowhere|dnsalias|dnsdojo|doesntexist|dontexist|doomdns|dvrdns|dynalias|endofinternet|endoftheinternet|from-me|game-host|go.dyndns|gotdns|hobby-site|home.dyndns|homedns|homeftp|homelinux|homeunix|is-a-bruinsfan|is-a-candidate|is-a-celticsfan|is-a-chef|is-a-geek|is-a-knight|is-a-linux-user|is-a-patsfan|is-a-soxfan|is-found|is-lost|is-saved|is-very-bad|is-very-evil|is-very-good|is-very-nice|is-very-sweet|isa-geek|kicks-ass|misconfused|podzone|readmyblog|selfip|sellsyourhome|servebbs|serveftp|servegame|stuff-4-sale|webhop|ddnss|accesscam|camdvr|freeddns|mywire|webredirect|eu|al.eu|asso.eu|at.eu|au.eu|be.eu|bg.eu|ca.eu|cd.eu|ch.eu|cn.eu|cy.eu|cz.eu|de.eu|dk.eu|edu.eu|ee.eu|es.eu|fi.eu|fr.eu|gr.eu|hr.eu|hu.eu|ie.eu|il.eu|in.eu|int.eu|is.eu|it.eu|jp.eu|kr.eu|lt.eu|lu.eu|lv.eu|mc.eu|me.eu|mk.eu|mt.eu|my.eu|net.eu|ng.eu|nl.eu|no.eu|nz.eu|paris.eu|pl.eu|pt.eu|q-a.eu|ro.eu|ru.eu|se.eu|si.eu|sk.eu|tr.eu|uk.eu|us.eu|twmail|fedorainfracloud|fedorapeople|cloud.fedoraproject|hepforge|js|bmoattachments|cable-modem|collegefan|couchpotatofries|mlbfan|mysecuritycamera|nflfan|read-books|ufcfan|hopto|myftp|no-ip|zapto|my-firewall|myfirewall|spdns|dsmynas|familyds|tuxfamily|diskstation|hk|wmflabs|za","pa":"ac|gob|com|org|sld|edu|net|ing|abo|med|nom","pe":"edu|gob|nom|mil|org|com|net|blogspot|nym","pf":"com|org|edu","pg":"*","ph":"com|net|org|gov|edu|ngo|mil|i","pk":"com|net|edu|org|fam|biz|web|gov|gob|gok|gon|gop|gos|info","pl":"com|net|org|aid|agro|atm|auto|biz|edu|gmina|gsm|info|mail|miasta|media|mil|nieruchomosci|nom|pc|powiat|priv|realestate|rel|sex|shop|sklep|sos|szkola|targi|tm|tourism|travel|turystyka|gov|ap.gov|ic.gov|is.gov|us.gov|kmpsp.gov|kppsp.gov|kwpsp.gov|psp.gov|wskr.gov|kwp.gov|mw.gov|ug.gov|um.gov|umig.gov|ugim.gov|upow.gov|uw.gov|starostwo.gov|pa.gov|po.gov|psse.gov|pup.gov|rzgw.gov|sa.gov|so.gov|sr.gov|wsa.gov|sko.gov|uzs.gov|wiih.gov|winb.gov|pinb.gov|wios.gov|witd.gov|wzmiuw.gov|piw.gov|wiw.gov|griw.gov|wif.gov|oum.gov|sdn.gov|zp.gov|uppo.gov|mup.gov|wuoz.gov|konsulat.gov|oirm.gov|augustow|babia-gora|bedzin|beskidy|bialowieza|bialystok|bielawa|bieszczady|boleslawiec|bydgoszcz|bytom|cieszyn|czeladz|czest|dlugoleka|elblag|elk|glogow|gniezno|gorlice|grajewo|ilawa|jaworzno|jelenia-gora|jgora|kalisz|kazimierz-dolny|karpacz|kartuzy|kaszuby|katowice|kepno|ketrzyn|klodzko|kobierzyce|kolobrzeg|konin|konskowola|kutno|lapy|lebork|legnica|lezajsk|limanowa|lomza|lowicz|lubin|lukow|malbork|malopolska|mazowsze|mazury|mielec|mielno|mragowo|naklo|nowaruda|nysa|olawa|olecko|olkusz|olsztyn|opoczno|opole|ostroda|ostroleka|ostrowiec|ostrowwlkp|pila|pisz|podhale|podlasie|polkowice|pomorze|pomorskie|prochowice|pruszkow|przeworsk|pulawy|radom|rawa-maz|rybnik|rzeszow|sanok|sejny|slask|slupsk|sosnowiec|stalowa-wola|skoczow|starachowice|stargard|suwalki|swidnica|swiebodzin|swinoujscie|szczecin|szczytno|tarnobrzeg|tgory|turek|tychy|ustka|walbrzych|warmia|warszawa|waw|wegrow|wielun|wlocl|wloclawek|wodzislaw|wolomin|wroclaw|zachpomor|zagan|zarow|zgora|zgorzelec|beep|co|art|gliwice|krakow|poznan|wroc|zakopane|gda|gdansk|gdynia|med|sopot","pm":"","pn":"gov|co|org|edu|net","post":"","pr":"com|net|org|gov|edu|isla|pro|biz|info|name|est|prof|ac","pro":"aaa|aca|acct|avocat|bar|cpa|eng|jur|law|med|recht|cloudns","ps":"edu|gov|sec|plo|com|org|net","pt":"net|gov|org|edu|int|publ|com|nome|blogspot|nym","pw":"co|ne|or|ed|go|belau|cloudns|nom","py":"com|coop|edu|gov|mil|net|org","qa":"com|edu|gov|mil|name|net|org|sch|blogspot|nom","re":"asso|com|nom|blogspot","ro":"arts|com|firm|info|nom|nt|org|rec|store|tm|www|shop|blogspot","rs":"ac|co|edu|gov|in|org|blogspot|nom","ru":"ac|edu|gov|int|mil|test|adygeya|bashkiria|bir|cbg|com|dagestan|grozny|kalmykia|kustanai|marine|mordovia|msk|mytis|nalchik|nov|pyatigorsk|spb|vladikavkaz|vladimir|blogspot|hb.cldmail|net|org|pp","rw":"gov|net|edu|ac|com|co|int|mil|gouv","sa":"com|net|org|gov|med|pub|edu|sch","sb":"com|edu|gov|net|org","sc":"com|gov|net|org|edu","sd":"com|net|org|edu|med|tv|gov|info","se":"a|ac|b|bd|brand|c|d|e|f|fh|fhsk|fhv|g|h|i|k|komforb|kommunalforbund|komvux|l|lanbib|m|n|naturbruksgymn|o|org|p|parti|pp|press|r|s|t|tm|u|w|x|y|z|com|blogspot","sg":"com|net|org|gov|edu|per|blogspot","sh":"com|net|gov|org|mil|hashbang|*platform|now","si":"blogspot|nom","sj":"","sk":"blogspot|nym","sl":"com|net|edu|gov|org","sm":"","sn":"art|com|edu|gouv|org|perso|univ|blogspot","so":"com|net|org","sr":"","st":"co|com|consulado|edu|embaixada|gov|mil|net|org|principe|saotome|store","su":"abkhazia|adygeya|aktyubinsk|arkhangelsk|armenia|ashgabad|azerbaijan|balashov|bashkiria|bryansk|bukhara|chimkent|dagestan|east-kazakhstan|exnet|georgia|grozny|ivanovo|jambyl|kalmykia|kaluga|karacol|karaganda|karelia|khakassia|krasnodar|kurgan|kustanai|lenug|mangyshlak|mordovia|msk|murmansk|nalchik|navoi|north-kazakhstan|nov|obninsk|penza|pokrovsk|sochi|spb|tashkent|termez|togliatti|troitsk|tselinograd|tula|tuva|vladikavkaz|vladimir|vologda|nym","sv":"com|edu|gob|org|red","sx":"gov|nym","sy":"edu|gov|net|mil|com|org","sz":"co|ac|org","tc":"","td":"blogspot","tel":"","tf":"","tg":"","th":"ac|co|go|in|mi|net|or","tj":"ac|biz|co|com|edu|go|gov|int|mil|name|net|nic|org|test|web","tk":"","tl":"gov","tm":"com|co|org|net|nom|gov|mil|edu","tn":"com|ens|fin|gov|ind|intl|nat|net|org|info|perso|tourism|edunet|rnrt|rns|rnu|mincom|agrinet|defense|turen","to":"com|gov|net|org|edu|mil|vpnplus","tr":"com|info|biz|net|org|web|gen|tv|av|dr|bbs|name|tel|gov|bel|pol|mil|k12|edu|kep|nc|gov.nc|blogspot.com","travel":"","tt":"co|com|org|net|biz|info|pro|int|coop|jobs|mobi|travel|museum|aero|name|gov|edu","tv":"dyndns|better-than|on-the-web|worse-than","tw":"edu|gov|mil|com|net|org|idv|game|ebiz|club|xn--zf0ao64a|xn--uc0atv|xn--czrw28b|mymailer.com|url|blogspot|nym","tz":"ac|co|go|hotel|info|me|mil|mobi|ne|or|sc|tv","ua":"com|edu|gov|in|net|org|cherkassy|cherkasy|chernigov|chernihiv|chernivtsi|chernovtsy|ck|cn|cr|crimea|cv|dn|dnepropetrovsk|dnipropetrovsk|dominic|donetsk|dp|if|ivano-frankivsk|kh|kharkiv|kharkov|kherson|khmelnitskiy|khmelnytskyi|kiev|kirovograd|km|kr|krym|ks|kv|kyiv|lg|lt|lugansk|lutsk|lv|lviv|mk|mykolaiv|nikolaev|od|odesa|odessa|pl|poltava|rivne|rovno|rv|sb|sebastopol|sevastopol|sm|sumy|te|ternopil|uz|uzhgorod|vinnica|vinnytsia|vn|volyn|yalta|zaporizhzhe|zaporizhzhia|zhitomir|zhytomyr|zp|zt|cc|inf|ltd|biz|co|pp","ug":"co|or|ac|sc|go|ne|com|org|blogspot|nom","uk":"ac|co|gov|ltd|me|net|nhs|org|plc|police|*sch|service.gov|homeoffice.gov|blogspot.co|no-ip.co|wellbeingzone.co","us":"dni|fed|isa|kids|nsn|ak|al|ar|as|az|ca|co|ct|dc|de|fl|ga|gu|hi|ia|id|il|in|ks|ky|la|ma|md|me|mi|mn|mo|ms|mt|nc|nd|ne|nh|nj|nm|nv|ny|oh|ok|or|pa|pr|ri|sc|sd|tn|tx|ut|vi|vt|va|wa|wi|wv|wy|k12.ak|k12.al|k12.ar|k12.as|k12.az|k12.ca|k12.co|k12.ct|k12.dc|k12.de|k12.fl|k12.ga|k12.gu|k12.ia|k12.id|k12.il|k12.in|k12.ks|k12.ky|k12.la|k12.ma|k12.md|k12.me|k12.mi|k12.mn|k12.mo|k12.ms|k12.mt|k12.nc|k12.ne|k12.nh|k12.nj|k12.nm|k12.nv|k12.ny|k12.oh|k12.ok|k12.or|k12.pa|k12.pr|k12.ri|k12.sc|k12.tn|k12.tx|k12.ut|k12.vi|k12.vt|k12.va|k12.wa|k12.wi|k12.wy|cc.ak|cc.al|cc.ar|cc.as|cc.az|cc.ca|cc.co|cc.ct|cc.dc|cc.de|cc.fl|cc.ga|cc.gu|cc.hi|cc.ia|cc.id|cc.il|cc.in|cc.ks|cc.ky|cc.la|cc.ma|cc.md|cc.me|cc.mi|cc.mn|cc.mo|cc.ms|cc.mt|cc.nc|cc.nd|cc.ne|cc.nh|cc.nj|cc.nm|cc.nv|cc.ny|cc.oh|cc.ok|cc.or|cc.pa|cc.pr|cc.ri|cc.sc|cc.sd|cc.tn|cc.tx|cc.ut|cc.vi|cc.vt|cc.va|cc.wa|cc.wi|cc.wv|cc.wy|lib.ak|lib.al|lib.ar|lib.as|lib.az|lib.ca|lib.co|lib.ct|lib.dc|lib.fl|lib.ga|lib.gu|lib.hi|lib.ia|lib.id|lib.il|lib.in|lib.ks|lib.ky|lib.la|lib.ma|lib.md|lib.me|lib.mi|lib.mn|lib.mo|lib.ms|lib.mt|lib.nc|lib.nd|lib.ne|lib.nh|lib.nj|lib.nm|lib.nv|lib.ny|lib.oh|lib.ok|lib.or|lib.pa|lib.pr|lib.ri|lib.sc|lib.sd|lib.tn|lib.tx|lib.ut|lib.vi|lib.vt|lib.va|lib.wa|lib.wi|lib.wy|pvt.k12.ma|chtr.k12.ma|paroch.k12.ma|cloudns|drud|is-by|land-4-sale|stuff-4-sale|golffan|noip|pointto|lib.de","uy":"com|edu|gub|mil|net|org|blogspot.com|nom","uz":"co|com|net|org","va":"","vc":"com|net|org|gov|mil|edu|nom","ve":"arts|co|com|e12|edu|firm|gob|gov|info|int|mil|net|org|rec|store|tec|web","vg":"nom","vi":"co|com|k12|net|org","vn":"com|net|org|edu|gov|int|ac|biz|info|name|pro|health|blogspot","vu":"com|edu|net|org","wf":"","ws":"com|net|org|gov|edu|*advisor|dyndns|mypets","yt":"","xn--mgbaam7a8h":"","xn--y9a3aq":"","xn--54b7fta0cc":"","xn--90ae":"","xn--90ais":"","xn--fiqs8s":"","xn--fiqz9s":"","xn--lgbbat1ad8j":"","xn--wgbh1c":"","xn--e1a4c":"","xn--node":"","xn--qxam":"","xn--j6w193g":"","xn--2scrj9c":"","xn--3hcrj9c":"","xn--45br5cyl":"","xn--h2breg3eve":"","xn--h2brj9c8c":"","xn--mgbgu82a":"","xn--rvc1e0am3e":"","xn--h2brj9c":"","xn--mgbbh1a71e":"","xn--fpcrj9c3d":"","xn--gecrj9c":"","xn--s9brj9c":"","xn--45brj9c":"","xn--xkc2dl3a5ee0h":"","xn--mgba3a4f16a":"","xn--mgba3a4fra":"","xn--mgbtx2b":"","xn--mgbayh7gpa":"","xn--3e0b707e":"","xn--80ao21a":"","xn--fzc2c9e2c":"","xn--xkc2al3hye2a":"","xn--mgbc0a9azcg":"","xn--d1alf":"","xn--l1acc":"","xn--mix891f":"","xn--mix082f":"","xn--mgbx4cd0ab":"","xn--mgb9awbf":"","xn--mgbai9azgqp6j":"","xn--mgbai9a5eva00b":"","xn--ygbi2ammx":"","xn--90a3ac":"xn--o1ac|xn--c1avg|xn--90azh|xn--d1at|xn--o1ach|xn--80au","xn--p1ai":"","xn--wgbl6a":"","xn--mgberp4a5d4ar":"","xn--mgberp4a5d4a87g":"","xn--mgbqly7c0a67fbc":"","xn--mgbqly7cvafr":"","xn--mgbpl2fh":"","xn--yfro4i67o":"","xn--clchc0ea0b2g2a9gcd":"","xn--ogbpf8fl":"","xn--mgbtf8fl":"","xn--o3cw4h":"xn--12c1fe0br|xn--12co0c3b4eva|xn--h3cuzk1di|xn--o3cyx2a|xn--m3ch0j3a|xn--12cfi8ixb8l","xn--pgbs0dh":"","xn--kpry57d":"","xn--kprw13d":"","xn--nnx388a":"","xn--j1amh":"","xn--mgb2ddes":"","xxx":"","ye":"*","za":"ac|agric|alt|co|edu|gov|grondar|law|mil|net|ngo|nis|nom|org|school|tm|web|blogspot.co","zm":"ac|biz|co|com|edu|gov|info|mil|net|org|sch","zw":"ac|co|gov|mil|org","aaa":"","aarp":"","abarth":"","abb":"","abbott":"","abbvie":"","abc":"","able":"","abogado":"","abudhabi":"","academy":"","accenture":"","accountant":"","accountants":"","aco":"","active":"","actor":"","adac":"","ads":"","adult":"","aeg":"","aetna":"","afamilycompany":"","afl":"","africa":"","agakhan":"","agency":"","aig":"","aigo":"","airbus":"","airforce":"","airtel":"","akdn":"","alfaromeo":"","alibaba":"","alipay":"","allfinanz":"","allstate":"","ally":"","alsace":"","alstom":"","americanexpress":"","americanfamily":"","amex":"","amfam":"","amica":"","amsterdam":"","analytics":"","android":"","anquan":"","anz":"","aol":"","apartments":"","app":"","apple":"","aquarelle":"","arab":"","aramco":"","archi":"","army":"","art":"","arte":"","asda":"","associates":"","athleta":"","attorney":"","auction":"","audi":"","audible":"","audio":"","auspost":"","author":"","auto":"","autos":"","avianca":"","aws":"","axa":"","azure":"","baby":"","baidu":"","banamex":"","bananarepublic":"","band":"","bank":"","bar":"","barcelona":"","barclaycard":"","barclays":"","barefoot":"","bargains":"","baseball":"","basketball":"","bauhaus":"","bayern":"","bbc":"","bbt":"","bbva":"","bcg":"","bcn":"","beats":"","beauty":"","beer":"","bentley":"","berlin":"","best":"","bestbuy":"","bet":"","bharti":"","bible":"","bid":"","bike":"","bing":"","bingo":"","bio":"","black":"","blackfriday":"","blanco":"","blockbuster":"","blog":"","bloomberg":"","blue":"","bms":"","bmw":"","bnl":"","bnpparibas":"","boats":"","boehringer":"","bofa":"","bom":"","bond":"","boo":"","book":"","booking":"","boots":"","bosch":"","bostik":"","boston":"","bot":"","boutique":"","box":"","bradesco":"","bridgestone":"","broadway":"","broker":"","brother":"","brussels":"","budapest":"","bugatti":"","build":"","builders":"","business":"","buy":"","buzz":"","bzh":"","cab":"","cafe":"","cal":"","call":"","calvinklein":"","cam":"","camera":"","camp":"","cancerresearch":"","canon":"","capetown":"","capital":"","capitalone":"","car":"","caravan":"","cards":"","care":"","career":"","careers":"","cars":"","cartier":"","casa":"","case":"","caseih":"","cash":"","casino":"","catering":"","catholic":"","cba":"","cbn":"","cbre":"","cbs":"","ceb":"","center":"","ceo":"","cern":"","cfa":"","cfd":"","chanel":"","channel":"","chase":"","chat":"","cheap":"","chintai":"","chloe":"","christmas":"","chrome":"","chrysler":"","church":"","cipriani":"","circle":"","cisco":"","citadel":"","citi":"","citic":"","city":"","cityeats":"","claims":"","cleaning":"","click":"","clinic":"","clinique":"","clothing":"","cloud":"myfusion|*statics|*magentosite|vapor|*sensiosite|trafficplex","club":"cloudns","clubmed":"","coach":"","codes":"","coffee":"","college":"","cologne":"","comcast":"","commbank":"","community":"","company":"","compare":"","computer":"","comsec":"","condos":"","construction":"","consulting":"","contact":"","contractors":"","cooking":"","cookingchannel":"","cool":"de","corsica":"","country":"","coupon":"","coupons":"","courses":"","credit":"","creditcard":"","creditunion":"","cricket":"","crown":"","crs":"","cruise":"","cruises":"","csc":"","cuisinella":"","cymru":"","cyou":"","dabur":"","dad":"","dance":"","data":"","date":"","dating":"","datsun":"","day":"","dclk":"","dds":"","deal":"","dealer":"","deals":"","degree":"","delivery":"","dell":"","deloitte":"","delta":"","democrat":"","dental":"","dentist":"","desi":"","design":"","dev":"","dhl":"","diamonds":"","diet":"","digital":"","direct":"","directory":"","discount":"","discover":"","dish":"","diy":"","dnp":"","docs":"","doctor":"","dodge":"","dog":"","doha":"","domains":"","dot":"","download":"","drive":"","dtv":"","dubai":"","duck":"","dunlop":"","duns":"","dupont":"","durban":"","dvag":"","dvr":"","earth":"","eat":"","eco":"","edeka":"","education":"","email":"","emerck":"","energy":"","engineer":"","engineering":"","enterprises":"","epost":"","epson":"","equipment":"","ericsson":"","erni":"","esq":"","estate":"*compute","esurance":"","etisalat":"","eurovision":"","eus":"user.party","events":"","everbank":"","exchange":"","expert":"","exposed":"","express":"","extraspace":"","fage":"","fail":"","fairwinds":"","faith":"ybo","family":"","fan":"","fans":"","farm":"storj","farmers":"","fashion":"","fast":"","fedex":"","feedback":"","ferrari":"","ferrero":"","fiat":"","fidelity":"","fido":"","film":"","final":"","finance":"","financial":"","fire":"","firestone":"","firmdale":"","fish":"","fishing":"","fit":"ptplus","fitness":"","flickr":"","flights":"","flir":"","florist":"","flowers":"","fly":"","foo":"","food":"","foodnetwork":"","football":"","ford":"","forex":"","forsale":"","forum":"","foundation":"","fox":"","free":"","fresenius":"","frl":"","frogans":"","frontdoor":"","frontier":"","ftr":"","fujitsu":"","fujixerox":"","fun":"","fund":"","furniture":"","futbol":"","fyi":"","gal":"","gallery":"","gallo":"","gallup":"","game":"","games":"","gap":"","garden":"","gbiz":"","gdn":"","gea":"","gent":"","genting":"","george":"","ggee":"","gift":"","gifts":"","gives":"","giving":"","glade":"","glass":"","gle":"","global":"","globo":"","gmail":"","gmbh":"","gmo":"","gmx":"","godaddy":"","gold":"","goldpoint":"","golf":"","goo":"","goodhands":"","goodyear":"","goog":"cloud","google":"","gop":"","got":"","grainger":"","graphics":"","gratis":"","green":"","gripe":"","grocery":"","group":"","guardian":"","gucci":"","guge":"","guide":"","guitars":"","guru":"","hair":"","hamburg":"","hangout":"","haus":"","hbo":"","hdfc":"","hdfcbank":"","health":"","healthcare":"","help":"","helsinki":"","here":"","hermes":"","hgtv":"","hiphop":"","hisamitsu":"","hitachi":"","hiv":"","hkt":"","hockey":"","holdings":"","holiday":"","homedepot":"","homegoods":"","homes":"","homesense":"","honda":"","honeywell":"","horse":"","hospital":"","host":"cloudaccess|freesite","hosting":"opencraft","hot":"","hoteles":"","hotels":"","hotmail":"","house":"","how":"","hsbc":"","htc":"","hughes":"","hyatt":"","hyundai":"","ibm":"","icbc":"","ice":"","icu":"","ieee":"","ifm":"","ikano":"","imamat":"","imdb":"","immo":"","immobilien":"","industries":"","infiniti":"","ing":"","ink":"","institute":"","insurance":"","insure":"","intel":"","international":"","intuit":"","investments":"","ipiranga":"","irish":"","iselect":"","ismaili":"","ist":"","istanbul":"","itau":"","itv":"","iveco":"","iwc":"","jaguar":"","java":"","jcb":"","jcp":"","jeep":"","jetzt":"","jewelry":"","jio":"","jlc":"","jll":"","jmp":"","jnj":"","joburg":"","jot":"","joy":"","jpmorgan":"","jprs":"","juegos":"","juniper":"","kaufen":"","kddi":"","kerryhotels":"","kerrylogistics":"","kerryproperties":"","kfh":"","kia":"","kim":"","kinder":"","kindle":"","kitchen":"","kiwi":"","koeln":"","komatsu":"","kosher":"","kpmg":"","kpn":"","krd":"co|edu","kred":"","kuokgroup":"","kyoto":"","lacaixa":"","ladbrokes":"","lamborghini":"","lamer":"","lancaster":"","lancia":"","lancome":"","land":"static|dev.static|sites.static","landrover":"","lanxess":"","lasalle":"","lat":"","latino":"","latrobe":"","law":"","lawyer":"","lds":"","lease":"","leclerc":"","lefrak":"","legal":"","lego":"","lexus":"","lgbt":"","liaison":"","lidl":"","life":"","lifeinsurance":"","lifestyle":"","lighting":"","like":"","lilly":"","limited":"","limo":"","lincoln":"","linde":"","link":"cyon|mypep","lipsy":"","live":"","living":"","lixil":"","loan":"","loans":"","locker":"","locus":"","loft":"","lol":"","london":"","lotte":"","lotto":"","love":"","lpl":"","lplfinancial":"","ltd":"","ltda":"","lundbeck":"","lupin":"","luxe":"","luxury":"","macys":"","madrid":"","maif":"","maison":"","makeup":"","man":"","management":"router","mango":"","map":"","market":"","marketing":"","markets":"","marriott":"","marshalls":"","maserati":"","mattel":"","mba":"","mcd":"","mcdonalds":"","mckinsey":"","med":"","media":"","meet":"","melbourne":"","meme":"","memorial":"","men":"","menu":"","meo":"","merckmsd":"","metlife":"","miami":"","microsoft":"","mini":"","mint":"","mit":"","mitsubishi":"","mlb":"","mls":"","mma":"","mobile":"","mobily":"","moda":"","moe":"","moi":"","mom":"","monash":"","money":"","monster":"","montblanc":"","mopar":"","mormon":"","mortgage":"","moscow":"","moto":"","motorcycles":"","mov":"","movie":"","movistar":"","msd":"","mtn":"","mtpc":"","mtr":"","mutual":"","nab":"","nadex":"","nagoya":"","nationwide":"","natura":"","navy":"","nba":"","nec":"","netbank":"","netflix":"","network":"*alces","neustar":"","new":"","newholland":"","news":"","next":"","nextdirect":"","nexus":"","nfl":"","ngo":"","nhk":"","nico":"","nike":"","nikon":"","ninja":"","nissan":"","nissay":"","nokia":"","northwesternmutual":"","norton":"","now":"","nowruz":"","nowtv":"","nra":"","nrw":"","ntt":"","nyc":"","obi":"","observer":"","off":"","office":"","okinawa":"","olayan":"","olayangroup":"","oldnavy":"","ollo":"","omega":"","one":"homelink","ong":"","onl":"","online":"barsy","onyourside":"","ooo":"","open":"","oracle":"","orange":"","organic":"","origins":"","osaka":"","otsuka":"","ott":"","ovh":"nerdpol","page":"","pamperedchef":"","panasonic":"","panerai":"","paris":"","pars":"","partners":"","parts":"","party":"ybo","passagens":"","pay":"","pccw":"","pet":"","pfizer":"","pharmacy":"","phd":"","philips":"","phone":"","photo":"","photography":"","photos":"","physio":"","piaget":"","pics":"","pictet":"","pictures":"1337","pid":"","pin":"","ping":"","pink":"","pioneer":"","pizza":"","place":"","play":"","playstation":"","plumbing":"","plus":"","pnc":"","pohl":"","poker":"","politie":"","porn":"","pramerica":"","praxi":"","press":"","prime":"","prod":"","productions":"","prof":"","progressive":"","promo":"","properties":"","property":"","protection":"","pru":"","prudential":"","pub":"","pwc":"","qpon":"","quebec":"","quest":"","qvc":"","racing":"","radio":"","raid":"","read":"","realestate":"","realtor":"","realty":"","recipes":"","red":"","redstone":"","redumbrella":"","rehab":"","reise":"","reisen":"","reit":"","reliance":"","ren":"","rent":"","rentals":"","repair":"","report":"","republican":"","rest":"","restaurant":"","review":"ybo","reviews":"","rexroth":"","rich":"","richardli":"","ricoh":"","rightathome":"","ril":"","rio":"","rip":"clan","rmit":"","rocher":"","rocks":"myddns|lima-city|webspace","rodeo":"","rogers":"","room":"","rsvp":"","rugby":"","ruhr":"","run":"","rwe":"","ryukyu":"","saarland":"","safe":"","safety":"","sakura":"","sale":"","salon":"","samsclub":"","samsung":"","sandvik":"","sandvikcoromant":"","sanofi":"","sap":"","sapo":"","sarl":"","sas":"","save":"","saxo":"","sbi":"","sbs":"","sca":"","scb":"","schaeffler":"","schmidt":"","scholarships":"","school":"","schule":"","schwarz":"","science":"ybo","scjohnson":"","scor":"","scot":"","search":"","seat":"","secure":"","security":"","seek":"","select":"","sener":"","services":"","ses":"","seven":"","sew":"","sex":"","sexy":"","sfr":"","shangrila":"","sharp":"","shaw":"","shell":"","shia":"","shiksha":"","shoes":"","shop":"","shopping":"","shouji":"","show":"","showtime":"","shriram":"","silk":"","sina":"","singles":"","site":"cyon|*platformsh","ski":"","skin":"","sky":"","skype":"","sling":"","smart":"","smile":"","sncf":"","soccer":"","social":"","softbank":"","software":"","sohu":"","solar":"","solutions":"","song":"","sony":"","soy":"","space":"stackspace|uber|xs4all","spiegel":"","spot":"","spreadbetting":"","srl":"","srt":"","stada":"","staples":"","star":"","starhub":"","statebank":"","statefarm":"","statoil":"","stc":"","stcgroup":"","stockholm":"","storage":"","store":"","stream":"","studio":"","study":"","style":"","sucks":"","supplies":"","supply":"","support":"barsy","surf":"","surgery":"","suzuki":"","swatch":"","swiftcover":"","swiss":"","sydney":"","symantec":"","systems":"knightpoint","tab":"","taipei":"","talk":"","taobao":"","target":"","tatamotors":"","tatar":"","tattoo":"","tax":"","taxi":"","tci":"","tdk":"","team":"","tech":"","technology":"","telecity":"","telefonica":"","temasek":"","tennis":"","teva":"","thd":"","theater":"","theatre":"","tiaa":"","tickets":"","tienda":"","tiffany":"","tips":"","tires":"","tirol":"","tjmaxx":"","tjx":"","tkmaxx":"","tmall":"","today":"","tokyo":"","tools":"","top":"","toray":"","toshiba":"","total":"","tours":"","town":"","toyota":"","toys":"","trade":"ybo","trading":"","training":"","travelchannel":"","travelers":"","travelersinsurance":"","trust":"","trv":"","tube":"","tui":"","tunes":"","tushu":"","tvs":"","ubank":"","ubs":"","uconnect":"","unicom":"","university":"","uno":"","uol":"","ups":"","vacations":"","vana":"","vanguard":"","vegas":"","ventures":"","verisign":"","versicherung":"","vet":"","viajes":"","video":"","vig":"","viking":"","villas":"","vin":"","vip":"","virgin":"","visa":"","vision":"","vista":"","vistaprint":"","viva":"","vivo":"","vlaanderen":"","vodka":"","volkswagen":"","volvo":"","vote":"","voting":"","voto":"","voyage":"","vuelos":"","wales":"","walmart":"","walter":"","wang":"","wanggou":"","warman":"","watch":"","watches":"","weather":"","weatherchannel":"","webcam":"","weber":"","website":"","wed":"","wedding":"","weibo":"","weir":"","whoswho":"","wien":"","wiki":"","williamhill":"","win":"","windows":"","wine":"","winners":"","wme":"","wolterskluwer":"","woodside":"","work":"","works":"","world":"","wow":"","wtc":"","wtf":"","xbox":"","xerox":"","xfinity":"","xihuan":"","xin":"","xn--11b4c3d":"","xn--1ck2e1b":"","xn--1qqw23a":"","xn--30rr7y":"","xn--3bst00m":"","xn--3ds443g":"","xn--3oq18vl8pn36a":"","xn--3pxu8k":"","xn--42c2d9a":"","xn--45q11c":"","xn--4gbrim":"","xn--55qw42g":"","xn--55qx5d":"","xn--5su34j936bgsg":"","xn--5tzm5g":"","xn--6frz82g":"","xn--6qq986b3xl":"","xn--80adxhks":"","xn--80aqecdr1a":"","xn--80asehdb":"","xn--80aswg":"","xn--8y0a063a":"","xn--9dbq2a":"","xn--9et52u":"","xn--9krt00a":"","xn--b4w605ferd":"","xn--bck1b9a5dre4c":"","xn--c1avg":"","xn--c2br7g":"","xn--cck2b3b":"","xn--cg4bki":"","xn--czr694b":"","xn--czrs0t":"","xn--czru2d":"","xn--d1acj3b":"","xn--eckvdtc9d":"","xn--efvy88h":"","xn--estv75g":"","xn--fct429k":"","xn--fhbei":"","xn--fiq228c5hs":"","xn--fiq64b":"","xn--fjq720a":"","xn--flw351e":"","xn--fzys8d69uvgm":"","xn--g2xx48c":"","xn--gckr3f0f":"","xn--gk3at1e":"","xn--hxt814e":"","xn--i1b6b1a6a2e":"","xn--imr513n":"","xn--io0a7i":"","xn--j1aef":"","xn--jlq61u9w7b":"","xn--jvr189m":"","xn--kcrx77d1x4a":"","xn--kpu716f":"","xn--kput3i":"","xn--mgba3a3ejt":"","xn--mgba7c0bbn0a":"","xn--mgbaakc7dvf":"","xn--mgbab2bd":"","xn--mgbb9fbpob":"","xn--mgbca7dzdo":"","xn--mgbi4ecexp":"","xn--mgbt3dhd":"","xn--mk1bu44c":"","xn--mxtq1m":"","xn--ngbc5azd":"","xn--ngbe9e0a":"","xn--ngbrx":"","xn--nqv7f":"","xn--nqv7fs00ema":"","xn--nyqy26a":"","xn--p1acf":"","xn--pbt977c":"","xn--pssy2u":"","xn--q9jyb4c":"","xn--qcka1pmc":"","xn--rhqv96g":"","xn--rovu88b":"","xn--ses554g":"","xn--t60b56a":"","xn--tckwe":"","xn--tiq49xqyj":"","xn--unup4y":"","xn--vermgensberater-ctb":"","xn--vermgensberatung-pwb":"","xn--vhquv":"","xn--vuq861b":"","xn--w4r85el8fhu5dnra":"","xn--w4rs40l":"","xn--xhq521b":"","xn--zfr164b":"","xperia":"","xyz":"blogsite|fhapp","yachts":"","yahoo":"","yamaxun":"","yandex":"","yodobashi":"","yoga":"","yokohama":"","you":"","youtube":"","yun":"","zappos":"","zara":"","zero":"","zip":"","zippo":"","zone":"*triton|lima","zuerich":""}
  7932. },{}],60:[function(require,module,exports){
  7933. // Copyright Joyent, Inc. and other Node contributors.
  7934. //
  7935. // Permission is hereby granted, free of charge, to any person obtaining a
  7936. // copy of this software and associated documentation files (the
  7937. // "Software"), to deal in the Software without restriction, including
  7938. // without limitation the rights to use, copy, modify, merge, publish,
  7939. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7940. // persons to whom the Software is furnished to do so, subject to the
  7941. // following conditions:
  7942. //
  7943. // The above copyright notice and this permission notice shall be included
  7944. // in all copies or substantial portions of the Software.
  7945. //
  7946. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7947. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7948. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7949. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7950. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7951. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7952. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7953. var punycode = require('punycode');
  7954. exports.parse = urlParse;
  7955. exports.resolve = urlResolve;
  7956. exports.resolveObject = urlResolveObject;
  7957. exports.format = urlFormat;
  7958. exports.Url = Url;
  7959. function Url() {
  7960. this.protocol = null;
  7961. this.slashes = null;
  7962. this.auth = null;
  7963. this.host = null;
  7964. this.port = null;
  7965. this.hostname = null;
  7966. this.hash = null;
  7967. this.search = null;
  7968. this.query = null;
  7969. this.pathname = null;
  7970. this.path = null;
  7971. this.href = null;
  7972. }
  7973. // Reference: RFC 3986, RFC 1808, RFC 2396
  7974. // define these here so at least they only have to be
  7975. // compiled once on the first module load.
  7976. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  7977. portPattern = /:[0-9]*$/,
  7978. // RFC 2396: characters reserved for delimiting URLs.
  7979. // We actually just auto-escape these.
  7980. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  7981. // RFC 2396: characters not allowed for various reasons.
  7982. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  7983. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  7984. autoEscape = ['\''].concat(unwise),
  7985. // Characters that are never ever allowed in a hostname.
  7986. // Note that any invalid chars are also handled, but these
  7987. // are the ones that are *expected* to be seen, so we fast-path
  7988. // them.
  7989. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  7990. hostEndingChars = ['/', '?', '#'],
  7991. hostnameMaxLen = 255,
  7992. hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/,
  7993. hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/,
  7994. // protocols that can allow "unsafe" and "unwise" chars.
  7995. unsafeProtocol = {
  7996. 'javascript': true,
  7997. 'javascript:': true
  7998. },
  7999. // protocols that never have a hostname.
  8000. hostlessProtocol = {
  8001. 'javascript': true,
  8002. 'javascript:': true
  8003. },
  8004. // protocols that always contain a // bit.
  8005. slashedProtocol = {
  8006. 'http': true,
  8007. 'https': true,
  8008. 'ftp': true,
  8009. 'gopher': true,
  8010. 'file': true,
  8011. 'http:': true,
  8012. 'https:': true,
  8013. 'ftp:': true,
  8014. 'gopher:': true,
  8015. 'file:': true
  8016. },
  8017. querystring = require('querystring');
  8018. function urlParse(url, parseQueryString, slashesDenoteHost) {
  8019. if (url && isObject(url) && url instanceof Url) return url;
  8020. var u = new Url;
  8021. u.parse(url, parseQueryString, slashesDenoteHost);
  8022. return u;
  8023. }
  8024. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  8025. if (!isString(url)) {
  8026. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  8027. }
  8028. var rest = url;
  8029. // trim before proceeding.
  8030. // This is to support parse stuff like " http://foo.com \n"
  8031. rest = rest.trim();
  8032. var proto = protocolPattern.exec(rest);
  8033. if (proto) {
  8034. proto = proto[0];
  8035. var lowerProto = proto.toLowerCase();
  8036. this.protocol = lowerProto;
  8037. rest = rest.substr(proto.length);
  8038. }
  8039. // figure out if it's got a host
  8040. // user@server is *always* interpreted as a hostname, and url
  8041. // resolution will treat //foo/bar as host=foo,path=bar because that's
  8042. // how the browser resolves relative URLs.
  8043. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  8044. var slashes = rest.substr(0, 2) === '//';
  8045. if (slashes && !(proto && hostlessProtocol[proto])) {
  8046. rest = rest.substr(2);
  8047. this.slashes = true;
  8048. }
  8049. }
  8050. if (!hostlessProtocol[proto] &&
  8051. (slashes || (proto && !slashedProtocol[proto]))) {
  8052. // there's a hostname.
  8053. // the first instance of /, ?, ;, or # ends the host.
  8054. //
  8055. // If there is an @ in the hostname, then non-host chars *are* allowed
  8056. // to the left of the last @ sign, unless some host-ending character
  8057. // comes *before* the @-sign.
  8058. // URLs are obnoxious.
  8059. //
  8060. // ex:
  8061. // http://a@b@c/ => user:a@b host:c
  8062. // http://a@b?@c => user:a host:c path:/?@c
  8063. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  8064. // Review our test case against browsers more comprehensively.
  8065. // find the first instance of any hostEndingChars
  8066. var hostEnd = -1;
  8067. for (var i = 0; i < hostEndingChars.length; i++) {
  8068. var hec = rest.indexOf(hostEndingChars[i]);
  8069. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  8070. hostEnd = hec;
  8071. }
  8072. // at this point, either we have an explicit point where the
  8073. // auth portion cannot go past, or the last @ char is the decider.
  8074. var auth, atSign;
  8075. if (hostEnd === -1) {
  8076. // atSign can be anywhere.
  8077. atSign = rest.lastIndexOf('@');
  8078. } else {
  8079. // atSign must be in auth portion.
  8080. // http://a@b/c@d => host:b auth:a path:/c@d
  8081. atSign = rest.lastIndexOf('@', hostEnd);
  8082. }
  8083. // Now we have a portion which is definitely the auth.
  8084. // Pull that off.
  8085. if (atSign !== -1) {
  8086. auth = rest.slice(0, atSign);
  8087. rest = rest.slice(atSign + 1);
  8088. this.auth = decodeURIComponent(auth);
  8089. }
  8090. // the host is the remaining to the left of the first non-host char
  8091. hostEnd = -1;
  8092. for (var i = 0; i < nonHostChars.length; i++) {
  8093. var hec = rest.indexOf(nonHostChars[i]);
  8094. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  8095. hostEnd = hec;
  8096. }
  8097. // if we still have not hit it, then the entire thing is a host.
  8098. if (hostEnd === -1)
  8099. hostEnd = rest.length;
  8100. this.host = rest.slice(0, hostEnd);
  8101. rest = rest.slice(hostEnd);
  8102. // pull out port.
  8103. this.parseHost();
  8104. // we've indicated that there is a hostname,
  8105. // so even if it's empty, it has to be present.
  8106. this.hostname = this.hostname || '';
  8107. // if hostname begins with [ and ends with ]
  8108. // assume that it's an IPv6 address.
  8109. var ipv6Hostname = this.hostname[0] === '[' &&
  8110. this.hostname[this.hostname.length - 1] === ']';
  8111. // validate a little.
  8112. if (!ipv6Hostname) {
  8113. var hostparts = this.hostname.split(/\./);
  8114. for (var i = 0, l = hostparts.length; i < l; i++) {
  8115. var part = hostparts[i];
  8116. if (!part) continue;
  8117. if (!part.match(hostnamePartPattern)) {
  8118. var newpart = '';
  8119. for (var j = 0, k = part.length; j < k; j++) {
  8120. if (part.charCodeAt(j) > 127) {
  8121. // we replace non-ASCII char with a temporary placeholder
  8122. // we need this to make sure size of hostname is not
  8123. // broken by replacing non-ASCII by nothing
  8124. newpart += 'x';
  8125. } else {
  8126. newpart += part[j];
  8127. }
  8128. }
  8129. // we test again with ASCII char only
  8130. if (!newpart.match(hostnamePartPattern)) {
  8131. var validParts = hostparts.slice(0, i);
  8132. var notHost = hostparts.slice(i + 1);
  8133. var bit = part.match(hostnamePartStart);
  8134. if (bit) {
  8135. validParts.push(bit[1]);
  8136. notHost.unshift(bit[2]);
  8137. }
  8138. if (notHost.length) {
  8139. rest = '/' + notHost.join('.') + rest;
  8140. }
  8141. this.hostname = validParts.join('.');
  8142. break;
  8143. }
  8144. }
  8145. }
  8146. }
  8147. if (this.hostname.length > hostnameMaxLen) {
  8148. this.hostname = '';
  8149. } else {
  8150. // hostnames are always lower case.
  8151. this.hostname = this.hostname.toLowerCase();
  8152. }
  8153. if (!ipv6Hostname) {
  8154. // IDNA Support: Returns a puny coded representation of "domain".
  8155. // It only converts the part of the domain name that
  8156. // has non ASCII characters. I.e. it dosent matter if
  8157. // you call it with a domain that already is in ASCII.
  8158. var domainArray = this.hostname.split('.');
  8159. var newOut = [];
  8160. for (var i = 0; i < domainArray.length; ++i) {
  8161. var s = domainArray[i];
  8162. newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
  8163. 'xn--' + punycode.encode(s) : s);
  8164. }
  8165. this.hostname = newOut.join('.');
  8166. }
  8167. var p = this.port ? ':' + this.port : '';
  8168. var h = this.hostname || '';
  8169. this.host = h + p;
  8170. this.href += this.host;
  8171. // strip [ and ] from the hostname
  8172. // the host field still retains them, though
  8173. if (ipv6Hostname) {
  8174. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  8175. if (rest[0] !== '/') {
  8176. rest = '/' + rest;
  8177. }
  8178. }
  8179. }
  8180. // now rest is set to the post-host stuff.
  8181. // chop off any delim chars.
  8182. if (!unsafeProtocol[lowerProto]) {
  8183. // First, make 100% sure that any "autoEscape" chars get
  8184. // escaped, even if encodeURIComponent doesn't think they
  8185. // need to be.
  8186. for (var i = 0, l = autoEscape.length; i < l; i++) {
  8187. var ae = autoEscape[i];
  8188. var esc = encodeURIComponent(ae);
  8189. if (esc === ae) {
  8190. esc = escape(ae);
  8191. }
  8192. rest = rest.split(ae).join(esc);
  8193. }
  8194. }
  8195. // chop off from the tail first.
  8196. var hash = rest.indexOf('#');
  8197. if (hash !== -1) {
  8198. // got a fragment string.
  8199. this.hash = rest.substr(hash);
  8200. rest = rest.slice(0, hash);
  8201. }
  8202. var qm = rest.indexOf('?');
  8203. if (qm !== -1) {
  8204. this.search = rest.substr(qm);
  8205. this.query = rest.substr(qm + 1);
  8206. if (parseQueryString) {
  8207. this.query = querystring.parse(this.query);
  8208. }
  8209. rest = rest.slice(0, qm);
  8210. } else if (parseQueryString) {
  8211. // no query string, but parseQueryString still requested
  8212. this.search = '';
  8213. this.query = {};
  8214. }
  8215. if (rest) this.pathname = rest;
  8216. if (slashedProtocol[lowerProto] &&
  8217. this.hostname && !this.pathname) {
  8218. this.pathname = '/';
  8219. }
  8220. //to support http.request
  8221. if (this.pathname || this.search) {
  8222. var p = this.pathname || '';
  8223. var s = this.search || '';
  8224. this.path = p + s;
  8225. }
  8226. // finally, reconstruct the href based on what has been validated.
  8227. this.href = this.format();
  8228. return this;
  8229. };
  8230. // format a parsed object into a url string
  8231. function urlFormat(obj) {
  8232. // ensure it's an object, and not a string url.
  8233. // If it's an obj, this is a no-op.
  8234. // this way, you can call url_format() on strings
  8235. // to clean up potentially wonky urls.
  8236. if (isString(obj)) obj = urlParse(obj);
  8237. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  8238. return obj.format();
  8239. }
  8240. Url.prototype.format = function() {
  8241. var auth = this.auth || '';
  8242. if (auth) {
  8243. auth = encodeURIComponent(auth);
  8244. auth = auth.replace(/%3A/i, ':');
  8245. auth += '@';
  8246. }
  8247. var protocol = this.protocol || '',
  8248. pathname = this.pathname || '',
  8249. hash = this.hash || '',
  8250. host = false,
  8251. query = '';
  8252. if (this.host) {
  8253. host = auth + this.host;
  8254. } else if (this.hostname) {
  8255. host = auth + (this.hostname.indexOf(':') === -1 ?
  8256. this.hostname :
  8257. '[' + this.hostname + ']');
  8258. if (this.port) {
  8259. host += ':' + this.port;
  8260. }
  8261. }
  8262. if (this.query &&
  8263. isObject(this.query) &&
  8264. Object.keys(this.query).length) {
  8265. query = querystring.stringify(this.query);
  8266. }
  8267. var search = this.search || (query && ('?' + query)) || '';
  8268. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  8269. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  8270. // unless they had them to begin with.
  8271. if (this.slashes ||
  8272. (!protocol || slashedProtocol[protocol]) && host !== false) {
  8273. host = '//' + (host || '');
  8274. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  8275. } else if (!host) {
  8276. host = '';
  8277. }
  8278. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  8279. if (search && search.charAt(0) !== '?') search = '?' + search;
  8280. pathname = pathname.replace(/[?#]/g, function(match) {
  8281. return encodeURIComponent(match);
  8282. });
  8283. search = search.replace('#', '%23');
  8284. return protocol + host + pathname + search + hash;
  8285. };
  8286. function urlResolve(source, relative) {
  8287. return urlParse(source, false, true).resolve(relative);
  8288. }
  8289. Url.prototype.resolve = function(relative) {
  8290. return this.resolveObject(urlParse(relative, false, true)).format();
  8291. };
  8292. function urlResolveObject(source, relative) {
  8293. if (!source) return relative;
  8294. return urlParse(source, false, true).resolveObject(relative);
  8295. }
  8296. Url.prototype.resolveObject = function(relative) {
  8297. if (isString(relative)) {
  8298. var rel = new Url();
  8299. rel.parse(relative, false, true);
  8300. relative = rel;
  8301. }
  8302. var result = new Url();
  8303. Object.keys(this).forEach(function(k) {
  8304. result[k] = this[k];
  8305. }, this);
  8306. // hash is always overridden, no matter what.
  8307. // even href="" will remove it.
  8308. result.hash = relative.hash;
  8309. // if the relative url is empty, then there's nothing left to do here.
  8310. if (relative.href === '') {
  8311. result.href = result.format();
  8312. return result;
  8313. }
  8314. // hrefs like //foo/bar always cut to the protocol.
  8315. if (relative.slashes && !relative.protocol) {
  8316. // take everything except the protocol from relative
  8317. Object.keys(relative).forEach(function(k) {
  8318. if (k !== 'protocol')
  8319. result[k] = relative[k];
  8320. });
  8321. //urlParse appends trailing / to urls like http://www.example.com
  8322. if (slashedProtocol[result.protocol] &&
  8323. result.hostname && !result.pathname) {
  8324. result.path = result.pathname = '/';
  8325. }
  8326. result.href = result.format();
  8327. return result;
  8328. }
  8329. if (relative.protocol && relative.protocol !== result.protocol) {
  8330. // if it's a known url protocol, then changing
  8331. // the protocol does weird things
  8332. // first, if it's not file:, then we MUST have a host,
  8333. // and if there was a path
  8334. // to begin with, then we MUST have a path.
  8335. // if it is file:, then the host is dropped,
  8336. // because that's known to be hostless.
  8337. // anything else is assumed to be absolute.
  8338. if (!slashedProtocol[relative.protocol]) {
  8339. Object.keys(relative).forEach(function(k) {
  8340. result[k] = relative[k];
  8341. });
  8342. result.href = result.format();
  8343. return result;
  8344. }
  8345. result.protocol = relative.protocol;
  8346. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  8347. var relPath = (relative.pathname || '').split('/');
  8348. while (relPath.length && !(relative.host = relPath.shift()));
  8349. if (!relative.host) relative.host = '';
  8350. if (!relative.hostname) relative.hostname = '';
  8351. if (relPath[0] !== '') relPath.unshift('');
  8352. if (relPath.length < 2) relPath.unshift('');
  8353. result.pathname = relPath.join('/');
  8354. } else {
  8355. result.pathname = relative.pathname;
  8356. }
  8357. result.search = relative.search;
  8358. result.query = relative.query;
  8359. result.host = relative.host || '';
  8360. result.auth = relative.auth;
  8361. result.hostname = relative.hostname || relative.host;
  8362. result.port = relative.port;
  8363. // to support http.request
  8364. if (result.pathname || result.search) {
  8365. var p = result.pathname || '';
  8366. var s = result.search || '';
  8367. result.path = p + s;
  8368. }
  8369. result.slashes = result.slashes || relative.slashes;
  8370. result.href = result.format();
  8371. return result;
  8372. }
  8373. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  8374. isRelAbs = (
  8375. relative.host ||
  8376. relative.pathname && relative.pathname.charAt(0) === '/'
  8377. ),
  8378. mustEndAbs = (isRelAbs || isSourceAbs ||
  8379. (result.host && relative.pathname)),
  8380. removeAllDots = mustEndAbs,
  8381. srcPath = result.pathname && result.pathname.split('/') || [],
  8382. relPath = relative.pathname && relative.pathname.split('/') || [],
  8383. psychotic = result.protocol && !slashedProtocol[result.protocol];
  8384. // if the url is a non-slashed url, then relative
  8385. // links like ../.. should be able
  8386. // to crawl up to the hostname, as well. This is strange.
  8387. // result.protocol has already been set by now.
  8388. // Later on, put the first path part into the host field.
  8389. if (psychotic) {
  8390. result.hostname = '';
  8391. result.port = null;
  8392. if (result.host) {
  8393. if (srcPath[0] === '') srcPath[0] = result.host;
  8394. else srcPath.unshift(result.host);
  8395. }
  8396. result.host = '';
  8397. if (relative.protocol) {
  8398. relative.hostname = null;
  8399. relative.port = null;
  8400. if (relative.host) {
  8401. if (relPath[0] === '') relPath[0] = relative.host;
  8402. else relPath.unshift(relative.host);
  8403. }
  8404. relative.host = null;
  8405. }
  8406. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  8407. }
  8408. if (isRelAbs) {
  8409. // it's absolute.
  8410. result.host = (relative.host || relative.host === '') ?
  8411. relative.host : result.host;
  8412. result.hostname = (relative.hostname || relative.hostname === '') ?
  8413. relative.hostname : result.hostname;
  8414. result.search = relative.search;
  8415. result.query = relative.query;
  8416. srcPath = relPath;
  8417. // fall through to the dot-handling below.
  8418. } else if (relPath.length) {
  8419. // it's relative
  8420. // throw away the existing file, and take the new path instead.
  8421. if (!srcPath) srcPath = [];
  8422. srcPath.pop();
  8423. srcPath = srcPath.concat(relPath);
  8424. result.search = relative.search;
  8425. result.query = relative.query;
  8426. } else if (!isNullOrUndefined(relative.search)) {
  8427. // just pull out the search.
  8428. // like href='?foo'.
  8429. // Put this after the other two cases because it simplifies the booleans
  8430. if (psychotic) {
  8431. result.hostname = result.host = srcPath.shift();
  8432. //occationaly the auth can get stuck only in host
  8433. //this especialy happens in cases like
  8434. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  8435. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  8436. result.host.split('@') : false;
  8437. if (authInHost) {
  8438. result.auth = authInHost.shift();
  8439. result.host = result.hostname = authInHost.shift();
  8440. }
  8441. }
  8442. result.search = relative.search;
  8443. result.query = relative.query;
  8444. //to support http.request
  8445. if (!isNull(result.pathname) || !isNull(result.search)) {
  8446. result.path = (result.pathname ? result.pathname : '') +
  8447. (result.search ? result.search : '');
  8448. }
  8449. result.href = result.format();
  8450. return result;
  8451. }
  8452. if (!srcPath.length) {
  8453. // no path at all. easy.
  8454. // we've already handled the other stuff above.
  8455. result.pathname = null;
  8456. //to support http.request
  8457. if (result.search) {
  8458. result.path = '/' + result.search;
  8459. } else {
  8460. result.path = null;
  8461. }
  8462. result.href = result.format();
  8463. return result;
  8464. }
  8465. // if a url ENDs in . or .., then it must get a trailing slash.
  8466. // however, if it ends in anything else non-slashy,
  8467. // then it must NOT get a trailing slash.
  8468. var last = srcPath.slice(-1)[0];
  8469. var hasTrailingSlash = (
  8470. (result.host || relative.host) && (last === '.' || last === '..') ||
  8471. last === '');
  8472. // strip single dots, resolve double dots to parent dir
  8473. // if the path tries to go above the root, `up` ends up > 0
  8474. var up = 0;
  8475. for (var i = srcPath.length; i >= 0; i--) {
  8476. last = srcPath[i];
  8477. if (last == '.') {
  8478. srcPath.splice(i, 1);
  8479. } else if (last === '..') {
  8480. srcPath.splice(i, 1);
  8481. up++;
  8482. } else if (up) {
  8483. srcPath.splice(i, 1);
  8484. up--;
  8485. }
  8486. }
  8487. // if the path is allowed to go above the root, restore leading ..s
  8488. if (!mustEndAbs && !removeAllDots) {
  8489. for (; up--; up) {
  8490. srcPath.unshift('..');
  8491. }
  8492. }
  8493. if (mustEndAbs && srcPath[0] !== '' &&
  8494. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  8495. srcPath.unshift('');
  8496. }
  8497. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  8498. srcPath.push('');
  8499. }
  8500. var isAbsolute = srcPath[0] === '' ||
  8501. (srcPath[0] && srcPath[0].charAt(0) === '/');
  8502. // put the host back
  8503. if (psychotic) {
  8504. result.hostname = result.host = isAbsolute ? '' :
  8505. srcPath.length ? srcPath.shift() : '';
  8506. //occationaly the auth can get stuck only in host
  8507. //this especialy happens in cases like
  8508. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  8509. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  8510. result.host.split('@') : false;
  8511. if (authInHost) {
  8512. result.auth = authInHost.shift();
  8513. result.host = result.hostname = authInHost.shift();
  8514. }
  8515. }
  8516. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  8517. if (mustEndAbs && !isAbsolute) {
  8518. srcPath.unshift('');
  8519. }
  8520. if (!srcPath.length) {
  8521. result.pathname = null;
  8522. result.path = null;
  8523. } else {
  8524. result.pathname = srcPath.join('/');
  8525. }
  8526. //to support request.http
  8527. if (!isNull(result.pathname) || !isNull(result.search)) {
  8528. result.path = (result.pathname ? result.pathname : '') +
  8529. (result.search ? result.search : '');
  8530. }
  8531. result.auth = relative.auth || result.auth;
  8532. result.slashes = result.slashes || relative.slashes;
  8533. result.href = result.format();
  8534. return result;
  8535. };
  8536. Url.prototype.parseHost = function() {
  8537. var host = this.host;
  8538. var port = portPattern.exec(host);
  8539. if (port) {
  8540. port = port[0];
  8541. if (port !== ':') {
  8542. this.port = port.substr(1);
  8543. }
  8544. host = host.substr(0, host.length - port.length);
  8545. }
  8546. if (host) this.hostname = host;
  8547. };
  8548. function isString(arg) {
  8549. return typeof arg === "string";
  8550. }
  8551. function isObject(arg) {
  8552. return typeof arg === 'object' && arg !== null;
  8553. }
  8554. function isNull(arg) {
  8555. return arg === null;
  8556. }
  8557. function isNullOrUndefined(arg) {
  8558. return arg == null;
  8559. }
  8560. },{"punycode":40,"querystring":43}],61:[function(require,module,exports){
  8561. var AttachedCache, IP, U2, Url, escapeSlash, exports, ref, shExp2RegExp,
  8562. hasProp = {}.hasOwnProperty;
  8563. U2 = require('uglify-js');
  8564. IP = require('ip-address');
  8565. Url = require('url');
  8566. ref = require('./shexp_utils'), shExp2RegExp = ref.shExp2RegExp, escapeSlash = ref.escapeSlash;
  8567. AttachedCache = require('./utils').AttachedCache;
  8568. module.exports = exports = {
  8569. requestFromUrl: function(url) {
  8570. var req;
  8571. if (typeof url === 'string') {
  8572. url = Url.parse(url);
  8573. }
  8574. return req = {
  8575. url: Url.format(url),
  8576. host: url.hostname,
  8577. scheme: url.protocol.replace(':', '')
  8578. };
  8579. },
  8580. urlWildcard2HostWildcard: function(pattern) {
  8581. var result;
  8582. result = pattern.match(/^\*:\/\/((?:\w|[?*._\-])+)\/\*$/);
  8583. return result != null ? result[1] : void 0;
  8584. },
  8585. tag: function(condition) {
  8586. return exports._condCache.tag(condition);
  8587. },
  8588. analyze: function(condition) {
  8589. return exports._condCache.get(condition, function() {
  8590. return {
  8591. analyzed: exports._handler(condition.conditionType).analyze.call(exports, condition)
  8592. };
  8593. });
  8594. },
  8595. match: function(condition, request) {
  8596. var cache;
  8597. cache = exports.analyze(condition);
  8598. return exports._handler(condition.conditionType).match.call(exports, condition, request, cache);
  8599. },
  8600. compile: function(condition) {
  8601. var cache, handler;
  8602. cache = exports.analyze(condition);
  8603. if (cache.compiled) {
  8604. return cache.compiled;
  8605. }
  8606. handler = exports._handler(condition.conditionType);
  8607. return cache.compiled = handler.compile.call(exports, condition, cache);
  8608. },
  8609. str: function(condition, arg) {
  8610. var abbr, endCode, handler, part, result, str, typeStr;
  8611. abbr = (arg != null ? arg : {
  8612. abbr: -1
  8613. }).abbr;
  8614. handler = exports._handler(condition.conditionType);
  8615. if (handler.abbrs[0].length === 0) {
  8616. endCode = condition.pattern.charCodeAt(condition.pattern.length - 1);
  8617. if (endCode !== exports.colonCharCode && condition.pattern.indexOf(' ') < 0) {
  8618. return condition.pattern;
  8619. }
  8620. }
  8621. str = handler.str;
  8622. typeStr = typeof abbr === 'number' ? handler.abbrs[(handler.abbrs.length + abbr) % handler.abbrs.length] : condition.conditionType;
  8623. result = typeStr + ':';
  8624. part = str ? str.call(exports, condition) : condition.pattern;
  8625. if (part) {
  8626. result += ' ' + part;
  8627. }
  8628. return result;
  8629. },
  8630. colonCharCode: ':'.charCodeAt(0),
  8631. fromStr: function(str) {
  8632. var condition, conditionType, fromStr, i;
  8633. str = str.trim();
  8634. i = str.indexOf(' ');
  8635. if (i < 0) {
  8636. i = str.length;
  8637. }
  8638. if (str.charCodeAt(i - 1) === exports.colonCharCode) {
  8639. conditionType = str.substr(0, i - 1);
  8640. str = str.substr(i + 1).trim();
  8641. } else {
  8642. conditionType = '';
  8643. }
  8644. conditionType = exports.typeFromAbbr(conditionType);
  8645. if (!conditionType) {
  8646. return null;
  8647. }
  8648. condition = {
  8649. conditionType: conditionType
  8650. };
  8651. fromStr = exports._handler(condition.conditionType).fromStr;
  8652. if (fromStr) {
  8653. return fromStr.call(exports, str, condition);
  8654. } else {
  8655. condition.pattern = str;
  8656. return condition;
  8657. }
  8658. },
  8659. _abbrs: null,
  8660. typeFromAbbr: function(abbr) {
  8661. var ab, abbrs, j, len, ref1, type;
  8662. if (!exports._abbrs) {
  8663. exports._abbrs = {};
  8664. ref1 = exports._conditionTypes;
  8665. for (type in ref1) {
  8666. if (!hasProp.call(ref1, type)) continue;
  8667. abbrs = ref1[type].abbrs;
  8668. exports._abbrs[type.toUpperCase()] = type;
  8669. for (j = 0, len = abbrs.length; j < len; j++) {
  8670. ab = abbrs[j];
  8671. exports._abbrs[ab.toUpperCase()] = type;
  8672. }
  8673. }
  8674. }
  8675. return exports._abbrs[abbr.toUpperCase()];
  8676. },
  8677. comment: function(comment, node) {
  8678. var base;
  8679. if (!comment) {
  8680. return node;
  8681. }
  8682. if (node.start == null) {
  8683. node.start = {};
  8684. }
  8685. Object.defineProperty(node.start, '_comments_dumped', {
  8686. get: function() {
  8687. return false;
  8688. },
  8689. set: function() {
  8690. return false;
  8691. }
  8692. });
  8693. if ((base = node.start).comments_before == null) {
  8694. base.comments_before = [];
  8695. }
  8696. node.start.comments_before.push({
  8697. type: 'comment2',
  8698. value: comment
  8699. });
  8700. return node;
  8701. },
  8702. safeRegex: function(expr) {
  8703. var _;
  8704. try {
  8705. return new RegExp(expr);
  8706. } catch (error) {
  8707. _ = error;
  8708. return /(?!)/;
  8709. }
  8710. },
  8711. regTest: function(expr, regexp) {
  8712. if (typeof regexp === 'string') {
  8713. regexp = regexSafe(escapeSlash(regexp));
  8714. }
  8715. if (typeof expr === 'string') {
  8716. expr = new U2.AST_SymbolRef({
  8717. name: expr
  8718. });
  8719. }
  8720. return new U2.AST_Call({
  8721. args: [expr],
  8722. expression: new U2.AST_Dot({
  8723. property: 'test',
  8724. expression: new U2.AST_RegExp({
  8725. value: regexp
  8726. })
  8727. })
  8728. });
  8729. },
  8730. isInt: function(num) {
  8731. return typeof num === 'number' && !isNaN(num) && parseFloat(num) === parseInt(num, 10);
  8732. },
  8733. between: function(val, min, max, comment) {
  8734. var pos, str, tmpl;
  8735. if (min === max) {
  8736. if (typeof min === 'number') {
  8737. min = new U2.AST_Number({
  8738. value: min
  8739. });
  8740. }
  8741. return exports.comment(comment, new U2.AST_Binary({
  8742. left: val,
  8743. operator: '===',
  8744. right: min
  8745. }));
  8746. }
  8747. if (min > max) {
  8748. return exports.comment(comment, new U2.AST_False);
  8749. }
  8750. if (exports.isInt(min) && exports.isInt(max) && max - min < 32) {
  8751. comment || (comment = min + " <= value && value <= " + max);
  8752. tmpl = "0123456789abcdefghijklmnopqrstuvwxyz";
  8753. str = max < tmpl.length ? tmpl.substr(min, max - min + 1) : tmpl.substr(0, max - min + 1);
  8754. pos = min === 0 ? val : new U2.AST_Binary({
  8755. left: val,
  8756. operator: '-',
  8757. right: new U2.AST_Number({
  8758. value: min
  8759. })
  8760. });
  8761. return exports.comment(comment, new U2.AST_Binary({
  8762. left: new U2.AST_Call({
  8763. expression: new U2.AST_Dot({
  8764. expression: new U2.AST_String({
  8765. value: str
  8766. }),
  8767. property: 'charCodeAt'
  8768. }),
  8769. args: [pos]
  8770. }),
  8771. operator: '>',
  8772. right: new U2.AST_Number({
  8773. value: 0
  8774. })
  8775. }));
  8776. }
  8777. if (typeof min === 'number') {
  8778. min = new U2.AST_Number({
  8779. value: min
  8780. });
  8781. }
  8782. if (typeof max === 'number') {
  8783. max = new U2.AST_Number({
  8784. value: max
  8785. });
  8786. }
  8787. return exports.comment(comment, new U2.AST_Call({
  8788. args: [val, min, max],
  8789. expression: new U2.AST_Function({
  8790. argnames: [
  8791. new U2.AST_SymbolFunarg({
  8792. name: 'value'
  8793. }), new U2.AST_SymbolFunarg({
  8794. name: 'min'
  8795. }), new U2.AST_SymbolFunarg({
  8796. name: 'max'
  8797. })
  8798. ],
  8799. body: [
  8800. new U2.AST_Return({
  8801. value: new U2.AST_Binary({
  8802. left: new U2.AST_Binary({
  8803. left: new U2.AST_SymbolRef({
  8804. name: 'min'
  8805. }),
  8806. operator: '<=',
  8807. right: new U2.AST_SymbolRef({
  8808. name: 'value'
  8809. })
  8810. }),
  8811. operator: '&&',
  8812. right: new U2.AST_Binary({
  8813. left: new U2.AST_SymbolRef({
  8814. name: 'value'
  8815. }),
  8816. operator: '<=',
  8817. right: new U2.AST_SymbolRef({
  8818. name: 'max'
  8819. })
  8820. })
  8821. })
  8822. })
  8823. ]
  8824. })
  8825. }));
  8826. },
  8827. parseIp: function(ip) {
  8828. var addr;
  8829. if (ip.charCodeAt(0) === '['.charCodeAt(0)) {
  8830. ip = ip.substr(1, ip.length - 2);
  8831. }
  8832. addr = new IP.v4.Address(ip);
  8833. if (!addr.isValid()) {
  8834. addr = new IP.v6.Address(ip);
  8835. if (!addr.isValid()) {
  8836. return null;
  8837. }
  8838. }
  8839. return addr;
  8840. },
  8841. normalizeIp: function(addr) {
  8842. var ref1;
  8843. return ((ref1 = addr.correctForm) != null ? ref1 : addr.canonicalForm).call(addr);
  8844. },
  8845. ipv6Max: new IP.v6.Address('::/0').endAddress().canonicalForm(),
  8846. localHosts: ["127.0.0.1", "[::1]", "localhost"],
  8847. getWeekdayList: function(condition) {
  8848. var i, j, k, results, results1;
  8849. if (condition.days) {
  8850. results = [];
  8851. for (i = j = 0; j < 7; i = ++j) {
  8852. results.push(condition.days.charCodeAt(i) > 64);
  8853. }
  8854. return results;
  8855. } else {
  8856. results1 = [];
  8857. for (i = k = 0; k < 7; i = ++k) {
  8858. results1.push((condition.startDay <= i && i <= condition.endDay));
  8859. }
  8860. return results1;
  8861. }
  8862. },
  8863. _condCache: new AttachedCache(function(condition) {
  8864. var result, tag;
  8865. tag = exports._handler(condition.conditionType).tag;
  8866. result = tag ? tag.apply(exports, arguments) : exports.str(condition);
  8867. return condition.conditionType + '$' + result;
  8868. }),
  8869. _setProp: function(obj, prop, value) {
  8870. if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
  8871. Object.defineProperty(obj, prop, {
  8872. writable: true
  8873. });
  8874. }
  8875. return obj[prop] = value;
  8876. },
  8877. _handler: function(conditionType) {
  8878. var handler;
  8879. if (typeof conditionType !== 'string') {
  8880. conditionType = conditionType.conditionType;
  8881. }
  8882. handler = exports._conditionTypes[conditionType];
  8883. if (handler == null) {
  8884. throw new Error("Unknown condition type: " + conditionType);
  8885. }
  8886. return handler;
  8887. },
  8888. _conditionTypes: {
  8889. 'TrueCondition': {
  8890. abbrs: ['True'],
  8891. analyze: function(condition) {
  8892. return null;
  8893. },
  8894. match: function() {
  8895. return true;
  8896. },
  8897. compile: function(condition) {
  8898. return new U2.AST_True;
  8899. },
  8900. str: function(condition) {
  8901. return '';
  8902. },
  8903. fromStr: function(str, condition) {
  8904. return condition;
  8905. }
  8906. },
  8907. 'FalseCondition': {
  8908. abbrs: ['False', 'Disabled'],
  8909. analyze: function(condition) {
  8910. return null;
  8911. },
  8912. match: function() {
  8913. return false;
  8914. },
  8915. compile: function(condition) {
  8916. return new U2.AST_False;
  8917. },
  8918. fromStr: function(str, condition) {
  8919. if (str.length > 0) {
  8920. condition.pattern = str;
  8921. }
  8922. return condition;
  8923. }
  8924. },
  8925. 'UrlRegexCondition': {
  8926. abbrs: ['UR', 'URegex', 'UrlR', 'UrlRegex'],
  8927. analyze: function(condition) {
  8928. return this.safeRegex(escapeSlash(condition.pattern));
  8929. },
  8930. match: function(condition, request, cache) {
  8931. return cache.analyzed.test(request.url);
  8932. },
  8933. compile: function(condition, cache) {
  8934. return this.regTest('url', cache.analyzed);
  8935. }
  8936. },
  8937. 'UrlWildcardCondition': {
  8938. abbrs: ['U', 'UW', 'Url', 'UrlW', 'UWild', 'UWildcard', 'UrlWild', 'UrlWildcard'],
  8939. analyze: function(condition) {
  8940. var parts, pattern;
  8941. parts = (function() {
  8942. var j, len, ref1, results;
  8943. ref1 = condition.pattern.split('|');
  8944. results = [];
  8945. for (j = 0, len = ref1.length; j < len; j++) {
  8946. pattern = ref1[j];
  8947. if (pattern) {
  8948. results.push(shExp2RegExp(pattern, {
  8949. trimAsterisk: true
  8950. }));
  8951. }
  8952. }
  8953. return results;
  8954. })();
  8955. return this.safeRegex(parts.join('|'));
  8956. },
  8957. match: function(condition, request, cache) {
  8958. return cache.analyzed.test(request.url);
  8959. },
  8960. compile: function(condition, cache) {
  8961. return this.regTest('url', cache.analyzed);
  8962. }
  8963. },
  8964. 'HostRegexCondition': {
  8965. abbrs: ['R', 'HR', 'Regex', 'HostR', 'HRegex', 'HostRegex'],
  8966. analyze: function(condition) {
  8967. return this.safeRegex(escapeSlash(condition.pattern));
  8968. },
  8969. match: function(condition, request, cache) {
  8970. return cache.analyzed.test(request.host);
  8971. },
  8972. compile: function(condition, cache) {
  8973. return this.regTest('host', cache.analyzed);
  8974. }
  8975. },
  8976. 'HostWildcardCondition': {
  8977. abbrs: ['', 'H', 'W', 'HW', 'Wild', 'Wildcard', 'Host', 'HostW', 'HWild', 'HWildcard', 'HostWild', 'HostWildcard'],
  8978. analyze: function(condition) {
  8979. var parts, pattern;
  8980. parts = (function() {
  8981. var j, len, ref1, results;
  8982. ref1 = condition.pattern.split('|');
  8983. results = [];
  8984. for (j = 0, len = ref1.length; j < len; j++) {
  8985. pattern = ref1[j];
  8986. if (!(pattern)) {
  8987. continue;
  8988. }
  8989. if (pattern.charCodeAt(0) === '.'.charCodeAt(0)) {
  8990. pattern = '*' + pattern;
  8991. }
  8992. if (pattern.indexOf('**.') === 0) {
  8993. results.push(shExp2RegExp(pattern.substring(1), {
  8994. trimAsterisk: true
  8995. }));
  8996. } else if (pattern.indexOf('*.') === 0) {
  8997. results.push(shExp2RegExp(pattern.substring(2), {
  8998. trimAsterisk: false
  8999. }).replace(/./, '(?:^|\\.)').replace(/\.\*\$$/, ''));
  9000. } else {
  9001. results.push(shExp2RegExp(pattern, {
  9002. trimAsterisk: true
  9003. }));
  9004. }
  9005. }
  9006. return results;
  9007. })();
  9008. return this.safeRegex(parts.join('|'));
  9009. },
  9010. match: function(condition, request, cache) {
  9011. return cache.analyzed.test(request.host);
  9012. },
  9013. compile: function(condition, cache) {
  9014. return this.regTest('host', cache.analyzed);
  9015. }
  9016. },
  9017. 'BypassCondition': {
  9018. abbrs: ['B', 'Bypass'],
  9019. analyze: function(condition) {
  9020. var addr, cache, matchPort, parts, pos, prefixLen, ref1, scheme, server, serverIp, serverRegex;
  9021. cache = {
  9022. host: null,
  9023. ip: null,
  9024. scheme: null,
  9025. url: null,
  9026. normalizedPattern: ''
  9027. };
  9028. server = condition.pattern;
  9029. if (server === '<local>') {
  9030. cache.host = server;
  9031. return cache;
  9032. }
  9033. parts = server.split('://');
  9034. if (parts.length > 1) {
  9035. cache.scheme = parts[0];
  9036. cache.normalizedPattern = cache.scheme + '://';
  9037. server = parts[1];
  9038. }
  9039. parts = server.split('/');
  9040. if (parts.length > 1) {
  9041. addr = this.parseIp(parts[0]);
  9042. prefixLen = parseInt(parts[1]);
  9043. if (addr && !isNaN(prefixLen)) {
  9044. cache.ip = {
  9045. conditionType: 'IpCondition',
  9046. ip: this.normalizeIp(addr),
  9047. prefixLength: prefixLen
  9048. };
  9049. cache.normalizedPattern += cache.ip.ip + '/' + cache.ip.prefixLength;
  9050. return cache;
  9051. }
  9052. }
  9053. serverIp = this.parseIp(server);
  9054. if (serverIp == null) {
  9055. pos = server.lastIndexOf(':');
  9056. if (pos >= 0) {
  9057. matchPort = server.substring(pos + 1);
  9058. server = server.substring(0, pos);
  9059. }
  9060. serverIp = this.parseIp(server);
  9061. }
  9062. if (serverIp != null) {
  9063. server = this.normalizeIp(serverIp);
  9064. if (serverIp.v4) {
  9065. cache.normalizedPattern += server;
  9066. } else {
  9067. cache.normalizedPattern += '[' + server + ']';
  9068. }
  9069. } else {
  9070. if (server.charCodeAt(0) === '.'.charCodeAt(0)) {
  9071. server = '*' + server;
  9072. }
  9073. cache.normalizedPattern = server;
  9074. }
  9075. if (matchPort) {
  9076. cache.port = matchPort;
  9077. cache.normalizedPattern += ':' + cache.port;
  9078. if ((serverIp != null) && !serverIp.v4) {
  9079. server = '[' + server + ']';
  9080. }
  9081. serverRegex = shExp2RegExp(server);
  9082. serverRegex = serverRegex.substring(1, serverRegex.length - 1);
  9083. scheme = (ref1 = cache.scheme) != null ? ref1 : '[^:]+';
  9084. cache.url = this.safeRegex('^' + scheme + ':\\/\\/' + serverRegex + ':' + matchPort + '\\/');
  9085. } else if (server !== '*') {
  9086. serverRegex = shExp2RegExp(server, {
  9087. trimAsterisk: true
  9088. });
  9089. cache.host = this.safeRegex(serverRegex);
  9090. }
  9091. return cache;
  9092. },
  9093. match: function(condition, request, cache) {
  9094. cache = cache.analyzed;
  9095. if ((cache.scheme != null) && cache.scheme !== request.scheme) {
  9096. return false;
  9097. }
  9098. if ((cache.ip != null) && !this.match(cache.ip, request)) {
  9099. return false;
  9100. }
  9101. if (cache.host != null) {
  9102. if (cache.host === '<local>') {
  9103. return request.host === '127.0.0.1' || request.host === '::1' || request.host.indexOf('.') < 0;
  9104. } else {
  9105. if (!cache.host.test(request.host)) {
  9106. return false;
  9107. }
  9108. }
  9109. }
  9110. if ((cache.url != null) && !cache.url.test(request.url)) {
  9111. return false;
  9112. }
  9113. return true;
  9114. },
  9115. str: function(condition) {
  9116. var analyze, cache;
  9117. analyze = this._handler(condition).analyze;
  9118. cache = analyze.call(exports, condition);
  9119. if (cache.normalizedPattern) {
  9120. return cache.normalizedPattern;
  9121. } else {
  9122. return condition.pattern;
  9123. }
  9124. },
  9125. compile: function(condition, cache) {
  9126. var conditions, hostEquals;
  9127. cache = cache.analyzed;
  9128. if (cache.url != null) {
  9129. return this.regTest('url', cache.url);
  9130. }
  9131. conditions = [];
  9132. if (cache.host === '<local>') {
  9133. hostEquals = function(host) {
  9134. return new U2.AST_Binary({
  9135. left: new U2.AST_SymbolRef({
  9136. name: 'host'
  9137. }),
  9138. operator: '===',
  9139. right: new U2.AST_String({
  9140. value: host
  9141. })
  9142. });
  9143. };
  9144. return new U2.AST_Binary({
  9145. left: new U2.AST_Binary({
  9146. left: hostEquals('127.0.0.1'),
  9147. operator: '||',
  9148. right: hostEquals('::1')
  9149. }),
  9150. operator: '||',
  9151. right: new U2.AST_Binary({
  9152. left: new U2.AST_Call({
  9153. expression: new U2.AST_Dot({
  9154. expression: new U2.AST_SymbolRef({
  9155. name: 'host'
  9156. }),
  9157. property: 'indexOf'
  9158. }),
  9159. args: [
  9160. new U2.AST_String({
  9161. value: '.'
  9162. })
  9163. ]
  9164. }),
  9165. operator: '<',
  9166. right: new U2.AST_Number({
  9167. value: 0
  9168. })
  9169. })
  9170. });
  9171. }
  9172. if (cache.scheme != null) {
  9173. conditions.push(new U2.AST_Binary({
  9174. left: new U2.AST_SymbolRef({
  9175. name: 'scheme'
  9176. }),
  9177. operator: '===',
  9178. right: new U2.AST_String({
  9179. value: cache.scheme
  9180. })
  9181. }));
  9182. }
  9183. if (cache.host != null) {
  9184. conditions.push(this.regTest('host', cache.host));
  9185. } else if (cache.ip != null) {
  9186. conditions.push(this.compile(cache.ip));
  9187. }
  9188. switch (conditions.length) {
  9189. case 0:
  9190. return new U2.AST_True;
  9191. case 1:
  9192. return conditions[0];
  9193. case 2:
  9194. return new U2.AST_Binary({
  9195. left: conditions[0],
  9196. operator: '&&',
  9197. right: conditions[1]
  9198. });
  9199. }
  9200. }
  9201. },
  9202. 'KeywordCondition': {
  9203. abbrs: ['K', 'KW', 'Keyword'],
  9204. analyze: function(condition) {
  9205. return null;
  9206. },
  9207. match: function(condition, request) {
  9208. return request.scheme === 'http' && request.url.indexOf(condition.pattern) >= 0;
  9209. },
  9210. compile: function(condition) {
  9211. return new U2.AST_Binary({
  9212. left: new U2.AST_Binary({
  9213. left: new U2.AST_SymbolRef({
  9214. name: 'scheme'
  9215. }),
  9216. operator: '===',
  9217. right: new U2.AST_String({
  9218. value: 'http'
  9219. })
  9220. }),
  9221. operator: '&&',
  9222. right: new U2.AST_Binary({
  9223. left: new U2.AST_Call({
  9224. expression: new U2.AST_Dot({
  9225. expression: new U2.AST_SymbolRef({
  9226. name: 'url'
  9227. }),
  9228. property: 'indexOf'
  9229. }),
  9230. args: [
  9231. new U2.AST_String({
  9232. value: condition.pattern
  9233. })
  9234. ]
  9235. }),
  9236. operator: '>=',
  9237. right: new U2.AST_Number({
  9238. value: 0
  9239. })
  9240. })
  9241. });
  9242. }
  9243. },
  9244. 'IpCondition': {
  9245. abbrs: ['Ip'],
  9246. analyze: function(condition) {
  9247. var addr, cache, ip, mask;
  9248. cache = {
  9249. addr: null,
  9250. normalized: null
  9251. };
  9252. ip = condition.ip;
  9253. if (ip.charCodeAt(0) === '['.charCodeAt(0)) {
  9254. ip = ip.substr(1, ip.length - 2);
  9255. }
  9256. addr = ip + '/' + condition.prefixLength;
  9257. cache.addr = this.parseIp(addr);
  9258. if (cache.addr == null) {
  9259. throw new Error("Invalid IP address " + addr);
  9260. }
  9261. cache.normalized = this.normalizeIp(cache.addr);
  9262. mask = cache.addr.v4 ? new IP.v4.Address('255.255.255.255/' + cache.addr.subnetMask) : new IP.v6.Address(this.ipv6Max + '/' + cache.addr.subnetMask);
  9263. cache.mask = this.normalizeIp(mask.startAddress());
  9264. return cache;
  9265. },
  9266. match: function(condition, request, cache) {
  9267. var addr;
  9268. addr = this.parseIp(request.host);
  9269. if (addr == null) {
  9270. return false;
  9271. }
  9272. cache = cache.analyzed;
  9273. if (addr.v4 !== cache.addr.v4) {
  9274. return false;
  9275. }
  9276. return addr.isInSubnet(cache.addr);
  9277. },
  9278. compile: function(condition, cache) {
  9279. var hostIsInNet, hostIsInNetEx, hostLooksLikeIp;
  9280. cache = cache.analyzed;
  9281. hostLooksLikeIp = cache.addr.v4 ? new U2.AST_Binary({
  9282. left: new U2.AST_Sub({
  9283. expression: new U2.AST_SymbolRef({
  9284. name: 'host'
  9285. }),
  9286. property: new U2.AST_Binary({
  9287. left: new U2.AST_Dot({
  9288. expression: new U2.AST_SymbolRef({
  9289. name: 'host'
  9290. }),
  9291. property: 'length'
  9292. }),
  9293. operator: '-',
  9294. right: new U2.AST_Number({
  9295. value: 1
  9296. })
  9297. })
  9298. }),
  9299. operator: '>=',
  9300. right: new U2.AST_Number({
  9301. value: 0
  9302. })
  9303. }) : new U2.AST_Binary({
  9304. left: new U2.AST_Call({
  9305. expression: new U2.AST_Dot({
  9306. expression: new U2.AST_SymbolRef({
  9307. name: 'host'
  9308. }),
  9309. property: 'indexOf'
  9310. }),
  9311. args: [
  9312. new U2.AST_String({
  9313. value: ':'
  9314. })
  9315. ]
  9316. }),
  9317. operator: '>=',
  9318. right: new U2.AST_Number({
  9319. value: 0
  9320. })
  9321. });
  9322. if (cache.addr.subnetMask === 0) {
  9323. return hostLooksLikeIp;
  9324. }
  9325. hostIsInNet = new U2.AST_Call({
  9326. expression: new U2.AST_SymbolRef({
  9327. name: 'isInNet'
  9328. }),
  9329. args: [
  9330. new U2.AST_SymbolRef({
  9331. name: 'host'
  9332. }), new U2.AST_String({
  9333. value: cache.normalized
  9334. }), new U2.AST_String({
  9335. value: cache.mask
  9336. })
  9337. ]
  9338. });
  9339. if (!cache.addr.v4) {
  9340. hostIsInNetEx = new U2.AST_Call({
  9341. expression: new U2.AST_SymbolRef({
  9342. name: 'isInNetEx'
  9343. }),
  9344. args: [
  9345. new U2.AST_SymbolRef({
  9346. name: 'host'
  9347. }), new U2.AST_String({
  9348. value: cache.normalized + cache.addr.subnet
  9349. })
  9350. ]
  9351. });
  9352. hostIsInNet = new U2.AST_Conditional({
  9353. condition: new U2.AST_Binary({
  9354. left: new U2.AST_UnaryPrefix({
  9355. operator: 'typeof',
  9356. expression: new U2.AST_SymbolRef({
  9357. name: 'isInNetEx'
  9358. })
  9359. }),
  9360. operator: '===',
  9361. right: new U2.AST_String({
  9362. value: 'function'
  9363. })
  9364. }),
  9365. consequent: hostIsInNetEx,
  9366. alternative: hostIsInNet
  9367. });
  9368. }
  9369. return new U2.AST_Binary({
  9370. left: hostLooksLikeIp,
  9371. operator: '&&',
  9372. right: hostIsInNet
  9373. });
  9374. },
  9375. str: function(condition) {
  9376. return condition.ip + '/' + condition.prefixLength;
  9377. },
  9378. fromStr: function(str, condition) {
  9379. var addr;
  9380. addr = this.parseIp(str);
  9381. if (addr != null) {
  9382. condition.ip = addr.addressMinusSuffix;
  9383. condition.prefixLength = addr.subnetMask;
  9384. } else {
  9385. condition.ip = '0.0.0.0';
  9386. condition.prefixLength = 0;
  9387. }
  9388. return condition;
  9389. }
  9390. },
  9391. 'HostLevelsCondition': {
  9392. abbrs: ['Lv', 'Level', 'Levels', 'HL', 'HLv', 'HLevel', 'HLevels', 'HostL', 'HostLv', 'HostLevel', 'HostLevels'],
  9393. analyze: function(condition) {
  9394. return '.'.charCodeAt(0);
  9395. },
  9396. match: function(condition, request, cache) {
  9397. var dotCharCode, dotCount, i, j, ref1;
  9398. dotCharCode = cache.analyzed;
  9399. dotCount = 0;
  9400. for (i = j = 0, ref1 = request.host.length; 0 <= ref1 ? j < ref1 : j > ref1; i = 0 <= ref1 ? ++j : --j) {
  9401. if (request.host.charCodeAt(i) === dotCharCode) {
  9402. dotCount++;
  9403. if (dotCount > condition.maxValue) {
  9404. return false;
  9405. }
  9406. }
  9407. }
  9408. return dotCount >= condition.minValue;
  9409. },
  9410. compile: function(condition) {
  9411. var val;
  9412. val = new U2.AST_Dot({
  9413. property: 'length',
  9414. expression: new U2.AST_Call({
  9415. args: [
  9416. new U2.AST_String({
  9417. value: '.'
  9418. })
  9419. ],
  9420. expression: new U2.AST_Dot({
  9421. expression: new U2.AST_SymbolRef({
  9422. name: 'host'
  9423. }),
  9424. property: 'split'
  9425. })
  9426. })
  9427. });
  9428. return this.between(val, condition.minValue + 1, condition.maxValue + 1, condition.minValue + " <= hostLevels <= " + condition.maxValue);
  9429. },
  9430. str: function(condition) {
  9431. return condition.minValue + '~' + condition.maxValue;
  9432. },
  9433. fromStr: function(str, condition) {
  9434. var maxValue, minValue, ref1;
  9435. ref1 = str.split('~'), minValue = ref1[0], maxValue = ref1[1];
  9436. condition.minValue = parseInt(minValue, 10);
  9437. condition.maxValue = parseInt(maxValue, 10);
  9438. if (!(condition.minValue > 0)) {
  9439. condition.minValue = 1;
  9440. }
  9441. if (!(condition.maxValue > 0)) {
  9442. condition.maxValue = 1;
  9443. }
  9444. return condition;
  9445. }
  9446. },
  9447. 'WeekdayCondition': {
  9448. abbrs: ['WD', 'Week', 'Day', 'Weekday'],
  9449. analyze: function(condition) {
  9450. return null;
  9451. },
  9452. match: function(condition, request) {
  9453. var day;
  9454. day = new Date().getDay();
  9455. if (condition.days) {
  9456. return condition.days.charCodeAt(day) > 64;
  9457. }
  9458. return condition.startDay <= day && day <= condition.endDay;
  9459. },
  9460. compile: function(condition) {
  9461. var getDay;
  9462. getDay = new U2.AST_Call({
  9463. args: [],
  9464. expression: new U2.AST_Dot({
  9465. property: 'getDay',
  9466. expression: new U2.AST_New({
  9467. args: [],
  9468. expression: new U2.AST_SymbolRef({
  9469. name: 'Date'
  9470. })
  9471. })
  9472. })
  9473. });
  9474. if (condition.days) {
  9475. return new U2.AST_Binary({
  9476. left: new U2.AST_Call({
  9477. expression: new U2.AST_Dot({
  9478. expression: new U2.AST_String({
  9479. value: condition.days
  9480. }),
  9481. property: 'charCodeAt'
  9482. }),
  9483. args: [getDay]
  9484. }),
  9485. operator: '>',
  9486. right: new U2.AST_Number({
  9487. value: 64
  9488. })
  9489. });
  9490. } else {
  9491. return this.between(getDay, condition.startDay, condition.endDay);
  9492. }
  9493. },
  9494. str: function(condition) {
  9495. if (condition.days) {
  9496. return condition.days;
  9497. } else {
  9498. return condition.startDay + '~' + condition.endDay;
  9499. }
  9500. },
  9501. fromStr: function(str, condition) {
  9502. var endDay, ref1, ref2, ref3, startDay;
  9503. if (str.indexOf('~') < 0 && str.length === 7) {
  9504. condition.days = str;
  9505. } else {
  9506. ref1 = str.split('~'), startDay = ref1[0], endDay = ref1[1];
  9507. condition.startDay = parseInt(startDay, 10);
  9508. condition.endDay = parseInt(endDay, 10);
  9509. if (!((0 <= (ref2 = condition.startDay) && ref2 <= 6))) {
  9510. condition.startDay = 0;
  9511. }
  9512. if (!((0 <= (ref3 = condition.endDay) && ref3 <= 6))) {
  9513. condition.endDay = 0;
  9514. }
  9515. }
  9516. return condition;
  9517. }
  9518. },
  9519. 'TimeCondition': {
  9520. abbrs: ['T', 'Time', 'Hour'],
  9521. analyze: function(condition) {
  9522. return null;
  9523. },
  9524. match: function(condition, request) {
  9525. var hour;
  9526. hour = new Date().getHours();
  9527. return condition.startHour <= hour && hour <= condition.endHour;
  9528. },
  9529. compile: function(condition) {
  9530. var val;
  9531. val = new U2.AST_Call({
  9532. args: [],
  9533. expression: new U2.AST_Dot({
  9534. property: 'getHours',
  9535. expression: new U2.AST_New({
  9536. args: [],
  9537. expression: new U2.AST_SymbolRef({
  9538. name: 'Date'
  9539. })
  9540. })
  9541. })
  9542. });
  9543. return this.between(val, condition.startHour, condition.endHour);
  9544. },
  9545. str: function(condition) {
  9546. return condition.startHour + '~' + condition.endHour;
  9547. },
  9548. fromStr: function(str, condition) {
  9549. var endHour, ref1, ref2, ref3, startHour;
  9550. ref1 = str.split('~'), startHour = ref1[0], endHour = ref1[1];
  9551. condition.startHour = parseInt(startHour, 10);
  9552. condition.endHour = parseInt(endHour, 10);
  9553. if (!((0 <= (ref2 = condition.startHour) && ref2 < 24))) {
  9554. condition.startHour = 0;
  9555. }
  9556. if (!((0 <= (ref3 = condition.endHour) && ref3 < 24))) {
  9557. condition.endHour = 0;
  9558. }
  9559. return condition;
  9560. }
  9561. }
  9562. }
  9563. };
  9564. },{"./shexp_utils":65,"./utils":66,"ip-address":5,"uglify-js":67,"url":60}],62:[function(require,module,exports){
  9565. var Profiles, U2;
  9566. U2 = require('uglify-js');
  9567. Profiles = require('./profiles');
  9568. module.exports = {
  9569. ascii: function(str) {
  9570. return str.replace(/[\u0080-\uffff]/g, function(char) {
  9571. var _, hex, i, ref, result;
  9572. hex = char.charCodeAt(0).toString(16);
  9573. result = '\\u';
  9574. for (_ = i = ref = hex.length; ref <= 4 ? i < 4 : i > 4; _ = ref <= 4 ? ++i : --i) {
  9575. result += '0';
  9576. }
  9577. result += hex;
  9578. return result;
  9579. });
  9580. },
  9581. compress: function(ast) {
  9582. var compressed_ast, compressor;
  9583. ast.figure_out_scope();
  9584. compressor = U2.Compressor({
  9585. warnings: false,
  9586. keep_fargs: true
  9587. }, {
  9588. if_return: false
  9589. });
  9590. compressed_ast = ast.transform(compressor);
  9591. compressed_ast.figure_out_scope();
  9592. compressed_ast.compute_char_frequency();
  9593. compressed_ast.mangle_names();
  9594. return compressed_ast;
  9595. },
  9596. script: function(options, profile, args) {
  9597. var factory, key, name, p, profiles, refs;
  9598. if (typeof profile === 'string') {
  9599. profile = Profiles.byName(profile, options);
  9600. }
  9601. refs = Profiles.allReferenceSet(profile, options, {
  9602. profileNotFound: args != null ? args.profileNotFound : void 0
  9603. });
  9604. profiles = new U2.AST_Object({
  9605. properties: (function() {
  9606. var results;
  9607. results = [];
  9608. for (key in refs) {
  9609. name = refs[key];
  9610. if (!(key !== '+direct')) {
  9611. continue;
  9612. }
  9613. p = typeof profile === 'object' && profile.name === name ? profile : Profiles.byName(name, options);
  9614. if (p == null) {
  9615. p = Profiles.profileNotFound(name, args != null ? args.profileNotFound : void 0);
  9616. }
  9617. results.push(new U2.AST_ObjectKeyVal({
  9618. key: key,
  9619. value: Profiles.compile(p)
  9620. }));
  9621. }
  9622. return results;
  9623. })()
  9624. });
  9625. factory = new U2.AST_Function({
  9626. argnames: [
  9627. new U2.AST_SymbolFunarg({
  9628. name: 'init'
  9629. }), new U2.AST_SymbolFunarg({
  9630. name: 'profiles'
  9631. })
  9632. ],
  9633. body: [
  9634. new U2.AST_Return({
  9635. value: new U2.AST_Function({
  9636. argnames: [
  9637. new U2.AST_SymbolFunarg({
  9638. name: 'url'
  9639. }), new U2.AST_SymbolFunarg({
  9640. name: 'host'
  9641. })
  9642. ],
  9643. body: [
  9644. new U2.AST_Directive({
  9645. value: 'use strict'
  9646. }), new U2.AST_Var({
  9647. definitions: [
  9648. new U2.AST_VarDef({
  9649. name: new U2.AST_SymbolVar({
  9650. name: 'result'
  9651. }),
  9652. value: new U2.AST_SymbolRef({
  9653. name: 'init'
  9654. })
  9655. }), new U2.AST_VarDef({
  9656. name: new U2.AST_SymbolVar({
  9657. name: 'scheme'
  9658. }),
  9659. value: new U2.AST_Call({
  9660. expression: new U2.AST_Dot({
  9661. expression: new U2.AST_SymbolRef({
  9662. name: 'url'
  9663. }),
  9664. property: 'substr'
  9665. }),
  9666. args: [
  9667. new U2.AST_Number({
  9668. value: 0
  9669. }), new U2.AST_Call({
  9670. expression: new U2.AST_Dot({
  9671. expression: new U2.AST_SymbolRef({
  9672. name: 'url'
  9673. }),
  9674. property: 'indexOf'
  9675. }),
  9676. args: [
  9677. new U2.AST_String({
  9678. value: ':'
  9679. })
  9680. ]
  9681. })
  9682. ]
  9683. })
  9684. })
  9685. ]
  9686. }), new U2.AST_Do({
  9687. body: new U2.AST_BlockStatement({
  9688. body: [
  9689. new U2.AST_SimpleStatement({
  9690. body: new U2.AST_Assign({
  9691. left: new U2.AST_SymbolRef({
  9692. name: 'result'
  9693. }),
  9694. operator: '=',
  9695. right: new U2.AST_Sub({
  9696. expression: new U2.AST_SymbolRef({
  9697. name: 'profiles'
  9698. }),
  9699. property: new U2.AST_SymbolRef({
  9700. name: 'result'
  9701. })
  9702. })
  9703. })
  9704. }), new U2.AST_If({
  9705. condition: new U2.AST_Binary({
  9706. left: new U2.AST_UnaryPrefix({
  9707. operator: 'typeof',
  9708. expression: new U2.AST_SymbolRef({
  9709. name: 'result'
  9710. })
  9711. }),
  9712. operator: '===',
  9713. right: new U2.AST_String({
  9714. value: 'function'
  9715. })
  9716. }),
  9717. body: new U2.AST_SimpleStatement({
  9718. body: new U2.AST_Assign({
  9719. left: new U2.AST_SymbolRef({
  9720. name: 'result'
  9721. }),
  9722. operator: '=',
  9723. right: new U2.AST_Call({
  9724. expression: new U2.AST_SymbolRef({
  9725. name: 'result'
  9726. }),
  9727. args: [
  9728. new U2.AST_SymbolRef({
  9729. name: 'url'
  9730. }), new U2.AST_SymbolRef({
  9731. name: 'host'
  9732. }), new U2.AST_SymbolRef({
  9733. name: 'scheme'
  9734. })
  9735. ]
  9736. })
  9737. })
  9738. })
  9739. })
  9740. ]
  9741. }),
  9742. condition: new U2.AST_Binary({
  9743. left: new U2.AST_Binary({
  9744. left: new U2.AST_UnaryPrefix({
  9745. operator: 'typeof',
  9746. expression: new U2.AST_SymbolRef({
  9747. name: 'result'
  9748. })
  9749. }),
  9750. operator: '!==',
  9751. right: new U2.AST_String({
  9752. value: 'string'
  9753. })
  9754. }),
  9755. operator: '||',
  9756. right: new U2.AST_Binary({
  9757. left: new U2.AST_Call({
  9758. expression: new U2.AST_Dot({
  9759. expression: new U2.AST_SymbolRef({
  9760. name: 'result'
  9761. }),
  9762. property: 'charCodeAt'
  9763. }),
  9764. args: [
  9765. new U2.AST_Number({
  9766. value: 0
  9767. })
  9768. ]
  9769. }),
  9770. operator: '===',
  9771. right: new U2.AST_Number({
  9772. value: '+'.charCodeAt(0)
  9773. })
  9774. })
  9775. })
  9776. }), new U2.AST_Return({
  9777. value: new U2.AST_SymbolRef({
  9778. name: 'result'
  9779. })
  9780. })
  9781. ]
  9782. })
  9783. })
  9784. ]
  9785. });
  9786. return new U2.AST_Toplevel({
  9787. body: [
  9788. new U2.AST_Var({
  9789. definitions: [
  9790. new U2.AST_VarDef({
  9791. name: new U2.AST_SymbolVar({
  9792. name: 'FindProxyForURL'
  9793. }),
  9794. value: new U2.AST_Call({
  9795. expression: factory,
  9796. args: [Profiles.profileResult(profile.name), profiles]
  9797. })
  9798. })
  9799. ]
  9800. })
  9801. ]
  9802. });
  9803. }
  9804. };
  9805. },{"./profiles":63,"uglify-js":67}],63:[function(require,module,exports){
  9806. var AST_Raw, AttachedCache, Conditions, Revision, RuleList, ShexpUtils, U2, exports, ref1,
  9807. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  9808. hasProp = {}.hasOwnProperty;
  9809. U2 = require('uglify-js');
  9810. ShexpUtils = require('./shexp_utils');
  9811. Conditions = require('./conditions');
  9812. RuleList = require('./rule_list');
  9813. ref1 = require('./utils'), AttachedCache = ref1.AttachedCache, Revision = ref1.Revision;
  9814. AST_Raw = (function(superClass) {
  9815. extend(AST_Raw, superClass);
  9816. function AST_Raw(raw) {
  9817. U2.AST_SymbolRef.call(this, {
  9818. name: raw
  9819. });
  9820. this.aborts = function() {
  9821. return false;
  9822. };
  9823. }
  9824. return AST_Raw;
  9825. })(U2.AST_SymbolRef);
  9826. module.exports = exports = {
  9827. builtinProfiles: {
  9828. '+direct': {
  9829. name: 'direct',
  9830. profileType: 'DirectProfile',
  9831. color: '#aaaaaa',
  9832. builtin: true
  9833. },
  9834. '+system': {
  9835. name: 'system',
  9836. profileType: 'SystemProfile',
  9837. color: '#000000',
  9838. builtin: true
  9839. }
  9840. },
  9841. schemes: [
  9842. {
  9843. scheme: 'http',
  9844. prop: 'proxyForHttp'
  9845. }, {
  9846. scheme: 'https',
  9847. prop: 'proxyForHttps'
  9848. }, {
  9849. scheme: 'ftp',
  9850. prop: 'proxyForFtp'
  9851. }, {
  9852. scheme: '',
  9853. prop: 'fallbackProxy'
  9854. }
  9855. ],
  9856. pacProtocols: {
  9857. 'http': 'PROXY',
  9858. 'https': 'HTTPS',
  9859. 'socks4': 'SOCKS',
  9860. 'socks5': 'SOCKS5'
  9861. },
  9862. formatByType: {
  9863. 'SwitchyRuleListProfile': 'Switchy',
  9864. 'AutoProxyRuleListProfile': 'AutoProxy'
  9865. },
  9866. ruleListFormats: ['Switchy', 'AutoProxy'],
  9867. parseHostPort: function(str, scheme) {
  9868. var host, port, sep;
  9869. sep = str.lastIndexOf(':');
  9870. if (sep < 0) {
  9871. return;
  9872. }
  9873. port = parseInt(str.substr(sep + 1)) || 80;
  9874. host = str.substr(0, sep);
  9875. if (!host) {
  9876. return;
  9877. }
  9878. return {
  9879. scheme: scheme,
  9880. host: host,
  9881. port: port
  9882. };
  9883. },
  9884. pacResult: function(proxy) {
  9885. if (proxy) {
  9886. if (proxy.scheme === 'socks5') {
  9887. return "SOCKS5 " + proxy.host + ":" + proxy.port + "; SOCKS " + proxy.host + ":" + proxy.port;
  9888. } else {
  9889. return exports.pacProtocols[proxy.scheme] + " " + proxy.host + ":" + proxy.port;
  9890. }
  9891. } else {
  9892. return 'DIRECT';
  9893. }
  9894. },
  9895. isFileUrl: function(url) {
  9896. return !!((url != null ? url.substr(0, 5).toUpperCase() : void 0) === 'FILE:');
  9897. },
  9898. nameAsKey: function(profileName) {
  9899. if (typeof profileName !== 'string') {
  9900. profileName = profileName.name;
  9901. }
  9902. return '+' + profileName;
  9903. },
  9904. byName: function(profileName, options) {
  9905. var key, ref2;
  9906. if (typeof profileName === 'string') {
  9907. key = exports.nameAsKey(profileName);
  9908. profileName = (ref2 = exports.builtinProfiles[key]) != null ? ref2 : options[key];
  9909. }
  9910. return profileName;
  9911. },
  9912. byKey: function(key, options) {
  9913. var ref2;
  9914. if (typeof key === 'string') {
  9915. key = (ref2 = exports.builtinProfiles[key]) != null ? ref2 : options[key];
  9916. }
  9917. return key;
  9918. },
  9919. each: function(options, callback) {
  9920. var charCodePlus, key, profile, ref2, results;
  9921. charCodePlus = '+'.charCodeAt(0);
  9922. for (key in options) {
  9923. profile = options[key];
  9924. if (key.charCodeAt(0) === charCodePlus) {
  9925. callback(key, profile);
  9926. }
  9927. }
  9928. ref2 = exports.builtinProfiles;
  9929. results = [];
  9930. for (key in ref2) {
  9931. profile = ref2[key];
  9932. if (key.charCodeAt(0) === charCodePlus) {
  9933. results.push(callback(key, profile));
  9934. } else {
  9935. results.push(void 0);
  9936. }
  9937. }
  9938. return results;
  9939. },
  9940. profileResult: function(profileName) {
  9941. var key;
  9942. key = exports.nameAsKey(profileName);
  9943. if (key === '+direct') {
  9944. key = exports.pacResult();
  9945. }
  9946. return new U2.AST_String({
  9947. value: key
  9948. });
  9949. },
  9950. isIncludable: function(profile) {
  9951. var includable;
  9952. includable = exports._handler(profile).includable;
  9953. if (typeof includable === 'function') {
  9954. includable = includable.call(exports, profile);
  9955. }
  9956. return !!includable;
  9957. },
  9958. isInclusive: function(profile) {
  9959. return !!exports._handler(profile).inclusive;
  9960. },
  9961. updateUrl: function(profile) {
  9962. var ref2;
  9963. return (ref2 = exports._handler(profile).updateUrl) != null ? ref2.call(exports, profile) : void 0;
  9964. },
  9965. updateContentTypeHints: function(profile) {
  9966. var ref2;
  9967. return (ref2 = exports._handler(profile).updateContentTypeHints) != null ? ref2.call(exports, profile) : void 0;
  9968. },
  9969. update: function(profile, data) {
  9970. return exports._handler(profile).update.call(exports, profile, data);
  9971. },
  9972. tag: function(profile) {
  9973. return exports._profileCache.tag(profile);
  9974. },
  9975. create: function(profile, opt_profileType) {
  9976. var create;
  9977. if (typeof profile === 'string') {
  9978. profile = {
  9979. name: profile,
  9980. profileType: opt_profileType
  9981. };
  9982. } else if (opt_profileType) {
  9983. profile.profileType = opt_profileType;
  9984. }
  9985. create = exports._handler(profile).create;
  9986. if (!create) {
  9987. return profile;
  9988. }
  9989. create.call(exports, profile);
  9990. return profile;
  9991. },
  9992. updateRevision: function(profile, revision) {
  9993. if (revision == null) {
  9994. revision = Revision.fromTime();
  9995. }
  9996. return profile.revision = revision;
  9997. },
  9998. replaceRef: function(profile, fromName, toName) {
  9999. var handler;
  10000. if (!exports.isInclusive(profile)) {
  10001. return false;
  10002. }
  10003. handler = exports._handler(profile);
  10004. return handler.replaceRef.call(exports, profile, fromName, toName);
  10005. },
  10006. analyze: function(profile) {
  10007. var analyze, cache, result;
  10008. cache = exports._profileCache.get(profile, {});
  10009. if (!Object.prototype.hasOwnProperty.call(cache, 'analyzed')) {
  10010. analyze = exports._handler(profile).analyze;
  10011. result = analyze != null ? analyze.call(exports, profile) : void 0;
  10012. cache.analyzed = result;
  10013. }
  10014. return cache;
  10015. },
  10016. dropCache: function(profile) {
  10017. return exports._profileCache.drop(profile);
  10018. },
  10019. directReferenceSet: function(profile) {
  10020. var cache, handler;
  10021. if (!exports.isInclusive(profile)) {
  10022. return {};
  10023. }
  10024. cache = exports._profileCache.get(profile, {});
  10025. if (cache.directReferenceSet) {
  10026. return cache.directReferenceSet;
  10027. }
  10028. handler = exports._handler(profile);
  10029. return cache.directReferenceSet = handler.directReferenceSet.call(exports, profile);
  10030. },
  10031. profileNotFound: function(name, action) {
  10032. if (action == null) {
  10033. throw new Error("Profile " + name + " does not exist!");
  10034. }
  10035. if (typeof action === 'function') {
  10036. action = action(name);
  10037. }
  10038. if (typeof action === 'object' && action.profileType) {
  10039. return action;
  10040. }
  10041. switch (action) {
  10042. case 'ignore':
  10043. return null;
  10044. case 'dumb':
  10045. return exports.create({
  10046. name: name,
  10047. profileType: 'VirtualProfile',
  10048. defaultProfileName: 'direct'
  10049. });
  10050. }
  10051. throw action;
  10052. },
  10053. allReferenceSet: function(profile, options, opt_args) {
  10054. var has_out, key, name, o_profile, ref2, result;
  10055. o_profile = profile;
  10056. profile = exports.byName(profile, options);
  10057. if (profile == null) {
  10058. profile = typeof exports.profileNotFound === "function" ? exports.profileNotFound(o_profile, opt_args.profileNotFound) : void 0;
  10059. }
  10060. if (opt_args == null) {
  10061. opt_args = {};
  10062. }
  10063. has_out = opt_args.out != null;
  10064. result = opt_args.out != null ? opt_args.out : opt_args.out = {};
  10065. if (profile) {
  10066. result[exports.nameAsKey(profile.name)] = profile.name;
  10067. ref2 = exports.directReferenceSet(profile);
  10068. for (key in ref2) {
  10069. name = ref2[key];
  10070. exports.allReferenceSet(name, options, opt_args);
  10071. }
  10072. }
  10073. if (!has_out) {
  10074. delete opt_args.out;
  10075. }
  10076. return result;
  10077. },
  10078. referencedBySet: function(profile, options, opt_args) {
  10079. var has_out, profileKey, result;
  10080. profileKey = exports.nameAsKey(profile);
  10081. if (opt_args == null) {
  10082. opt_args = {};
  10083. }
  10084. has_out = opt_args.out != null;
  10085. result = opt_args.out != null ? opt_args.out : opt_args.out = {};
  10086. exports.each(options, function(key, prof) {
  10087. if (exports.directReferenceSet(prof)[profileKey]) {
  10088. result[key] = prof.name;
  10089. return exports.referencedBySet(prof, options, opt_args);
  10090. }
  10091. });
  10092. if (!has_out) {
  10093. delete opt_args.out;
  10094. }
  10095. return result;
  10096. },
  10097. validResultProfilesFor: function(profile, options) {
  10098. var profileKey, ref, result;
  10099. profile = exports.byName(profile, options);
  10100. if (!exports.isInclusive(profile)) {
  10101. return [];
  10102. }
  10103. profileKey = exports.nameAsKey(profile);
  10104. ref = exports.referencedBySet(profile, options);
  10105. ref[profileKey] = profileKey;
  10106. result = [];
  10107. exports.each(options, function(key, prof) {
  10108. if (!ref[key] && exports.isIncludable(prof)) {
  10109. return result.push(prof);
  10110. }
  10111. });
  10112. return result;
  10113. },
  10114. match: function(profile, request, opt_profileType) {
  10115. var cache, match;
  10116. if (opt_profileType == null) {
  10117. opt_profileType = profile.profileType;
  10118. }
  10119. cache = exports.analyze(profile);
  10120. match = exports._handler(opt_profileType).match;
  10121. return match != null ? match.call(exports, profile, request, cache) : void 0;
  10122. },
  10123. compile: function(profile, opt_profileType) {
  10124. var cache, handler;
  10125. if (opt_profileType == null) {
  10126. opt_profileType = profile.profileType;
  10127. }
  10128. cache = exports.analyze(profile);
  10129. if (cache.compiled) {
  10130. return cache.compiled;
  10131. }
  10132. handler = exports._handler(opt_profileType);
  10133. return cache.compiled = handler.compile.call(exports, profile, cache);
  10134. },
  10135. _profileCache: new AttachedCache(function(profile) {
  10136. return profile.revision;
  10137. }),
  10138. _handler: function(profileType) {
  10139. var handler;
  10140. if (typeof profileType !== 'string') {
  10141. profileType = profileType.profileType;
  10142. }
  10143. handler = profileType;
  10144. while (typeof handler === 'string') {
  10145. handler = exports._profileTypes[handler];
  10146. }
  10147. if (handler == null) {
  10148. throw new Error("Unknown profile type: " + profileType);
  10149. }
  10150. return handler;
  10151. },
  10152. _profileTypes: {
  10153. 'SystemProfile': {
  10154. compile: function(profile) {
  10155. throw new Error("SystemProfile cannot be used in PAC scripts");
  10156. }
  10157. },
  10158. 'DirectProfile': {
  10159. includable: true,
  10160. compile: function(profile) {
  10161. return new U2.AST_String({
  10162. value: this.pacResult()
  10163. });
  10164. }
  10165. },
  10166. 'FixedProfile': {
  10167. includable: true,
  10168. create: function(profile) {
  10169. return profile.bypassList != null ? profile.bypassList : profile.bypassList = [
  10170. {
  10171. conditionType: 'BypassCondition',
  10172. pattern: '127.0.0.1'
  10173. }, {
  10174. conditionType: 'BypassCondition',
  10175. pattern: '[::1]'
  10176. }, {
  10177. conditionType: 'BypassCondition',
  10178. pattern: 'localhost'
  10179. }
  10180. ];
  10181. },
  10182. match: function(profile, request) {
  10183. var cond, i, j, len, len1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, s;
  10184. if (profile.bypassList) {
  10185. ref2 = profile.bypassList;
  10186. for (i = 0, len = ref2.length; i < len; i++) {
  10187. cond = ref2[i];
  10188. if (Conditions.match(cond, request)) {
  10189. return [
  10190. this.pacResult(), cond, {
  10191. scheme: 'direct'
  10192. }, void 0
  10193. ];
  10194. }
  10195. }
  10196. }
  10197. ref3 = this.schemes;
  10198. for (j = 0, len1 = ref3.length; j < len1; j++) {
  10199. s = ref3[j];
  10200. if (s.scheme === request.scheme && profile[s.prop]) {
  10201. return [this.pacResult(profile[s.prop]), s.scheme, profile[s.prop], (ref4 = (ref5 = profile.auth) != null ? ref5[s.prop] : void 0) != null ? ref4 : (ref6 = profile.auth) != null ? ref6['all'] : void 0];
  10202. }
  10203. }
  10204. return [this.pacResult(profile.fallbackProxy), '', profile.fallbackProxy, (ref7 = (ref8 = profile.auth) != null ? ref8.fallbackProxy : void 0) != null ? ref7 : (ref9 = profile.auth) != null ? ref9['all'] : void 0];
  10205. },
  10206. compile: function(profile) {
  10207. var body, cond, condition, conditions, i, len, ref2, ret, s;
  10208. if ((!profile.bypassList || !profile.fallbackProxy) && !profile.proxyForHttp && !profile.proxyForHttps && !profile.proxyForFtp) {
  10209. return new U2.AST_String({
  10210. value: this.pacResult(profile.fallbackProxy)
  10211. });
  10212. }
  10213. body = [
  10214. new U2.AST_Directive({
  10215. value: 'use strict'
  10216. })
  10217. ];
  10218. if (profile.bypassList && profile.bypassList.length) {
  10219. conditions = null;
  10220. ref2 = profile.bypassList;
  10221. for (i = 0, len = ref2.length; i < len; i++) {
  10222. cond = ref2[i];
  10223. condition = Conditions.compile(cond);
  10224. if (conditions != null) {
  10225. conditions = new U2.AST_Binary({
  10226. left: conditions,
  10227. operator: '||',
  10228. right: condition
  10229. });
  10230. } else {
  10231. conditions = condition;
  10232. }
  10233. }
  10234. body.push(new U2.AST_If({
  10235. condition: conditions,
  10236. body: new U2.AST_Return({
  10237. value: new U2.AST_String({
  10238. value: this.pacResult()
  10239. })
  10240. })
  10241. }));
  10242. }
  10243. if (!profile.proxyForHttp && !profile.proxyForHttps && !profile.proxyForFtp) {
  10244. body.push(new U2.AST_Return({
  10245. value: new U2.AST_String({
  10246. value: this.pacResult(profile.fallbackProxy)
  10247. })
  10248. }));
  10249. } else {
  10250. body.push(new U2.AST_Switch({
  10251. expression: new U2.AST_SymbolRef({
  10252. name: 'scheme'
  10253. }),
  10254. body: (function() {
  10255. var j, len1, ref3, results;
  10256. ref3 = this.schemes;
  10257. results = [];
  10258. for (j = 0, len1 = ref3.length; j < len1; j++) {
  10259. s = ref3[j];
  10260. if (!(!s.scheme || profile[s.prop])) {
  10261. continue;
  10262. }
  10263. ret = [
  10264. new U2.AST_Return({
  10265. value: new U2.AST_String({
  10266. value: this.pacResult(profile[s.prop])
  10267. })
  10268. })
  10269. ];
  10270. if (s.scheme) {
  10271. results.push(new U2.AST_Case({
  10272. expression: new U2.AST_String({
  10273. value: s.scheme
  10274. }),
  10275. body: ret
  10276. }));
  10277. } else {
  10278. results.push(new U2.AST_Default({
  10279. body: ret
  10280. }));
  10281. }
  10282. }
  10283. return results;
  10284. }).call(this)
  10285. }));
  10286. }
  10287. return new U2.AST_Function({
  10288. argnames: [
  10289. new U2.AST_SymbolFunarg({
  10290. name: 'url'
  10291. }), new U2.AST_SymbolFunarg({
  10292. name: 'host'
  10293. }), new U2.AST_SymbolFunarg({
  10294. name: 'scheme'
  10295. })
  10296. ],
  10297. body: body
  10298. });
  10299. }
  10300. },
  10301. 'PacProfile': {
  10302. includable: function(profile) {
  10303. return !this.isFileUrl(profile.pacUrl);
  10304. },
  10305. create: function(profile) {
  10306. return profile.pacScript != null ? profile.pacScript : profile.pacScript = 'function FindProxyForURL(url, host) {\n return "DIRECT";\n}';
  10307. },
  10308. compile: function(profile) {
  10309. return new U2.AST_Call({
  10310. args: [new U2.AST_This],
  10311. expression: new U2.AST_Dot({
  10312. property: 'call',
  10313. expression: new U2.AST_Function({
  10314. argnames: [],
  10315. body: [
  10316. new AST_Raw(';\n' + profile.pacScript + '\n\n/* End of PAC */;'), new U2.AST_Return({
  10317. value: new U2.AST_SymbolRef({
  10318. name: 'FindProxyForURL'
  10319. })
  10320. })
  10321. ]
  10322. })
  10323. })
  10324. });
  10325. },
  10326. updateUrl: function(profile) {
  10327. if (this.isFileUrl(profile.pacUrl)) {
  10328. return void 0;
  10329. } else {
  10330. return profile.pacUrl;
  10331. }
  10332. },
  10333. updateContentTypeHints: function() {
  10334. return ['!text/html', '!application/xhtml+xml', 'application/x-ns-proxy-autoconfig', 'application/x-javascript-config'];
  10335. },
  10336. update: function(profile, data) {
  10337. if (profile.pacScript === data) {
  10338. return false;
  10339. }
  10340. profile.pacScript = data;
  10341. return true;
  10342. }
  10343. },
  10344. 'AutoDetectProfile': 'PacProfile',
  10345. 'SwitchProfile': {
  10346. includable: true,
  10347. inclusive: true,
  10348. create: function(profile) {
  10349. if (profile.defaultProfileName == null) {
  10350. profile.defaultProfileName = 'direct';
  10351. }
  10352. return profile.rules != null ? profile.rules : profile.rules = [];
  10353. },
  10354. directReferenceSet: function(profile) {
  10355. var i, len, ref2, refs, rule;
  10356. refs = {};
  10357. refs[exports.nameAsKey(profile.defaultProfileName)] = profile.defaultProfileName;
  10358. ref2 = profile.rules;
  10359. for (i = 0, len = ref2.length; i < len; i++) {
  10360. rule = ref2[i];
  10361. refs[exports.nameAsKey(rule.profileName)] = rule.profileName;
  10362. }
  10363. return refs;
  10364. },
  10365. analyze: function(profile) {
  10366. return profile.rules;
  10367. },
  10368. replaceRef: function(profile, fromName, toName) {
  10369. var changed, i, len, ref2, rule;
  10370. changed = false;
  10371. if (profile.defaultProfileName === fromName) {
  10372. profile.defaultProfileName = toName;
  10373. changed = true;
  10374. }
  10375. ref2 = profile.rules;
  10376. for (i = 0, len = ref2.length; i < len; i++) {
  10377. rule = ref2[i];
  10378. if (rule.profileName === fromName) {
  10379. rule.profileName = toName;
  10380. changed = true;
  10381. }
  10382. }
  10383. return changed;
  10384. },
  10385. match: function(profile, request, cache) {
  10386. var i, len, ref2, rule;
  10387. ref2 = cache.analyzed;
  10388. for (i = 0, len = ref2.length; i < len; i++) {
  10389. rule = ref2[i];
  10390. if (Conditions.match(rule.condition, request)) {
  10391. return rule;
  10392. }
  10393. }
  10394. return [exports.nameAsKey(profile.defaultProfileName), null];
  10395. },
  10396. compile: function(profile, cache) {
  10397. var body, i, len, rule, rules;
  10398. rules = cache.analyzed;
  10399. if (rules.length === 0) {
  10400. return this.profileResult(profile.defaultProfileName);
  10401. }
  10402. body = [
  10403. new U2.AST_Directive({
  10404. value: 'use strict'
  10405. })
  10406. ];
  10407. for (i = 0, len = rules.length; i < len; i++) {
  10408. rule = rules[i];
  10409. body.push(new U2.AST_If({
  10410. condition: Conditions.compile(rule.condition),
  10411. body: new U2.AST_Return({
  10412. value: this.profileResult(rule.profileName)
  10413. })
  10414. }));
  10415. }
  10416. body.push(new U2.AST_Return({
  10417. value: this.profileResult(profile.defaultProfileName)
  10418. }));
  10419. return new U2.AST_Function({
  10420. argnames: [
  10421. new U2.AST_SymbolFunarg({
  10422. name: 'url'
  10423. }), new U2.AST_SymbolFunarg({
  10424. name: 'host'
  10425. }), new U2.AST_SymbolFunarg({
  10426. name: 'scheme'
  10427. })
  10428. ],
  10429. body: body
  10430. });
  10431. }
  10432. },
  10433. 'VirtualProfile': 'SwitchProfile',
  10434. 'RuleListProfile': {
  10435. includable: true,
  10436. inclusive: true,
  10437. create: function(profile) {
  10438. var ref2;
  10439. if (profile.profileType == null) {
  10440. profile.profileType = 'RuleListProfile';
  10441. }
  10442. if (profile.format == null) {
  10443. profile.format = (ref2 = exports.formatByType[profile.profileType]) != null ? ref2 : 'Switchy';
  10444. }
  10445. if (profile.defaultProfileName == null) {
  10446. profile.defaultProfileName = 'direct';
  10447. }
  10448. if (profile.matchProfileName == null) {
  10449. profile.matchProfileName = 'direct';
  10450. }
  10451. return profile.ruleList != null ? profile.ruleList : profile.ruleList = '';
  10452. },
  10453. directReferenceSet: function(profile) {
  10454. var i, len, name, ref2, ref3, refs;
  10455. if (profile.ruleList != null) {
  10456. refs = (ref2 = RuleList[profile.format]) != null ? typeof ref2.directReferenceSet === "function" ? ref2.directReferenceSet(profile) : void 0 : void 0;
  10457. if (refs) {
  10458. return refs;
  10459. }
  10460. }
  10461. refs = {};
  10462. ref3 = [profile.matchProfileName, profile.defaultProfileName];
  10463. for (i = 0, len = ref3.length; i < len; i++) {
  10464. name = ref3[i];
  10465. refs[exports.nameAsKey(name)] = name;
  10466. }
  10467. return refs;
  10468. },
  10469. replaceRef: function(profile, fromName, toName) {
  10470. var changed;
  10471. changed = false;
  10472. if (profile.defaultProfileName === fromName) {
  10473. profile.defaultProfileName = toName;
  10474. changed = true;
  10475. }
  10476. if (profile.matchProfileName === fromName) {
  10477. profile.matchProfileName = toName;
  10478. changed = true;
  10479. }
  10480. return changed;
  10481. },
  10482. analyze: function(profile) {
  10483. var format, formatHandler, ref2, ref3, ruleList;
  10484. format = (ref2 = profile.format) != null ? ref2 : exports.formatByType[profile.profileType];
  10485. formatHandler = RuleList[format];
  10486. if (!formatHandler) {
  10487. throw new Error("Unsupported rule list format " + format + "!");
  10488. }
  10489. ruleList = ((ref3 = profile.ruleList) != null ? ref3.trim() : void 0) || '';
  10490. if (formatHandler.preprocess != null) {
  10491. ruleList = formatHandler.preprocess(ruleList);
  10492. }
  10493. return formatHandler.parse(ruleList, profile.matchProfileName, profile.defaultProfileName);
  10494. },
  10495. match: function(profile, request) {
  10496. var result;
  10497. return result = exports.match(profile, request, 'SwitchProfile');
  10498. },
  10499. compile: function(profile) {
  10500. return exports.compile(profile, 'SwitchProfile');
  10501. },
  10502. updateUrl: function(profile) {
  10503. return profile.sourceUrl;
  10504. },
  10505. updateContentTypeHints: function() {
  10506. return ['!text/html', '!application/xhtml+xml', 'text/plain', '*'];
  10507. },
  10508. update: function(profile, data) {
  10509. var base, base1, format, formatHandler, formatName, original, ref2, result;
  10510. data = data.trim();
  10511. original = (ref2 = profile.format) != null ? ref2 : exports.formatByType[profile.profileType];
  10512. profile.profileType = 'RuleListProfile';
  10513. format = original;
  10514. if ((typeof (base = RuleList[format]).detect === "function" ? base.detect(data) : void 0) === false) {
  10515. format = null;
  10516. }
  10517. for (formatName in RuleList) {
  10518. if (!hasProp.call(RuleList, formatName)) continue;
  10519. result = typeof (base1 = RuleList[formatName]).detect === "function" ? base1.detect(data) : void 0;
  10520. if (result === true || (result !== false && (format == null))) {
  10521. profile.format = format = formatName;
  10522. }
  10523. }
  10524. if (format == null) {
  10525. format = original;
  10526. }
  10527. formatHandler = RuleList[format];
  10528. if (formatHandler.preprocess != null) {
  10529. data = formatHandler.preprocess(data);
  10530. }
  10531. if (profile.ruleList === data) {
  10532. return false;
  10533. }
  10534. profile.ruleList = data;
  10535. return true;
  10536. }
  10537. },
  10538. 'SwitchyRuleListProfile': 'RuleListProfile',
  10539. 'AutoProxyRuleListProfile': 'RuleListProfile'
  10540. }
  10541. };
  10542. },{"./conditions":61,"./rule_list":64,"./shexp_utils":65,"./utils":66,"uglify-js":67}],64:[function(require,module,exports){
  10543. var Buffer, Conditions, exports, strStartsWith,
  10544. hasProp = {}.hasOwnProperty;
  10545. Buffer = require('buffer').Buffer;
  10546. Conditions = require('./conditions');
  10547. strStartsWith = function(str, prefix) {
  10548. return str.substr(0, prefix.length) === prefix;
  10549. };
  10550. module.exports = exports = {
  10551. 'AutoProxy': {
  10552. magicPrefix: 'W0F1dG9Qcm94',
  10553. detect: function(text) {
  10554. if (strStartsWith(text, exports['AutoProxy'].magicPrefix)) {
  10555. return true;
  10556. } else if (strStartsWith(text, '[AutoProxy')) {
  10557. return true;
  10558. }
  10559. },
  10560. preprocess: function(text) {
  10561. if (strStartsWith(text, exports['AutoProxy'].magicPrefix)) {
  10562. text = new Buffer(text, 'base64').toString('utf8');
  10563. }
  10564. return text;
  10565. },
  10566. parse: function(text, matchProfileName, defaultProfileName) {
  10567. var cond, exclusive_rules, i, len, line, list, normal_rules, profile, ref, source;
  10568. normal_rules = [];
  10569. exclusive_rules = [];
  10570. ref = text.split(/\n|\r/);
  10571. for (i = 0, len = ref.length; i < len; i++) {
  10572. line = ref[i];
  10573. line = line.trim();
  10574. if (line.length === 0 || line[0] === '!' || line[0] === '[') {
  10575. continue;
  10576. }
  10577. source = line;
  10578. profile = matchProfileName;
  10579. list = normal_rules;
  10580. if (line[0] === '@' && line[1] === '@') {
  10581. profile = defaultProfileName;
  10582. list = exclusive_rules;
  10583. line = line.substring(2);
  10584. }
  10585. cond = line[0] === '/' ? {
  10586. conditionType: 'UrlRegexCondition',
  10587. pattern: line.substring(1, line.length - 1)
  10588. } : line[0] === '|' ? line[1] === '|' ? {
  10589. conditionType: 'HostWildcardCondition',
  10590. pattern: "*." + line.substring(2)
  10591. } : {
  10592. conditionType: 'UrlWildcardCondition',
  10593. pattern: line.substring(1) + "*"
  10594. } : line.indexOf('*') < 0 ? {
  10595. conditionType: 'KeywordCondition',
  10596. pattern: line
  10597. } : {
  10598. conditionType: 'UrlWildcardCondition',
  10599. pattern: 'http://*' + line + '*'
  10600. };
  10601. list.push({
  10602. condition: cond,
  10603. profileName: profile,
  10604. source: source
  10605. });
  10606. }
  10607. return exclusive_rules.concat(normal_rules);
  10608. }
  10609. },
  10610. 'Switchy': {
  10611. omegaPrefix: '[SwitchyOmega Conditions',
  10612. specialLineStart: "[;#@!",
  10613. detect: function(text) {
  10614. if (strStartsWith(text, exports['Switchy'].omegaPrefix)) {
  10615. return true;
  10616. }
  10617. },
  10618. parse: function(text, matchProfileName, defaultProfileName) {
  10619. var parser, switchy;
  10620. switchy = exports['Switchy'];
  10621. parser = switchy.getParser(text);
  10622. return switchy[parser](text, matchProfileName, defaultProfileName);
  10623. },
  10624. directReferenceSet: function(arg) {
  10625. var defaultProfileName, i, iSpace, len, line, matchProfileName, parser, profile, ref, refs, ruleList, switchy, text;
  10626. ruleList = arg.ruleList, matchProfileName = arg.matchProfileName, defaultProfileName = arg.defaultProfileName;
  10627. text = ruleList.trim();
  10628. switchy = exports['Switchy'];
  10629. parser = switchy.getParser(text);
  10630. if (parser !== 'parseOmega') {
  10631. return;
  10632. }
  10633. if (!/(^|\n)@with\s+results?(\r|\n|$)/i.test(text)) {
  10634. return;
  10635. }
  10636. refs = {};
  10637. ref = text.split(/\n|\r/);
  10638. for (i = 0, len = ref.length; i < len; i++) {
  10639. line = ref[i];
  10640. line = line.trim();
  10641. if (switchy.specialLineStart.indexOf(line[0]) < 0) {
  10642. iSpace = line.lastIndexOf(' +');
  10643. if (iSpace < 0) {
  10644. profile = defaultProfileName || 'direct';
  10645. } else {
  10646. profile = line.substr(iSpace + 2).trim();
  10647. }
  10648. refs['+' + profile] = profile;
  10649. }
  10650. }
  10651. return refs;
  10652. },
  10653. compose: function(arg, arg1) {
  10654. var defaultProfileName, eol, i, len, line, ref, rule, ruleList, rules, specialLineStart, useExclusive, withResult;
  10655. rules = arg.rules, defaultProfileName = arg.defaultProfileName;
  10656. ref = arg1 != null ? arg1 : {}, withResult = ref.withResult, useExclusive = ref.useExclusive;
  10657. eol = '\r\n';
  10658. ruleList = '[SwitchyOmega Conditions]' + eol;
  10659. if (useExclusive == null) {
  10660. useExclusive = !withResult;
  10661. }
  10662. if (withResult) {
  10663. ruleList += '@with result' + eol + eol;
  10664. } else {
  10665. ruleList += eol;
  10666. }
  10667. specialLineStart = exports['Switchy'].specialLineStart + '+';
  10668. for (i = 0, len = rules.length; i < len; i++) {
  10669. rule = rules[i];
  10670. if (rule.note) {
  10671. ruleList += '@note ' + rule.note + eol;
  10672. }
  10673. line = Conditions.str(rule.condition);
  10674. if (useExclusive && rule.profileName === defaultProfileName) {
  10675. line = '!' + line;
  10676. } else {
  10677. if (specialLineStart.indexOf(line[0]) >= 0) {
  10678. line = ': ' + line;
  10679. }
  10680. if (withResult) {
  10681. line += ' +' + rule.profileName;
  10682. }
  10683. }
  10684. ruleList += line + eol;
  10685. }
  10686. if (withResult) {
  10687. ruleList += eol + '* +' + defaultProfileName + eol;
  10688. }
  10689. return ruleList;
  10690. },
  10691. getParser: function(text) {
  10692. var parser, switchy;
  10693. switchy = exports['Switchy'];
  10694. parser = 'parseOmega';
  10695. if (!strStartsWith(text, switchy.omegaPrefix)) {
  10696. if (text[0] === '#' || text.indexOf('\n#') >= 0) {
  10697. parser = 'parseLegacy';
  10698. }
  10699. }
  10700. return parser;
  10701. },
  10702. conditionFromLegacyWildcard: function(pattern) {
  10703. var host;
  10704. if (pattern[0] === '@') {
  10705. pattern = pattern.substring(1);
  10706. } else {
  10707. if (pattern.indexOf('://') <= 0 && pattern[0] !== '*') {
  10708. pattern = '*' + pattern;
  10709. }
  10710. if (pattern[pattern.length - 1] !== '*') {
  10711. pattern += '*';
  10712. }
  10713. }
  10714. host = Conditions.urlWildcard2HostWildcard(pattern);
  10715. if (host) {
  10716. return {
  10717. conditionType: 'HostWildcardCondition',
  10718. pattern: host
  10719. };
  10720. } else {
  10721. return {
  10722. conditionType: 'UrlWildcardCondition',
  10723. pattern: pattern
  10724. };
  10725. }
  10726. },
  10727. parseLegacy: function(text, matchProfileName, defaultProfileName) {
  10728. var begin, cond, exclusive_rules, i, len, line, list, normal_rules, profile, ref, section, source;
  10729. normal_rules = [];
  10730. exclusive_rules = [];
  10731. begin = false;
  10732. section = 'WILDCARD';
  10733. ref = text.split(/\n|\r/);
  10734. for (i = 0, len = ref.length; i < len; i++) {
  10735. line = ref[i];
  10736. line = line.trim();
  10737. if (line.length === 0 || line[0] === ';') {
  10738. continue;
  10739. }
  10740. if (!begin) {
  10741. if (line.toUpperCase() === '#BEGIN') {
  10742. begin = true;
  10743. }
  10744. continue;
  10745. }
  10746. if (line.toUpperCase() === '#END') {
  10747. break;
  10748. }
  10749. if (line[0] === '[' && line[line.length - 1] === ']') {
  10750. section = line.substring(1, line.length - 1).toUpperCase();
  10751. continue;
  10752. }
  10753. source = line;
  10754. profile = matchProfileName;
  10755. list = normal_rules;
  10756. if (line[0] === '!') {
  10757. profile = defaultProfileName;
  10758. list = exclusive_rules;
  10759. line = line.substring(1);
  10760. }
  10761. cond = (function() {
  10762. switch (section) {
  10763. case 'WILDCARD':
  10764. return exports['Switchy'].conditionFromLegacyWildcard(line);
  10765. case 'REGEXP':
  10766. return {
  10767. conditionType: 'UrlRegexCondition',
  10768. pattern: line
  10769. };
  10770. default:
  10771. return null;
  10772. }
  10773. })();
  10774. if (cond != null) {
  10775. list.push({
  10776. condition: cond,
  10777. profileName: profile,
  10778. source: source
  10779. });
  10780. }
  10781. }
  10782. return exclusive_rules.concat(normal_rules);
  10783. },
  10784. parseOmega: function(text, matchProfileName, defaultProfileName, args) {
  10785. var cond, directive, error, exclusiveProfile, feature, i, iSpace, includeSource, j, len, len1, line, lno, noteForNextRule, profile, ref, ref1, rule, rules, rulesWithDefaultProfile, source, strict, withResult;
  10786. if (args == null) {
  10787. args = {};
  10788. }
  10789. strict = args.strict;
  10790. if (strict) {
  10791. error = function(fields) {
  10792. var err, key, value;
  10793. err = new Error(fields.message);
  10794. for (key in fields) {
  10795. if (!hasProp.call(fields, key)) continue;
  10796. value = fields[key];
  10797. err[key] = value;
  10798. }
  10799. throw err;
  10800. };
  10801. }
  10802. includeSource = (ref = args.source) != null ? ref : true;
  10803. rules = [];
  10804. rulesWithDefaultProfile = [];
  10805. withResult = false;
  10806. exclusiveProfile = null;
  10807. noteForNextRule = null;
  10808. lno = 0;
  10809. ref1 = text.split(/\n|\r/);
  10810. for (i = 0, len = ref1.length; i < len; i++) {
  10811. line = ref1[i];
  10812. lno++;
  10813. line = line.trim();
  10814. if (line.length === 0) {
  10815. continue;
  10816. }
  10817. switch (line[0]) {
  10818. case '[':
  10819. continue;
  10820. case ';':
  10821. continue;
  10822. case '@':
  10823. iSpace = line.indexOf(' ');
  10824. if (iSpace < 0) {
  10825. iSpace = line.length;
  10826. }
  10827. directive = line.substr(1, iSpace - 1);
  10828. line = line.substr(iSpace + 1).trim();
  10829. switch (directive.toUpperCase()) {
  10830. case 'WITH':
  10831. feature = line.toUpperCase();
  10832. if (feature === 'RESULT' || feature === 'RESULTS') {
  10833. withResult = true;
  10834. }
  10835. break;
  10836. case 'NOTE':
  10837. noteForNextRule = line;
  10838. }
  10839. continue;
  10840. }
  10841. source = null;
  10842. if (strict) {
  10843. exclusiveProfile = null;
  10844. }
  10845. if (line[0] === '!') {
  10846. profile = withResult ? null : defaultProfileName;
  10847. source = line;
  10848. line = line.substr(1);
  10849. } else if (withResult) {
  10850. iSpace = line.lastIndexOf(' +');
  10851. if (iSpace < 0) {
  10852. if (typeof error === "function") {
  10853. error({
  10854. message: "Missing result profile name: " + line,
  10855. reason: 'missingResultProfile',
  10856. source: line,
  10857. sourceLineNo: lno
  10858. });
  10859. }
  10860. continue;
  10861. }
  10862. profile = line.substr(iSpace + 2).trim();
  10863. line = line.substr(0, iSpace).trim();
  10864. if (line === '*') {
  10865. exclusiveProfile = profile;
  10866. }
  10867. } else {
  10868. profile = matchProfileName;
  10869. }
  10870. cond = Conditions.fromStr(line);
  10871. if (!cond) {
  10872. if (typeof error === "function") {
  10873. error({
  10874. message: "Invalid rule: " + line,
  10875. reason: 'invalidRule',
  10876. source: source != null ? source : line,
  10877. sourceLineNo: lno
  10878. });
  10879. }
  10880. continue;
  10881. }
  10882. rule = {
  10883. condition: cond,
  10884. profileName: profile,
  10885. source: includeSource ? source != null ? source : line : void 0
  10886. };
  10887. if (noteForNextRule != null) {
  10888. rule.note = noteForNextRule;
  10889. noteForNextRule = null;
  10890. }
  10891. rules.push(rule);
  10892. if (!profile) {
  10893. rulesWithDefaultProfile.push(rule);
  10894. }
  10895. }
  10896. if (withResult) {
  10897. if (!exclusiveProfile) {
  10898. if (strict) {
  10899. if (typeof error === "function") {
  10900. error({
  10901. message: "Missing default rule with catch-all '*' condition",
  10902. reason: 'noDefaultRule'
  10903. });
  10904. }
  10905. }
  10906. exclusiveProfile = defaultProfileName || 'direct';
  10907. }
  10908. for (j = 0, len1 = rulesWithDefaultProfile.length; j < len1; j++) {
  10909. rule = rulesWithDefaultProfile[j];
  10910. rule.profileName = exclusiveProfile;
  10911. }
  10912. }
  10913. return rules;
  10914. }
  10915. }
  10916. };
  10917. },{"./conditions":61,"buffer":2}],65:[function(require,module,exports){
  10918. var exports;
  10919. module.exports = exports = {
  10920. regExpMetaChars: (function() {
  10921. var chars, i, j, ref, set;
  10922. chars = '\\[\^$.|?*+(){}/';
  10923. set = {};
  10924. for (i = j = 0, ref = chars.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  10925. set[chars.charCodeAt(i)] = true;
  10926. }
  10927. return set;
  10928. })(),
  10929. escapeSlash: function(pattern) {
  10930. var charCodeBackSlash, charCodeSlash, code, escaped, i, j, ref, result, start;
  10931. charCodeSlash = 47;
  10932. charCodeBackSlash = 92;
  10933. escaped = false;
  10934. start = 0;
  10935. result = '';
  10936. for (i = j = 0, ref = pattern.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
  10937. code = pattern.charCodeAt(i);
  10938. if (code === charCodeSlash && !escaped) {
  10939. result += pattern.substring(start, i);
  10940. result += '\\';
  10941. start = i;
  10942. }
  10943. escaped = code === charCodeBackSlash && !escaped;
  10944. }
  10945. return result += pattern.substr(start);
  10946. },
  10947. shExp2RegExp: function(pattern, options) {
  10948. var charCodeAsterisk, charCodeQuestion, code, end, i, j, ref, ref1, regex, start, trimAsterisk;
  10949. trimAsterisk = (options != null ? options.trimAsterisk : void 0) || false;
  10950. start = 0;
  10951. end = pattern.length;
  10952. charCodeAsterisk = 42;
  10953. charCodeQuestion = 63;
  10954. if (trimAsterisk) {
  10955. while (start < end && pattern.charCodeAt(start) === charCodeAsterisk) {
  10956. start++;
  10957. }
  10958. while (start < end && pattern.charCodeAt(end - 1) === charCodeAsterisk) {
  10959. end--;
  10960. }
  10961. if (end - start === 1 && pattern.charCodeAt(start) === charCodeAsterisk) {
  10962. return '';
  10963. }
  10964. }
  10965. regex = '';
  10966. if (start === 0) {
  10967. regex += '^';
  10968. }
  10969. for (i = j = ref = start, ref1 = end; ref <= ref1 ? j < ref1 : j > ref1; i = ref <= ref1 ? ++j : --j) {
  10970. code = pattern.charCodeAt(i);
  10971. switch (code) {
  10972. case charCodeAsterisk:
  10973. regex += '.*';
  10974. break;
  10975. case charCodeQuestion:
  10976. regex += '.';
  10977. break;
  10978. default:
  10979. if (exports.regExpMetaChars[code] >= 0) {
  10980. regex += '\\';
  10981. }
  10982. regex += pattern[i];
  10983. }
  10984. }
  10985. if (end === pattern.length) {
  10986. regex += '$';
  10987. }
  10988. return regex;
  10989. }
  10990. };
  10991. },{}],66:[function(require,module,exports){
  10992. var AttachedCache, Revision, Url, tld;
  10993. Revision = {
  10994. fromTime: function(time) {
  10995. time = time ? new Date(time) : new Date();
  10996. return time.getTime().toString(16);
  10997. },
  10998. compare: function(a, b) {
  10999. if (!a && !b) {
  11000. return 0;
  11001. }
  11002. if (!a) {
  11003. return -1;
  11004. }
  11005. if (!b) {
  11006. return 1;
  11007. }
  11008. if (a.length > b.length) {
  11009. return 1;
  11010. }
  11011. if (a.length < b.length) {
  11012. return -1;
  11013. }
  11014. if (a > b) {
  11015. return 1;
  11016. }
  11017. if (a < b) {
  11018. return -1;
  11019. }
  11020. return 0;
  11021. }
  11022. };
  11023. exports.Revision = Revision;
  11024. AttachedCache = (function() {
  11025. function AttachedCache(opt_prop, tag1) {
  11026. this.tag = tag1;
  11027. this.prop = opt_prop;
  11028. if (typeof this.tag === 'undefined') {
  11029. this.tag = opt_prop;
  11030. this.prop = '_cache';
  11031. }
  11032. }
  11033. AttachedCache.prototype.get = function(obj, otherwise) {
  11034. var cache, tag, value;
  11035. tag = this.tag(obj);
  11036. cache = this._getCache(obj);
  11037. if ((cache != null) && cache.tag === tag) {
  11038. return cache.value;
  11039. }
  11040. value = typeof otherwise === 'function' ? otherwise() : otherwise;
  11041. this._setCache(obj, {
  11042. tag: tag,
  11043. value: value
  11044. });
  11045. return value;
  11046. };
  11047. AttachedCache.prototype.drop = function(obj) {
  11048. if (obj[this.prop] != null) {
  11049. return obj[this.prop] = void 0;
  11050. }
  11051. };
  11052. AttachedCache.prototype._getCache = function(obj) {
  11053. return obj[this.prop];
  11054. };
  11055. AttachedCache.prototype._setCache = function(obj, value) {
  11056. if (!Object.prototype.hasOwnProperty.call(obj, this.prop)) {
  11057. Object.defineProperty(obj, this.prop, {
  11058. writable: true
  11059. });
  11060. }
  11061. return obj[this.prop] = value;
  11062. };
  11063. return AttachedCache;
  11064. })();
  11065. exports.AttachedCache = AttachedCache;
  11066. tld = require('tldjs');
  11067. exports.isIp = function(domain) {
  11068. var lastCharCode;
  11069. if (domain.indexOf(':') > 0) {
  11070. return true;
  11071. }
  11072. lastCharCode = domain.charCodeAt(domain.length - 1);
  11073. if ((48 <= lastCharCode && lastCharCode <= 57)) {
  11074. return true;
  11075. }
  11076. return false;
  11077. };
  11078. exports.getBaseDomain = function(domain) {
  11079. var ref;
  11080. if (exports.isIp(domain)) {
  11081. return domain;
  11082. }
  11083. return (ref = tld.getDomain(domain)) != null ? ref : domain;
  11084. };
  11085. exports.wildcardForDomain = function(domain) {
  11086. if (exports.isIp(domain)) {
  11087. return domain;
  11088. }
  11089. return '*.' + exports.getBaseDomain(domain);
  11090. };
  11091. Url = require('url');
  11092. exports.wildcardForUrl = function(url) {
  11093. var domain;
  11094. domain = Url.parse(url).hostname;
  11095. return exports.wildcardForDomain(domain);
  11096. };
  11097. },{"tldjs":45,"url":60}],67:[function(require,module,exports){
  11098. require('uglify-js-real');
  11099. module.exports = UglifyJS;
  11100. },{"uglify-js-real":68}],68:[function(require,module,exports){
  11101. (function(exports, global) {
  11102. global["UglifyJS"] = exports;
  11103. "use strict";
  11104. function array_to_hash(a) {
  11105. var ret = Object.create(null);
  11106. for (var i = 0; i < a.length; ++i) ret[a[i]] = true;
  11107. return ret;
  11108. }
  11109. function slice(a, start) {
  11110. return Array.prototype.slice.call(a, start || 0);
  11111. }
  11112. function characters(str) {
  11113. return str.split("");
  11114. }
  11115. function member(name, array) {
  11116. for (var i = array.length; --i >= 0; ) if (array[i] == name) return true;
  11117. return false;
  11118. }
  11119. function find_if(func, array) {
  11120. for (var i = 0, n = array.length; i < n; ++i) {
  11121. if (func(array[i])) return array[i];
  11122. }
  11123. }
  11124. function repeat_string(str, i) {
  11125. if (i <= 0) return "";
  11126. if (i == 1) return str;
  11127. var d = repeat_string(str, i >> 1);
  11128. d += d;
  11129. if (i & 1) d += str;
  11130. return d;
  11131. }
  11132. function DefaultsError(msg, defs) {
  11133. Error.call(this, msg);
  11134. this.msg = msg;
  11135. this.defs = defs;
  11136. }
  11137. DefaultsError.prototype = Object.create(Error.prototype);
  11138. DefaultsError.prototype.constructor = DefaultsError;
  11139. DefaultsError.croak = function(msg, defs) {
  11140. throw new DefaultsError(msg, defs);
  11141. };
  11142. function defaults(args, defs, croak) {
  11143. if (args === true) args = {};
  11144. var ret = args || {};
  11145. if (croak) for (var i in ret) if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i)) DefaultsError.croak("`" + i + "` is not a supported option", defs);
  11146. for (var i in defs) if (defs.hasOwnProperty(i)) {
  11147. ret[i] = args && args.hasOwnProperty(i) ? args[i] : defs[i];
  11148. }
  11149. return ret;
  11150. }
  11151. function merge(obj, ext) {
  11152. for (var i in ext) if (ext.hasOwnProperty(i)) {
  11153. obj[i] = ext[i];
  11154. }
  11155. return obj;
  11156. }
  11157. function noop() {}
  11158. var MAP = function() {
  11159. function MAP(a, f, backwards) {
  11160. var ret = [], top = [], i;
  11161. function doit() {
  11162. var val = f(a[i], i);
  11163. var is_last = val instanceof Last;
  11164. if (is_last) val = val.v;
  11165. if (val instanceof AtTop) {
  11166. val = val.v;
  11167. if (val instanceof Splice) {
  11168. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  11169. } else {
  11170. top.push(val);
  11171. }
  11172. } else if (val !== skip) {
  11173. if (val instanceof Splice) {
  11174. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  11175. } else {
  11176. ret.push(val);
  11177. }
  11178. }
  11179. return is_last;
  11180. }
  11181. if (a instanceof Array) {
  11182. if (backwards) {
  11183. for (i = a.length; --i >= 0; ) if (doit()) break;
  11184. ret.reverse();
  11185. top.reverse();
  11186. } else {
  11187. for (i = 0; i < a.length; ++i) if (doit()) break;
  11188. }
  11189. } else {
  11190. for (i in a) if (a.hasOwnProperty(i)) if (doit()) break;
  11191. }
  11192. return top.concat(ret);
  11193. }
  11194. MAP.at_top = function(val) {
  11195. return new AtTop(val);
  11196. };
  11197. MAP.splice = function(val) {
  11198. return new Splice(val);
  11199. };
  11200. MAP.last = function(val) {
  11201. return new Last(val);
  11202. };
  11203. var skip = MAP.skip = {};
  11204. function AtTop(val) {
  11205. this.v = val;
  11206. }
  11207. function Splice(val) {
  11208. this.v = val;
  11209. }
  11210. function Last(val) {
  11211. this.v = val;
  11212. }
  11213. return MAP;
  11214. }();
  11215. function push_uniq(array, el) {
  11216. if (array.indexOf(el) < 0) array.push(el);
  11217. }
  11218. function string_template(text, props) {
  11219. return text.replace(/\{(.+?)\}/g, function(str, p) {
  11220. return props[p];
  11221. });
  11222. }
  11223. function remove(array, el) {
  11224. for (var i = array.length; --i >= 0; ) {
  11225. if (array[i] === el) array.splice(i, 1);
  11226. }
  11227. }
  11228. function mergeSort(array, cmp) {
  11229. if (array.length < 2) return array.slice();
  11230. function merge(a, b) {
  11231. var r = [], ai = 0, bi = 0, i = 0;
  11232. while (ai < a.length && bi < b.length) {
  11233. cmp(a[ai], b[bi]) <= 0 ? r[i++] = a[ai++] : r[i++] = b[bi++];
  11234. }
  11235. if (ai < a.length) r.push.apply(r, a.slice(ai));
  11236. if (bi < b.length) r.push.apply(r, b.slice(bi));
  11237. return r;
  11238. }
  11239. function _ms(a) {
  11240. if (a.length <= 1) return a;
  11241. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  11242. left = _ms(left);
  11243. right = _ms(right);
  11244. return merge(left, right);
  11245. }
  11246. return _ms(array);
  11247. }
  11248. function set_difference(a, b) {
  11249. return a.filter(function(el) {
  11250. return b.indexOf(el) < 0;
  11251. });
  11252. }
  11253. function set_intersection(a, b) {
  11254. return a.filter(function(el) {
  11255. return b.indexOf(el) >= 0;
  11256. });
  11257. }
  11258. function makePredicate(words) {
  11259. if (!(words instanceof Array)) words = words.split(" ");
  11260. if (typeof UglifyJS_NoUnsafeEval !== "undefined") {
  11261. return function(str) {
  11262. return words.indexOf(str) >= 0;
  11263. };
  11264. }
  11265. var f = "", cats = [];
  11266. out: for (var i = 0; i < words.length; ++i) {
  11267. for (var j = 0; j < cats.length; ++j) if (cats[j][0].length == words[i].length) {
  11268. cats[j].push(words[i]);
  11269. continue out;
  11270. }
  11271. cats.push([ words[i] ]);
  11272. }
  11273. function compareTo(arr) {
  11274. if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";";
  11275. f += "switch(str){";
  11276. for (var i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":";
  11277. f += "return true}return false;";
  11278. }
  11279. if (cats.length > 3) {
  11280. cats.sort(function(a, b) {
  11281. return b.length - a.length;
  11282. });
  11283. f += "switch(str.length){";
  11284. for (var i = 0; i < cats.length; ++i) {
  11285. var cat = cats[i];
  11286. f += "case " + cat[0].length + ":";
  11287. compareTo(cat);
  11288. }
  11289. f += "}";
  11290. } else {
  11291. compareTo(words);
  11292. }
  11293. return new Function("str", f);
  11294. }
  11295. function all(array, predicate) {
  11296. for (var i = array.length; --i >= 0; ) if (!predicate(array[i])) return false;
  11297. return true;
  11298. }
  11299. function Dictionary() {
  11300. this._values = Object.create(null);
  11301. this._size = 0;
  11302. }
  11303. Dictionary.prototype = {
  11304. set: function(key, val) {
  11305. if (!this.has(key)) ++this._size;
  11306. this._values["$" + key] = val;
  11307. return this;
  11308. },
  11309. add: function(key, val) {
  11310. if (this.has(key)) {
  11311. this.get(key).push(val);
  11312. } else {
  11313. this.set(key, [ val ]);
  11314. }
  11315. return this;
  11316. },
  11317. get: function(key) {
  11318. return this._values["$" + key];
  11319. },
  11320. del: function(key) {
  11321. if (this.has(key)) {
  11322. --this._size;
  11323. delete this._values["$" + key];
  11324. }
  11325. return this;
  11326. },
  11327. has: function(key) {
  11328. return "$" + key in this._values;
  11329. },
  11330. each: function(f) {
  11331. for (var i in this._values) f(this._values[i], i.substr(1));
  11332. },
  11333. size: function() {
  11334. return this._size;
  11335. },
  11336. map: function(f) {
  11337. var ret = [];
  11338. for (var i in this._values) ret.push(f(this._values[i], i.substr(1)));
  11339. return ret;
  11340. }
  11341. };
  11342. "use strict";
  11343. function DEFNODE(type, props, methods, base) {
  11344. if (arguments.length < 4) base = AST_Node;
  11345. if (!props) props = []; else props = props.split(/\s+/);
  11346. var self_props = props;
  11347. if (base && base.PROPS) props = props.concat(base.PROPS);
  11348. var proto = base && new base();
  11349. var ctor;
  11350. if (typeof UglifyJS_NoUnsafeEval === "undefined") {
  11351. var code = "return function AST_" + type + "(props){ if (props) { ";
  11352. for (var i = props.length; --i >= 0; ) {
  11353. code += "this." + props[i] + " = props." + props[i] + ";";
  11354. }
  11355. if (proto && proto.initialize || methods && methods.initialize) code += "this.initialize();";
  11356. code += "}}";
  11357. ctor = new Function(code)();
  11358. } else {
  11359. ctor = function(values) {
  11360. if (values) {
  11361. for (var i = props.length; --i >= 0; ) this[props[i]] = values[props[i]];
  11362. if (proto && proto.initialize || methods && methods.initialize) this.initialize();
  11363. }
  11364. };
  11365. }
  11366. if (proto) {
  11367. ctor.prototype = proto;
  11368. ctor.BASE = base;
  11369. }
  11370. if (base) base.SUBCLASSES.push(ctor);
  11371. ctor.prototype.CTOR = ctor;
  11372. ctor.PROPS = props || null;
  11373. ctor.SELF_PROPS = self_props;
  11374. ctor.SUBCLASSES = [];
  11375. if (type) {
  11376. ctor.prototype.TYPE = ctor.TYPE = type;
  11377. }
  11378. if (methods) for (i in methods) if (methods.hasOwnProperty(i)) {
  11379. if (/^\$/.test(i)) {
  11380. ctor[i.substr(1)] = methods[i];
  11381. } else {
  11382. ctor.prototype[i] = methods[i];
  11383. }
  11384. }
  11385. ctor.DEFMETHOD = function(name, method) {
  11386. this.prototype[name] = method;
  11387. };
  11388. return ctor;
  11389. }
  11390. var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {}, null);
  11391. var AST_Node = DEFNODE("Node", "start end", {
  11392. clone: function() {
  11393. return new this.CTOR(this);
  11394. },
  11395. $documentation: "Base class of all AST nodes",
  11396. $propdoc: {
  11397. start: "[AST_Token] The first token of this node",
  11398. end: "[AST_Token] The last token of this node"
  11399. },
  11400. _walk: function(visitor) {
  11401. return visitor._visit(this);
  11402. },
  11403. walk: function(visitor) {
  11404. return this._walk(visitor);
  11405. }
  11406. }, null);
  11407. AST_Node.warn_function = null;
  11408. AST_Node.warn = function(txt, props) {
  11409. if (AST_Node.warn_function) AST_Node.warn_function(string_template(txt, props));
  11410. };
  11411. var AST_Statement = DEFNODE("Statement", null, {
  11412. $documentation: "Base class of all statements"
  11413. });
  11414. var AST_Debugger = DEFNODE("Debugger", null, {
  11415. $documentation: "Represents a debugger statement"
  11416. }, AST_Statement);
  11417. var AST_Directive = DEFNODE("Directive", "value scope", {
  11418. $documentation: 'Represents a directive, like "use strict";',
  11419. $propdoc: {
  11420. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  11421. scope: "[AST_Scope/S] The scope that this directive affects"
  11422. }
  11423. }, AST_Statement);
  11424. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
  11425. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  11426. $propdoc: {
  11427. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  11428. },
  11429. _walk: function(visitor) {
  11430. return visitor._visit(this, function() {
  11431. this.body._walk(visitor);
  11432. });
  11433. }
  11434. }, AST_Statement);
  11435. function walk_body(node, visitor) {
  11436. if (node.body instanceof AST_Statement) {
  11437. node.body._walk(visitor);
  11438. } else node.body.forEach(function(stat) {
  11439. stat._walk(visitor);
  11440. });
  11441. }
  11442. var AST_Block = DEFNODE("Block", "body", {
  11443. $documentation: "A body of statements (usually bracketed)",
  11444. $propdoc: {
  11445. body: "[AST_Statement*] an array of statements"
  11446. },
  11447. _walk: function(visitor) {
  11448. return visitor._visit(this, function() {
  11449. walk_body(this, visitor);
  11450. });
  11451. }
  11452. }, AST_Statement);
  11453. var AST_BlockStatement = DEFNODE("BlockStatement", null, {
  11454. $documentation: "A block statement"
  11455. }, AST_Block);
  11456. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
  11457. $documentation: "The empty statement (empty block or simply a semicolon)",
  11458. _walk: function(visitor) {
  11459. return visitor._visit(this);
  11460. }
  11461. }, AST_Statement);
  11462. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
  11463. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  11464. $propdoc: {
  11465. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  11466. },
  11467. _walk: function(visitor) {
  11468. return visitor._visit(this, function() {
  11469. this.body._walk(visitor);
  11470. });
  11471. }
  11472. }, AST_Statement);
  11473. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
  11474. $documentation: "Statement with a label",
  11475. $propdoc: {
  11476. label: "[AST_Label] a label definition"
  11477. },
  11478. _walk: function(visitor) {
  11479. return visitor._visit(this, function() {
  11480. this.label._walk(visitor);
  11481. this.body._walk(visitor);
  11482. });
  11483. }
  11484. }, AST_StatementWithBody);
  11485. var AST_IterationStatement = DEFNODE("IterationStatement", null, {
  11486. $documentation: "Internal class. All loops inherit from it."
  11487. }, AST_StatementWithBody);
  11488. var AST_DWLoop = DEFNODE("DWLoop", "condition", {
  11489. $documentation: "Base class for do/while statements",
  11490. $propdoc: {
  11491. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  11492. },
  11493. _walk: function(visitor) {
  11494. return visitor._visit(this, function() {
  11495. this.condition._walk(visitor);
  11496. this.body._walk(visitor);
  11497. });
  11498. }
  11499. }, AST_IterationStatement);
  11500. var AST_Do = DEFNODE("Do", null, {
  11501. $documentation: "A `do` statement"
  11502. }, AST_DWLoop);
  11503. var AST_While = DEFNODE("While", null, {
  11504. $documentation: "A `while` statement"
  11505. }, AST_DWLoop);
  11506. var AST_For = DEFNODE("For", "init condition step", {
  11507. $documentation: "A `for` statement",
  11508. $propdoc: {
  11509. init: "[AST_Node?] the `for` initialization code, or null if empty",
  11510. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  11511. step: "[AST_Node?] the `for` update clause, or null if empty"
  11512. },
  11513. _walk: function(visitor) {
  11514. return visitor._visit(this, function() {
  11515. if (this.init) this.init._walk(visitor);
  11516. if (this.condition) this.condition._walk(visitor);
  11517. if (this.step) this.step._walk(visitor);
  11518. this.body._walk(visitor);
  11519. });
  11520. }
  11521. }, AST_IterationStatement);
  11522. var AST_ForIn = DEFNODE("ForIn", "init name object", {
  11523. $documentation: "A `for ... in` statement",
  11524. $propdoc: {
  11525. init: "[AST_Node] the `for/in` initialization code",
  11526. name: "[AST_SymbolRef?] the loop variable, only if `init` is AST_Var",
  11527. object: "[AST_Node] the object that we're looping through"
  11528. },
  11529. _walk: function(visitor) {
  11530. return visitor._visit(this, function() {
  11531. this.init._walk(visitor);
  11532. this.object._walk(visitor);
  11533. this.body._walk(visitor);
  11534. });
  11535. }
  11536. }, AST_IterationStatement);
  11537. var AST_With = DEFNODE("With", "expression", {
  11538. $documentation: "A `with` statement",
  11539. $propdoc: {
  11540. expression: "[AST_Node] the `with` expression"
  11541. },
  11542. _walk: function(visitor) {
  11543. return visitor._visit(this, function() {
  11544. this.expression._walk(visitor);
  11545. this.body._walk(visitor);
  11546. });
  11547. }
  11548. }, AST_StatementWithBody);
  11549. var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_eval parent_scope enclosed cname", {
  11550. $documentation: "Base class for all statements introducing a lexical scope",
  11551. $propdoc: {
  11552. directives: "[string*/S] an array of directives declared in this scope",
  11553. variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  11554. functions: "[Object/S] like `variables`, but only lists function declarations",
  11555. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  11556. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  11557. parent_scope: "[AST_Scope?/S] link to the parent scope",
  11558. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  11559. cname: "[integer/S] current index for mangling variables (used internally by the mangler)"
  11560. }
  11561. }, AST_Block);
  11562. var AST_Toplevel = DEFNODE("Toplevel", "globals", {
  11563. $documentation: "The toplevel scope",
  11564. $propdoc: {
  11565. globals: "[Object/S] a map of name -> SymbolDef for all undeclared names"
  11566. },
  11567. wrap_enclose: function(arg_parameter_pairs) {
  11568. var self = this;
  11569. var args = [];
  11570. var parameters = [];
  11571. arg_parameter_pairs.forEach(function(pair) {
  11572. var splitAt = pair.lastIndexOf(":");
  11573. args.push(pair.substr(0, splitAt));
  11574. parameters.push(pair.substr(splitAt + 1));
  11575. });
  11576. var wrapped_tl = "(function(" + parameters.join(",") + "){ '$ORIG'; })(" + args.join(",") + ")";
  11577. wrapped_tl = parse(wrapped_tl);
  11578. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
  11579. if (node instanceof AST_Directive && node.value == "$ORIG") {
  11580. return MAP.splice(self.body);
  11581. }
  11582. }));
  11583. return wrapped_tl;
  11584. },
  11585. wrap_commonjs: function(name, export_all) {
  11586. var self = this;
  11587. var to_export = [];
  11588. if (export_all) {
  11589. self.figure_out_scope();
  11590. self.walk(new TreeWalker(function(node) {
  11591. if (node instanceof AST_SymbolDeclaration && node.definition().global) {
  11592. if (!find_if(function(n) {
  11593. return n.name == node.name;
  11594. }, to_export)) to_export.push(node);
  11595. }
  11596. }));
  11597. }
  11598. var wrapped_tl = "(function(exports, global){ global['" + name + "'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";
  11599. wrapped_tl = parse(wrapped_tl);
  11600. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
  11601. if (node instanceof AST_SimpleStatement) {
  11602. node = node.body;
  11603. if (node instanceof AST_String) switch (node.getValue()) {
  11604. case "$ORIG":
  11605. return MAP.splice(self.body);
  11606. case "$EXPORTS":
  11607. var body = [];
  11608. to_export.forEach(function(sym) {
  11609. body.push(new AST_SimpleStatement({
  11610. body: new AST_Assign({
  11611. left: new AST_Sub({
  11612. expression: new AST_SymbolRef({
  11613. name: "exports"
  11614. }),
  11615. property: new AST_String({
  11616. value: sym.name
  11617. })
  11618. }),
  11619. operator: "=",
  11620. right: new AST_SymbolRef(sym)
  11621. })
  11622. }));
  11623. });
  11624. return MAP.splice(body);
  11625. }
  11626. }
  11627. }));
  11628. return wrapped_tl;
  11629. }
  11630. }, AST_Scope);
  11631. var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments", {
  11632. $documentation: "Base class for functions",
  11633. $propdoc: {
  11634. name: "[AST_SymbolDeclaration?] the name of this function",
  11635. argnames: "[AST_SymbolFunarg*] array of function arguments",
  11636. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array"
  11637. },
  11638. _walk: function(visitor) {
  11639. return visitor._visit(this, function() {
  11640. if (this.name) this.name._walk(visitor);
  11641. this.argnames.forEach(function(arg) {
  11642. arg._walk(visitor);
  11643. });
  11644. walk_body(this, visitor);
  11645. });
  11646. }
  11647. }, AST_Scope);
  11648. var AST_Accessor = DEFNODE("Accessor", null, {
  11649. $documentation: "A setter/getter function. The `name` property is always null."
  11650. }, AST_Lambda);
  11651. var AST_Function = DEFNODE("Function", null, {
  11652. $documentation: "A function expression"
  11653. }, AST_Lambda);
  11654. var AST_Defun = DEFNODE("Defun", null, {
  11655. $documentation: "A function definition"
  11656. }, AST_Lambda);
  11657. var AST_Jump = DEFNODE("Jump", null, {
  11658. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  11659. }, AST_Statement);
  11660. var AST_Exit = DEFNODE("Exit", "value", {
  11661. $documentation: "Base class for “exits” (`return` and `throw`)",
  11662. $propdoc: {
  11663. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  11664. },
  11665. _walk: function(visitor) {
  11666. return visitor._visit(this, this.value && function() {
  11667. this.value._walk(visitor);
  11668. });
  11669. }
  11670. }, AST_Jump);
  11671. var AST_Return = DEFNODE("Return", null, {
  11672. $documentation: "A `return` statement"
  11673. }, AST_Exit);
  11674. var AST_Throw = DEFNODE("Throw", null, {
  11675. $documentation: "A `throw` statement"
  11676. }, AST_Exit);
  11677. var AST_LoopControl = DEFNODE("LoopControl", "label", {
  11678. $documentation: "Base class for loop control statements (`break` and `continue`)",
  11679. $propdoc: {
  11680. label: "[AST_LabelRef?] the label, or null if none"
  11681. },
  11682. _walk: function(visitor) {
  11683. return visitor._visit(this, this.label && function() {
  11684. this.label._walk(visitor);
  11685. });
  11686. }
  11687. }, AST_Jump);
  11688. var AST_Break = DEFNODE("Break", null, {
  11689. $documentation: "A `break` statement"
  11690. }, AST_LoopControl);
  11691. var AST_Continue = DEFNODE("Continue", null, {
  11692. $documentation: "A `continue` statement"
  11693. }, AST_LoopControl);
  11694. var AST_If = DEFNODE("If", "condition alternative", {
  11695. $documentation: "A `if` statement",
  11696. $propdoc: {
  11697. condition: "[AST_Node] the `if` condition",
  11698. alternative: "[AST_Statement?] the `else` part, or null if not present"
  11699. },
  11700. _walk: function(visitor) {
  11701. return visitor._visit(this, function() {
  11702. this.condition._walk(visitor);
  11703. this.body._walk(visitor);
  11704. if (this.alternative) this.alternative._walk(visitor);
  11705. });
  11706. }
  11707. }, AST_StatementWithBody);
  11708. var AST_Switch = DEFNODE("Switch", "expression", {
  11709. $documentation: "A `switch` statement",
  11710. $propdoc: {
  11711. expression: "[AST_Node] the `switch` “discriminant”"
  11712. },
  11713. _walk: function(visitor) {
  11714. return visitor._visit(this, function() {
  11715. this.expression._walk(visitor);
  11716. walk_body(this, visitor);
  11717. });
  11718. }
  11719. }, AST_Block);
  11720. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
  11721. $documentation: "Base class for `switch` branches"
  11722. }, AST_Block);
  11723. var AST_Default = DEFNODE("Default", null, {
  11724. $documentation: "A `default` switch branch"
  11725. }, AST_SwitchBranch);
  11726. var AST_Case = DEFNODE("Case", "expression", {
  11727. $documentation: "A `case` switch branch",
  11728. $propdoc: {
  11729. expression: "[AST_Node] the `case` expression"
  11730. },
  11731. _walk: function(visitor) {
  11732. return visitor._visit(this, function() {
  11733. this.expression._walk(visitor);
  11734. walk_body(this, visitor);
  11735. });
  11736. }
  11737. }, AST_SwitchBranch);
  11738. var AST_Try = DEFNODE("Try", "bcatch bfinally", {
  11739. $documentation: "A `try` statement",
  11740. $propdoc: {
  11741. bcatch: "[AST_Catch?] the catch block, or null if not present",
  11742. bfinally: "[AST_Finally?] the finally block, or null if not present"
  11743. },
  11744. _walk: function(visitor) {
  11745. return visitor._visit(this, function() {
  11746. walk_body(this, visitor);
  11747. if (this.bcatch) this.bcatch._walk(visitor);
  11748. if (this.bfinally) this.bfinally._walk(visitor);
  11749. });
  11750. }
  11751. }, AST_Block);
  11752. var AST_Catch = DEFNODE("Catch", "argname", {
  11753. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  11754. $propdoc: {
  11755. argname: "[AST_SymbolCatch] symbol for the exception"
  11756. },
  11757. _walk: function(visitor) {
  11758. return visitor._visit(this, function() {
  11759. this.argname._walk(visitor);
  11760. walk_body(this, visitor);
  11761. });
  11762. }
  11763. }, AST_Block);
  11764. var AST_Finally = DEFNODE("Finally", null, {
  11765. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  11766. }, AST_Block);
  11767. var AST_Definitions = DEFNODE("Definitions", "definitions", {
  11768. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  11769. $propdoc: {
  11770. definitions: "[AST_VarDef*] array of variable definitions"
  11771. },
  11772. _walk: function(visitor) {
  11773. return visitor._visit(this, function() {
  11774. this.definitions.forEach(function(def) {
  11775. def._walk(visitor);
  11776. });
  11777. });
  11778. }
  11779. }, AST_Statement);
  11780. var AST_Var = DEFNODE("Var", null, {
  11781. $documentation: "A `var` statement"
  11782. }, AST_Definitions);
  11783. var AST_Const = DEFNODE("Const", null, {
  11784. $documentation: "A `const` statement"
  11785. }, AST_Definitions);
  11786. var AST_VarDef = DEFNODE("VarDef", "name value", {
  11787. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  11788. $propdoc: {
  11789. name: "[AST_SymbolVar|AST_SymbolConst] name of the variable",
  11790. value: "[AST_Node?] initializer, or null of there's no initializer"
  11791. },
  11792. _walk: function(visitor) {
  11793. return visitor._visit(this, function() {
  11794. this.name._walk(visitor);
  11795. if (this.value) this.value._walk(visitor);
  11796. });
  11797. }
  11798. });
  11799. var AST_Call = DEFNODE("Call", "expression args", {
  11800. $documentation: "A function call expression",
  11801. $propdoc: {
  11802. expression: "[AST_Node] expression to invoke as function",
  11803. args: "[AST_Node*] array of arguments"
  11804. },
  11805. _walk: function(visitor) {
  11806. return visitor._visit(this, function() {
  11807. this.expression._walk(visitor);
  11808. this.args.forEach(function(arg) {
  11809. arg._walk(visitor);
  11810. });
  11811. });
  11812. }
  11813. });
  11814. var AST_New = DEFNODE("New", null, {
  11815. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  11816. }, AST_Call);
  11817. var AST_Seq = DEFNODE("Seq", "car cdr", {
  11818. $documentation: "A sequence expression (two comma-separated expressions)",
  11819. $propdoc: {
  11820. car: "[AST_Node] first element in sequence",
  11821. cdr: "[AST_Node] second element in sequence"
  11822. },
  11823. $cons: function(x, y) {
  11824. var seq = new AST_Seq(x);
  11825. seq.car = x;
  11826. seq.cdr = y;
  11827. return seq;
  11828. },
  11829. $from_array: function(array) {
  11830. if (array.length == 0) return null;
  11831. if (array.length == 1) return array[0].clone();
  11832. var list = null;
  11833. for (var i = array.length; --i >= 0; ) {
  11834. list = AST_Seq.cons(array[i], list);
  11835. }
  11836. var p = list;
  11837. while (p) {
  11838. if (p.cdr && !p.cdr.cdr) {
  11839. p.cdr = p.cdr.car;
  11840. break;
  11841. }
  11842. p = p.cdr;
  11843. }
  11844. return list;
  11845. },
  11846. to_array: function() {
  11847. var p = this, a = [];
  11848. while (p) {
  11849. a.push(p.car);
  11850. if (p.cdr && !(p.cdr instanceof AST_Seq)) {
  11851. a.push(p.cdr);
  11852. break;
  11853. }
  11854. p = p.cdr;
  11855. }
  11856. return a;
  11857. },
  11858. add: function(node) {
  11859. var p = this;
  11860. while (p) {
  11861. if (!(p.cdr instanceof AST_Seq)) {
  11862. var cell = AST_Seq.cons(p.cdr, node);
  11863. return p.cdr = cell;
  11864. }
  11865. p = p.cdr;
  11866. }
  11867. },
  11868. _walk: function(visitor) {
  11869. return visitor._visit(this, function() {
  11870. this.car._walk(visitor);
  11871. if (this.cdr) this.cdr._walk(visitor);
  11872. });
  11873. }
  11874. });
  11875. var AST_PropAccess = DEFNODE("PropAccess", "expression property", {
  11876. $documentation: 'Base class for property access expressions, i.e. `a.foo` or `a["foo"]`',
  11877. $propdoc: {
  11878. expression: "[AST_Node] the “container” expression",
  11879. property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node"
  11880. }
  11881. });
  11882. var AST_Dot = DEFNODE("Dot", null, {
  11883. $documentation: "A dotted property access expression",
  11884. _walk: function(visitor) {
  11885. return visitor._visit(this, function() {
  11886. this.expression._walk(visitor);
  11887. });
  11888. }
  11889. }, AST_PropAccess);
  11890. var AST_Sub = DEFNODE("Sub", null, {
  11891. $documentation: 'Index-style property access, i.e. `a["foo"]`',
  11892. _walk: function(visitor) {
  11893. return visitor._visit(this, function() {
  11894. this.expression._walk(visitor);
  11895. this.property._walk(visitor);
  11896. });
  11897. }
  11898. }, AST_PropAccess);
  11899. var AST_Unary = DEFNODE("Unary", "operator expression", {
  11900. $documentation: "Base class for unary expressions",
  11901. $propdoc: {
  11902. operator: "[string] the operator",
  11903. expression: "[AST_Node] expression that this unary operator applies to"
  11904. },
  11905. _walk: function(visitor) {
  11906. return visitor._visit(this, function() {
  11907. this.expression._walk(visitor);
  11908. });
  11909. }
  11910. });
  11911. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
  11912. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  11913. }, AST_Unary);
  11914. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
  11915. $documentation: "Unary postfix expression, i.e. `i++`"
  11916. }, AST_Unary);
  11917. var AST_Binary = DEFNODE("Binary", "left operator right", {
  11918. $documentation: "Binary expression, i.e. `a + b`",
  11919. $propdoc: {
  11920. left: "[AST_Node] left-hand side expression",
  11921. operator: "[string] the operator",
  11922. right: "[AST_Node] right-hand side expression"
  11923. },
  11924. _walk: function(visitor) {
  11925. return visitor._visit(this, function() {
  11926. this.left._walk(visitor);
  11927. this.right._walk(visitor);
  11928. });
  11929. }
  11930. });
  11931. var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
  11932. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  11933. $propdoc: {
  11934. condition: "[AST_Node]",
  11935. consequent: "[AST_Node]",
  11936. alternative: "[AST_Node]"
  11937. },
  11938. _walk: function(visitor) {
  11939. return visitor._visit(this, function() {
  11940. this.condition._walk(visitor);
  11941. this.consequent._walk(visitor);
  11942. this.alternative._walk(visitor);
  11943. });
  11944. }
  11945. });
  11946. var AST_Assign = DEFNODE("Assign", null, {
  11947. $documentation: "An assignment expression — `a = b + 5`"
  11948. }, AST_Binary);
  11949. var AST_Array = DEFNODE("Array", "elements", {
  11950. $documentation: "An array literal",
  11951. $propdoc: {
  11952. elements: "[AST_Node*] array of elements"
  11953. },
  11954. _walk: function(visitor) {
  11955. return visitor._visit(this, function() {
  11956. this.elements.forEach(function(el) {
  11957. el._walk(visitor);
  11958. });
  11959. });
  11960. }
  11961. });
  11962. var AST_Object = DEFNODE("Object", "properties", {
  11963. $documentation: "An object literal",
  11964. $propdoc: {
  11965. properties: "[AST_ObjectProperty*] array of properties"
  11966. },
  11967. _walk: function(visitor) {
  11968. return visitor._visit(this, function() {
  11969. this.properties.forEach(function(prop) {
  11970. prop._walk(visitor);
  11971. });
  11972. });
  11973. }
  11974. });
  11975. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
  11976. $documentation: "Base class for literal object properties",
  11977. $propdoc: {
  11978. key: "[string] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",
  11979. value: "[AST_Node] property value. For setters and getters this is an AST_Function."
  11980. },
  11981. _walk: function(visitor) {
  11982. return visitor._visit(this, function() {
  11983. this.value._walk(visitor);
  11984. });
  11985. }
  11986. });
  11987. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", null, {
  11988. $documentation: "A key: value object property"
  11989. }, AST_ObjectProperty);
  11990. var AST_ObjectSetter = DEFNODE("ObjectSetter", null, {
  11991. $documentation: "An object setter property"
  11992. }, AST_ObjectProperty);
  11993. var AST_ObjectGetter = DEFNODE("ObjectGetter", null, {
  11994. $documentation: "An object getter property"
  11995. }, AST_ObjectProperty);
  11996. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
  11997. $propdoc: {
  11998. name: "[string] name of this symbol",
  11999. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  12000. thedef: "[SymbolDef/S] the definition of this symbol"
  12001. },
  12002. $documentation: "Base class for all symbols"
  12003. });
  12004. var AST_SymbolAccessor = DEFNODE("SymbolAccessor", null, {
  12005. $documentation: "The name of a property accessor (setter/getter function)"
  12006. }, AST_Symbol);
  12007. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
  12008. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  12009. $propdoc: {
  12010. init: "[AST_Node*/S] array of initializers for this declaration."
  12011. }
  12012. }, AST_Symbol);
  12013. var AST_SymbolVar = DEFNODE("SymbolVar", null, {
  12014. $documentation: "Symbol defining a variable"
  12015. }, AST_SymbolDeclaration);
  12016. var AST_SymbolConst = DEFNODE("SymbolConst", null, {
  12017. $documentation: "A constant declaration"
  12018. }, AST_SymbolDeclaration);
  12019. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
  12020. $documentation: "Symbol naming a function argument"
  12021. }, AST_SymbolVar);
  12022. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
  12023. $documentation: "Symbol defining a function"
  12024. }, AST_SymbolDeclaration);
  12025. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
  12026. $documentation: "Symbol naming a function expression"
  12027. }, AST_SymbolDeclaration);
  12028. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
  12029. $documentation: "Symbol naming the exception in catch"
  12030. }, AST_SymbolDeclaration);
  12031. var AST_Label = DEFNODE("Label", "references", {
  12032. $documentation: "Symbol naming a label (declaration)",
  12033. $propdoc: {
  12034. references: "[AST_LoopControl*] a list of nodes referring to this label"
  12035. },
  12036. initialize: function() {
  12037. this.references = [];
  12038. this.thedef = this;
  12039. }
  12040. }, AST_Symbol);
  12041. var AST_SymbolRef = DEFNODE("SymbolRef", null, {
  12042. $documentation: "Reference to some symbol (not definition/declaration)"
  12043. }, AST_Symbol);
  12044. var AST_LabelRef = DEFNODE("LabelRef", null, {
  12045. $documentation: "Reference to a label symbol"
  12046. }, AST_Symbol);
  12047. var AST_This = DEFNODE("This", null, {
  12048. $documentation: "The `this` symbol"
  12049. }, AST_Symbol);
  12050. var AST_Constant = DEFNODE("Constant", null, {
  12051. $documentation: "Base class for all constants",
  12052. getValue: function() {
  12053. return this.value;
  12054. }
  12055. });
  12056. var AST_String = DEFNODE("String", "value", {
  12057. $documentation: "A string literal",
  12058. $propdoc: {
  12059. value: "[string] the contents of this string"
  12060. }
  12061. }, AST_Constant);
  12062. var AST_Number = DEFNODE("Number", "value", {
  12063. $documentation: "A number literal",
  12064. $propdoc: {
  12065. value: "[number] the numeric value"
  12066. }
  12067. }, AST_Constant);
  12068. var AST_RegExp = DEFNODE("RegExp", "value", {
  12069. $documentation: "A regexp literal",
  12070. $propdoc: {
  12071. value: "[RegExp] the actual regexp"
  12072. }
  12073. }, AST_Constant);
  12074. var AST_Atom = DEFNODE("Atom", null, {
  12075. $documentation: "Base class for atoms"
  12076. }, AST_Constant);
  12077. var AST_Null = DEFNODE("Null", null, {
  12078. $documentation: "The `null` atom",
  12079. value: null
  12080. }, AST_Atom);
  12081. var AST_NaN = DEFNODE("NaN", null, {
  12082. $documentation: "The impossible value",
  12083. value: 0 / 0
  12084. }, AST_Atom);
  12085. var AST_Undefined = DEFNODE("Undefined", null, {
  12086. $documentation: "The `undefined` value",
  12087. value: function() {}()
  12088. }, AST_Atom);
  12089. var AST_Hole = DEFNODE("Hole", null, {
  12090. $documentation: "A hole in an array",
  12091. value: function() {}()
  12092. }, AST_Atom);
  12093. var AST_Infinity = DEFNODE("Infinity", null, {
  12094. $documentation: "The `Infinity` value",
  12095. value: 1 / 0
  12096. }, AST_Atom);
  12097. var AST_Boolean = DEFNODE("Boolean", null, {
  12098. $documentation: "Base class for booleans"
  12099. }, AST_Atom);
  12100. var AST_False = DEFNODE("False", null, {
  12101. $documentation: "The `false` atom",
  12102. value: false
  12103. }, AST_Boolean);
  12104. var AST_True = DEFNODE("True", null, {
  12105. $documentation: "The `true` atom",
  12106. value: true
  12107. }, AST_Boolean);
  12108. function TreeWalker(callback) {
  12109. this.visit = callback;
  12110. this.stack = [];
  12111. }
  12112. TreeWalker.prototype = {
  12113. _visit: function(node, descend) {
  12114. this.stack.push(node);
  12115. var ret = this.visit(node, descend ? function() {
  12116. descend.call(node);
  12117. } : noop);
  12118. if (!ret && descend) {
  12119. descend.call(node);
  12120. }
  12121. this.stack.pop();
  12122. return ret;
  12123. },
  12124. parent: function(n) {
  12125. return this.stack[this.stack.length - 2 - (n || 0)];
  12126. },
  12127. push: function(node) {
  12128. this.stack.push(node);
  12129. },
  12130. pop: function() {
  12131. return this.stack.pop();
  12132. },
  12133. self: function() {
  12134. return this.stack[this.stack.length - 1];
  12135. },
  12136. find_parent: function(type) {
  12137. var stack = this.stack;
  12138. for (var i = stack.length; --i >= 0; ) {
  12139. var x = stack[i];
  12140. if (x instanceof type) return x;
  12141. }
  12142. },
  12143. has_directive: function(type) {
  12144. return this.find_parent(AST_Scope).has_directive(type);
  12145. },
  12146. in_boolean_context: function() {
  12147. var stack = this.stack;
  12148. var i = stack.length, self = stack[--i];
  12149. while (i > 0) {
  12150. var p = stack[--i];
  12151. if (p instanceof AST_If && p.condition === self || p instanceof AST_Conditional && p.condition === self || p instanceof AST_DWLoop && p.condition === self || p instanceof AST_For && p.condition === self || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  12152. return true;
  12153. }
  12154. if (!(p instanceof AST_Binary && (p.operator == "&&" || p.operator == "||"))) return false;
  12155. self = p;
  12156. }
  12157. },
  12158. loopcontrol_target: function(label) {
  12159. var stack = this.stack;
  12160. if (label) for (var i = stack.length; --i >= 0; ) {
  12161. var x = stack[i];
  12162. if (x instanceof AST_LabeledStatement && x.label.name == label.name) {
  12163. return x.body;
  12164. }
  12165. } else for (var i = stack.length; --i >= 0; ) {
  12166. var x = stack[i];
  12167. if (x instanceof AST_Switch || x instanceof AST_IterationStatement) return x;
  12168. }
  12169. }
  12170. };
  12171. "use strict";
  12172. var KEYWORDS = "break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with";
  12173. var KEYWORDS_ATOM = "false null true";
  12174. var RESERVED_WORDS = "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield" + " " + KEYWORDS_ATOM + " " + KEYWORDS;
  12175. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case";
  12176. KEYWORDS = makePredicate(KEYWORDS);
  12177. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  12178. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  12179. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  12180. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  12181. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  12182. var RE_OCT_NUMBER = /^0[0-7]+$/;
  12183. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  12184. var OPERATORS = makePredicate([ "in", "instanceof", "typeof", "new", "void", "delete", "++", "--", "+", "-", "!", "~", "&", "|", "^", "*", "/", "%", ">>", "<<", ">>>", "<", ">", "<=", ">=", "==", "===", "!=", "!==", "?", "=", "+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=", "&&", "||" ]);
  12185. var WHITESPACE_CHARS = makePredicate(characters("  \n\r \f ​᠎              "));
  12186. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,.;:"));
  12187. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  12188. var REGEXP_MODIFIERS = makePredicate(characters("gmsiy"));
  12189. var UNICODE = {
  12190. letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
  12191. non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
  12192. space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
  12193. connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
  12194. };
  12195. function is_letter(code) {
  12196. return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 170 && UNICODE.letter.test(String.fromCharCode(code));
  12197. }
  12198. function is_digit(code) {
  12199. return code >= 48 && code <= 57;
  12200. }
  12201. function is_alphanumeric_char(code) {
  12202. return is_digit(code) || is_letter(code);
  12203. }
  12204. function is_unicode_combining_mark(ch) {
  12205. return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
  12206. }
  12207. function is_unicode_connector_punctuation(ch) {
  12208. return UNICODE.connector_punctuation.test(ch);
  12209. }
  12210. function is_identifier(name) {
  12211. return !RESERVED_WORDS(name) && /^[a-z_$][a-z0-9_$]*$/i.test(name);
  12212. }
  12213. function is_identifier_start(code) {
  12214. return code == 36 || code == 95 || is_letter(code);
  12215. }
  12216. function is_identifier_char(ch) {
  12217. var code = ch.charCodeAt(0);
  12218. return is_identifier_start(code) || is_digit(code) || code == 8204 || code == 8205 || is_unicode_combining_mark(ch) || is_unicode_connector_punctuation(ch);
  12219. }
  12220. function is_identifier_string(str) {
  12221. return /^[a-z_$][a-z0-9_$]*$/i.test(str);
  12222. }
  12223. function parse_js_number(num) {
  12224. if (RE_HEX_NUMBER.test(num)) {
  12225. return parseInt(num.substr(2), 16);
  12226. } else if (RE_OCT_NUMBER.test(num)) {
  12227. return parseInt(num.substr(1), 8);
  12228. } else if (RE_DEC_NUMBER.test(num)) {
  12229. return parseFloat(num);
  12230. }
  12231. }
  12232. function JS_Parse_Error(message, line, col, pos) {
  12233. this.message = message;
  12234. this.line = line;
  12235. this.col = col;
  12236. this.pos = pos;
  12237. this.stack = new Error().stack;
  12238. }
  12239. JS_Parse_Error.prototype.toString = function() {
  12240. return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
  12241. };
  12242. function js_error(message, filename, line, col, pos) {
  12243. throw new JS_Parse_Error(message, line, col, pos);
  12244. }
  12245. function is_token(token, type, val) {
  12246. return token.type == type && (val == null || token.value == val);
  12247. }
  12248. var EX_EOF = {};
  12249. function tokenizer($TEXT, filename, html5_comments) {
  12250. var S = {
  12251. text: $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ""),
  12252. filename: filename,
  12253. pos: 0,
  12254. tokpos: 0,
  12255. line: 1,
  12256. tokline: 0,
  12257. col: 0,
  12258. tokcol: 0,
  12259. newline_before: false,
  12260. regex_allowed: false,
  12261. comments_before: []
  12262. };
  12263. function peek() {
  12264. return S.text.charAt(S.pos);
  12265. }
  12266. function next(signal_eof, in_string) {
  12267. var ch = S.text.charAt(S.pos++);
  12268. if (signal_eof && !ch) throw EX_EOF;
  12269. if (ch == "\n") {
  12270. S.newline_before = S.newline_before || !in_string;
  12271. ++S.line;
  12272. S.col = 0;
  12273. } else {
  12274. ++S.col;
  12275. }
  12276. return ch;
  12277. }
  12278. function forward(i) {
  12279. while (i-- > 0) next();
  12280. }
  12281. function looking_at(str) {
  12282. return S.text.substr(S.pos, str.length) == str;
  12283. }
  12284. function find(what, signal_eof) {
  12285. var pos = S.text.indexOf(what, S.pos);
  12286. if (signal_eof && pos == -1) throw EX_EOF;
  12287. return pos;
  12288. }
  12289. function start_token() {
  12290. S.tokline = S.line;
  12291. S.tokcol = S.col;
  12292. S.tokpos = S.pos;
  12293. }
  12294. var prev_was_dot = false;
  12295. function token(type, value, is_comment) {
  12296. S.regex_allowed = type == "operator" && !UNARY_POSTFIX(value) || type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value) || type == "punc" && PUNC_BEFORE_EXPRESSION(value);
  12297. prev_was_dot = type == "punc" && value == ".";
  12298. var ret = {
  12299. type: type,
  12300. value: value,
  12301. line: S.tokline,
  12302. col: S.tokcol,
  12303. pos: S.tokpos,
  12304. endpos: S.pos,
  12305. nlb: S.newline_before,
  12306. file: filename
  12307. };
  12308. if (!is_comment) {
  12309. ret.comments_before = S.comments_before;
  12310. S.comments_before = [];
  12311. for (var i = 0, len = ret.comments_before.length; i < len; i++) {
  12312. ret.nlb = ret.nlb || ret.comments_before[i].nlb;
  12313. }
  12314. }
  12315. S.newline_before = false;
  12316. return new AST_Token(ret);
  12317. }
  12318. function skip_whitespace() {
  12319. while (WHITESPACE_CHARS(peek())) next();
  12320. }
  12321. function read_while(pred) {
  12322. var ret = "", ch, i = 0;
  12323. while ((ch = peek()) && pred(ch, i++)) ret += next();
  12324. return ret;
  12325. }
  12326. function parse_error(err) {
  12327. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  12328. }
  12329. function read_num(prefix) {
  12330. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
  12331. var num = read_while(function(ch, i) {
  12332. var code = ch.charCodeAt(0);
  12333. switch (code) {
  12334. case 120:
  12335. case 88:
  12336. return has_x ? false : has_x = true;
  12337. case 101:
  12338. case 69:
  12339. return has_x ? true : has_e ? false : has_e = after_e = true;
  12340. case 45:
  12341. return after_e || i == 0 && !prefix;
  12342. case 43:
  12343. return after_e;
  12344. case after_e = false, 46:
  12345. return !has_dot && !has_x && !has_e ? has_dot = true : false;
  12346. }
  12347. return is_alphanumeric_char(code);
  12348. });
  12349. if (prefix) num = prefix + num;
  12350. var valid = parse_js_number(num);
  12351. if (!isNaN(valid)) {
  12352. return token("num", valid);
  12353. } else {
  12354. parse_error("Invalid syntax: " + num);
  12355. }
  12356. }
  12357. function read_escaped_char(in_string) {
  12358. var ch = next(true, in_string);
  12359. switch (ch.charCodeAt(0)) {
  12360. case 110:
  12361. return "\n";
  12362. case 114:
  12363. return "\r";
  12364. case 116:
  12365. return " ";
  12366. case 98:
  12367. return "\b";
  12368. case 118:
  12369. return " ";
  12370. case 102:
  12371. return "\f";
  12372. case 48:
  12373. return "\x00";
  12374. case 120:
  12375. return String.fromCharCode(hex_bytes(2));
  12376. case 117:
  12377. return String.fromCharCode(hex_bytes(4));
  12378. case 10:
  12379. return "";
  12380. default:
  12381. return ch;
  12382. }
  12383. }
  12384. function hex_bytes(n) {
  12385. var num = 0;
  12386. for (;n > 0; --n) {
  12387. var digit = parseInt(next(true), 16);
  12388. if (isNaN(digit)) parse_error("Invalid hex-character pattern in string");
  12389. num = num << 4 | digit;
  12390. }
  12391. return num;
  12392. }
  12393. var read_string = with_eof_error("Unterminated string constant", function() {
  12394. var quote = next(), ret = "";
  12395. for (;;) {
  12396. var ch = next(true);
  12397. if (ch == "\\") {
  12398. var octal_len = 0, first = null;
  12399. ch = read_while(function(ch) {
  12400. if (ch >= "0" && ch <= "7") {
  12401. if (!first) {
  12402. first = ch;
  12403. return ++octal_len;
  12404. } else if (first <= "3" && octal_len <= 2) return ++octal_len; else if (first >= "4" && octal_len <= 1) return ++octal_len;
  12405. }
  12406. return false;
  12407. });
  12408. if (octal_len > 0) ch = String.fromCharCode(parseInt(ch, 8)); else ch = read_escaped_char(true);
  12409. } else if (ch == quote) break;
  12410. ret += ch;
  12411. }
  12412. return token("string", ret);
  12413. });
  12414. function skip_line_comment(type) {
  12415. var regex_allowed = S.regex_allowed;
  12416. var i = find("\n"), ret;
  12417. if (i == -1) {
  12418. ret = S.text.substr(S.pos);
  12419. S.pos = S.text.length;
  12420. } else {
  12421. ret = S.text.substring(S.pos, i);
  12422. S.pos = i;
  12423. }
  12424. S.comments_before.push(token(type, ret, true));
  12425. S.regex_allowed = regex_allowed;
  12426. return next_token();
  12427. }
  12428. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  12429. var regex_allowed = S.regex_allowed;
  12430. var i = find("*/", true);
  12431. var text = S.text.substring(S.pos, i);
  12432. var a = text.split("\n"), n = a.length;
  12433. S.pos = i + 2;
  12434. S.line += n - 1;
  12435. if (n > 1) S.col = a[n - 1].length; else S.col += a[n - 1].length;
  12436. S.col += 2;
  12437. var nlb = S.newline_before = S.newline_before || text.indexOf("\n") >= 0;
  12438. S.comments_before.push(token("comment2", text, true));
  12439. S.regex_allowed = regex_allowed;
  12440. S.newline_before = nlb;
  12441. return next_token();
  12442. });
  12443. function read_name() {
  12444. var backslash = false, name = "", ch, escaped = false, hex;
  12445. while ((ch = peek()) != null) {
  12446. if (!backslash) {
  12447. if (ch == "\\") escaped = backslash = true, next(); else if (is_identifier_char(ch)) name += next(); else break;
  12448. } else {
  12449. if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
  12450. ch = read_escaped_char();
  12451. if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
  12452. name += ch;
  12453. backslash = false;
  12454. }
  12455. }
  12456. if (KEYWORDS(name) && escaped) {
  12457. hex = name.charCodeAt(0).toString(16).toUpperCase();
  12458. name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1);
  12459. }
  12460. return name;
  12461. }
  12462. var read_regexp = with_eof_error("Unterminated regular expression", function(regexp) {
  12463. var prev_backslash = false, ch, in_class = false;
  12464. while (ch = next(true)) if (prev_backslash) {
  12465. regexp += "\\" + ch;
  12466. prev_backslash = false;
  12467. } else if (ch == "[") {
  12468. in_class = true;
  12469. regexp += ch;
  12470. } else if (ch == "]" && in_class) {
  12471. in_class = false;
  12472. regexp += ch;
  12473. } else if (ch == "/" && !in_class) {
  12474. break;
  12475. } else if (ch == "\\") {
  12476. prev_backslash = true;
  12477. } else {
  12478. regexp += ch;
  12479. }
  12480. var mods = read_name();
  12481. return token("regexp", new RegExp(regexp, mods));
  12482. });
  12483. function read_operator(prefix) {
  12484. function grow(op) {
  12485. if (!peek()) return op;
  12486. var bigger = op + peek();
  12487. if (OPERATORS(bigger)) {
  12488. next();
  12489. return grow(bigger);
  12490. } else {
  12491. return op;
  12492. }
  12493. }
  12494. return token("operator", grow(prefix || next()));
  12495. }
  12496. function handle_slash() {
  12497. next();
  12498. switch (peek()) {
  12499. case "/":
  12500. next();
  12501. return skip_line_comment("comment1");
  12502. case "*":
  12503. next();
  12504. return skip_multiline_comment();
  12505. }
  12506. return S.regex_allowed ? read_regexp("") : read_operator("/");
  12507. }
  12508. function handle_dot() {
  12509. next();
  12510. return is_digit(peek().charCodeAt(0)) ? read_num(".") : token("punc", ".");
  12511. }
  12512. function read_word() {
  12513. var word = read_name();
  12514. if (prev_was_dot) return token("name", word);
  12515. return KEYWORDS_ATOM(word) ? token("atom", word) : !KEYWORDS(word) ? token("name", word) : OPERATORS(word) ? token("operator", word) : token("keyword", word);
  12516. }
  12517. function with_eof_error(eof_error, cont) {
  12518. return function(x) {
  12519. try {
  12520. return cont(x);
  12521. } catch (ex) {
  12522. if (ex === EX_EOF) parse_error(eof_error); else throw ex;
  12523. }
  12524. };
  12525. }
  12526. function next_token(force_regexp) {
  12527. if (force_regexp != null) return read_regexp(force_regexp);
  12528. skip_whitespace();
  12529. start_token();
  12530. if (html5_comments) {
  12531. if (looking_at("<!--")) {
  12532. forward(4);
  12533. return skip_line_comment("comment3");
  12534. }
  12535. if (looking_at("-->") && S.newline_before) {
  12536. forward(3);
  12537. return skip_line_comment("comment4");
  12538. }
  12539. }
  12540. var ch = peek();
  12541. if (!ch) return token("eof");
  12542. var code = ch.charCodeAt(0);
  12543. switch (code) {
  12544. case 34:
  12545. case 39:
  12546. return read_string();
  12547. case 46:
  12548. return handle_dot();
  12549. case 47:
  12550. return handle_slash();
  12551. }
  12552. if (is_digit(code)) return read_num();
  12553. if (PUNC_CHARS(ch)) return token("punc", next());
  12554. if (OPERATOR_CHARS(ch)) return read_operator();
  12555. if (code == 92 || is_identifier_start(code)) return read_word();
  12556. parse_error("Unexpected character '" + ch + "'");
  12557. }
  12558. next_token.context = function(nc) {
  12559. if (nc) S = nc;
  12560. return S;
  12561. };
  12562. return next_token;
  12563. }
  12564. var UNARY_PREFIX = makePredicate([ "typeof", "void", "delete", "--", "++", "!", "~", "-", "+" ]);
  12565. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  12566. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  12567. var PRECEDENCE = function(a, ret) {
  12568. for (var i = 0; i < a.length; ++i) {
  12569. var b = a[i];
  12570. for (var j = 0; j < b.length; ++j) {
  12571. ret[b[j]] = i + 1;
  12572. }
  12573. }
  12574. return ret;
  12575. }([ [ "||" ], [ "&&" ], [ "|" ], [ "^" ], [ "&" ], [ "==", "===", "!=", "!==" ], [ "<", ">", "<=", ">=", "in", "instanceof" ], [ ">>", "<<", ">>>" ], [ "+", "-" ], [ "*", "/", "%" ] ], {});
  12576. var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
  12577. var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
  12578. function parse($TEXT, options) {
  12579. options = defaults(options, {
  12580. strict: false,
  12581. filename: null,
  12582. toplevel: null,
  12583. expression: false,
  12584. html5_comments: true
  12585. });
  12586. var S = {
  12587. input: typeof $TEXT == "string" ? tokenizer($TEXT, options.filename, options.html5_comments) : $TEXT,
  12588. token: null,
  12589. prev: null,
  12590. peeked: null,
  12591. in_function: 0,
  12592. in_directives: true,
  12593. in_loop: 0,
  12594. labels: []
  12595. };
  12596. S.token = next();
  12597. function is(type, value) {
  12598. return is_token(S.token, type, value);
  12599. }
  12600. function peek() {
  12601. return S.peeked || (S.peeked = S.input());
  12602. }
  12603. function next() {
  12604. S.prev = S.token;
  12605. if (S.peeked) {
  12606. S.token = S.peeked;
  12607. S.peeked = null;
  12608. } else {
  12609. S.token = S.input();
  12610. }
  12611. S.in_directives = S.in_directives && (S.token.type == "string" || is("punc", ";"));
  12612. return S.token;
  12613. }
  12614. function prev() {
  12615. return S.prev;
  12616. }
  12617. function croak(msg, line, col, pos) {
  12618. var ctx = S.input.context();
  12619. js_error(msg, ctx.filename, line != null ? line : ctx.tokline, col != null ? col : ctx.tokcol, pos != null ? pos : ctx.tokpos);
  12620. }
  12621. function token_error(token, msg) {
  12622. croak(msg, token.line, token.col);
  12623. }
  12624. function unexpected(token) {
  12625. if (token == null) token = S.token;
  12626. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  12627. }
  12628. function expect_token(type, val) {
  12629. if (is(type, val)) {
  12630. return next();
  12631. }
  12632. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  12633. }
  12634. function expect(punc) {
  12635. return expect_token("punc", punc);
  12636. }
  12637. function can_insert_semicolon() {
  12638. return !options.strict && (S.token.nlb || is("eof") || is("punc", "}"));
  12639. }
  12640. function semicolon() {
  12641. if (is("punc", ";")) next(); else if (!can_insert_semicolon()) unexpected();
  12642. }
  12643. function parenthesised() {
  12644. expect("(");
  12645. var exp = expression(true);
  12646. expect(")");
  12647. return exp;
  12648. }
  12649. function embed_tokens(parser) {
  12650. return function() {
  12651. var start = S.token;
  12652. var expr = parser();
  12653. var end = prev();
  12654. expr.start = start;
  12655. expr.end = end;
  12656. return expr;
  12657. };
  12658. }
  12659. function handle_regexp() {
  12660. if (is("operator", "/") || is("operator", "/=")) {
  12661. S.peeked = null;
  12662. S.token = S.input(S.token.value.substr(1));
  12663. }
  12664. }
  12665. var statement = embed_tokens(function() {
  12666. var tmp;
  12667. handle_regexp();
  12668. switch (S.token.type) {
  12669. case "string":
  12670. var dir = S.in_directives, stat = simple_statement();
  12671. if (dir && stat.body instanceof AST_String && !is("punc", ",")) return new AST_Directive({
  12672. value: stat.body.value
  12673. });
  12674. return stat;
  12675. case "num":
  12676. case "regexp":
  12677. case "operator":
  12678. case "atom":
  12679. return simple_statement();
  12680. case "name":
  12681. return is_token(peek(), "punc", ":") ? labeled_statement() : simple_statement();
  12682. case "punc":
  12683. switch (S.token.value) {
  12684. case "{":
  12685. return new AST_BlockStatement({
  12686. start: S.token,
  12687. body: block_(),
  12688. end: prev()
  12689. });
  12690. case "[":
  12691. case "(":
  12692. return simple_statement();
  12693. case ";":
  12694. next();
  12695. return new AST_EmptyStatement();
  12696. default:
  12697. unexpected();
  12698. }
  12699. case "keyword":
  12700. switch (tmp = S.token.value, next(), tmp) {
  12701. case "break":
  12702. return break_cont(AST_Break);
  12703. case "continue":
  12704. return break_cont(AST_Continue);
  12705. case "debugger":
  12706. semicolon();
  12707. return new AST_Debugger();
  12708. case "do":
  12709. return new AST_Do({
  12710. body: in_loop(statement),
  12711. condition: (expect_token("keyword", "while"), tmp = parenthesised(), semicolon(),
  12712. tmp)
  12713. });
  12714. case "while":
  12715. return new AST_While({
  12716. condition: parenthesised(),
  12717. body: in_loop(statement)
  12718. });
  12719. case "for":
  12720. return for_();
  12721. case "function":
  12722. return function_(AST_Defun);
  12723. case "if":
  12724. return if_();
  12725. case "return":
  12726. if (S.in_function == 0) croak("'return' outside of function");
  12727. return new AST_Return({
  12728. value: is("punc", ";") ? (next(), null) : can_insert_semicolon() ? null : (tmp = expression(true),
  12729. semicolon(), tmp)
  12730. });
  12731. case "switch":
  12732. return new AST_Switch({
  12733. expression: parenthesised(),
  12734. body: in_loop(switch_body_)
  12735. });
  12736. case "throw":
  12737. if (S.token.nlb) croak("Illegal newline after 'throw'");
  12738. return new AST_Throw({
  12739. value: (tmp = expression(true), semicolon(), tmp)
  12740. });
  12741. case "try":
  12742. return try_();
  12743. case "var":
  12744. return tmp = var_(), semicolon(), tmp;
  12745. case "const":
  12746. return tmp = const_(), semicolon(), tmp;
  12747. case "with":
  12748. return new AST_With({
  12749. expression: parenthesised(),
  12750. body: statement()
  12751. });
  12752. default:
  12753. unexpected();
  12754. }
  12755. }
  12756. });
  12757. function labeled_statement() {
  12758. var label = as_symbol(AST_Label);
  12759. if (find_if(function(l) {
  12760. return l.name == label.name;
  12761. }, S.labels)) {
  12762. croak("Label " + label.name + " defined twice");
  12763. }
  12764. expect(":");
  12765. S.labels.push(label);
  12766. var stat = statement();
  12767. S.labels.pop();
  12768. if (!(stat instanceof AST_IterationStatement)) {
  12769. label.references.forEach(function(ref) {
  12770. if (ref instanceof AST_Continue) {
  12771. ref = ref.label.start;
  12772. croak("Continue label `" + label.name + "` refers to non-IterationStatement.", ref.line, ref.col, ref.pos);
  12773. }
  12774. });
  12775. }
  12776. return new AST_LabeledStatement({
  12777. body: stat,
  12778. label: label
  12779. });
  12780. }
  12781. function simple_statement(tmp) {
  12782. return new AST_SimpleStatement({
  12783. body: (tmp = expression(true), semicolon(), tmp)
  12784. });
  12785. }
  12786. function break_cont(type) {
  12787. var label = null, ldef;
  12788. if (!can_insert_semicolon()) {
  12789. label = as_symbol(AST_LabelRef, true);
  12790. }
  12791. if (label != null) {
  12792. ldef = find_if(function(l) {
  12793. return l.name == label.name;
  12794. }, S.labels);
  12795. if (!ldef) croak("Undefined label " + label.name);
  12796. label.thedef = ldef;
  12797. } else if (S.in_loop == 0) croak(type.TYPE + " not inside a loop or switch");
  12798. semicolon();
  12799. var stat = new type({
  12800. label: label
  12801. });
  12802. if (ldef) ldef.references.push(stat);
  12803. return stat;
  12804. }
  12805. function for_() {
  12806. expect("(");
  12807. var init = null;
  12808. if (!is("punc", ";")) {
  12809. init = is("keyword", "var") ? (next(), var_(true)) : expression(true, true);
  12810. if (is("operator", "in")) {
  12811. if (init instanceof AST_Var && init.definitions.length > 1) croak("Only one variable declaration allowed in for..in loop");
  12812. next();
  12813. return for_in(init);
  12814. }
  12815. }
  12816. return regular_for(init);
  12817. }
  12818. function regular_for(init) {
  12819. expect(";");
  12820. var test = is("punc", ";") ? null : expression(true);
  12821. expect(";");
  12822. var step = is("punc", ")") ? null : expression(true);
  12823. expect(")");
  12824. return new AST_For({
  12825. init: init,
  12826. condition: test,
  12827. step: step,
  12828. body: in_loop(statement)
  12829. });
  12830. }
  12831. function for_in(init) {
  12832. var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
  12833. var obj = expression(true);
  12834. expect(")");
  12835. return new AST_ForIn({
  12836. init: init,
  12837. name: lhs,
  12838. object: obj,
  12839. body: in_loop(statement)
  12840. });
  12841. }
  12842. var function_ = function(ctor) {
  12843. var in_statement = ctor === AST_Defun;
  12844. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  12845. if (in_statement && !name) unexpected();
  12846. expect("(");
  12847. return new ctor({
  12848. name: name,
  12849. argnames: function(first, a) {
  12850. while (!is("punc", ")")) {
  12851. if (first) first = false; else expect(",");
  12852. a.push(as_symbol(AST_SymbolFunarg));
  12853. }
  12854. next();
  12855. return a;
  12856. }(true, []),
  12857. body: function(loop, labels) {
  12858. ++S.in_function;
  12859. S.in_directives = true;
  12860. S.in_loop = 0;
  12861. S.labels = [];
  12862. var a = block_();
  12863. --S.in_function;
  12864. S.in_loop = loop;
  12865. S.labels = labels;
  12866. return a;
  12867. }(S.in_loop, S.labels)
  12868. });
  12869. };
  12870. function if_() {
  12871. var cond = parenthesised(), body = statement(), belse = null;
  12872. if (is("keyword", "else")) {
  12873. next();
  12874. belse = statement();
  12875. }
  12876. return new AST_If({
  12877. condition: cond,
  12878. body: body,
  12879. alternative: belse
  12880. });
  12881. }
  12882. function block_() {
  12883. expect("{");
  12884. var a = [];
  12885. while (!is("punc", "}")) {
  12886. if (is("eof")) unexpected();
  12887. a.push(statement());
  12888. }
  12889. next();
  12890. return a;
  12891. }
  12892. function switch_body_() {
  12893. expect("{");
  12894. var a = [], cur = null, branch = null, tmp;
  12895. while (!is("punc", "}")) {
  12896. if (is("eof")) unexpected();
  12897. if (is("keyword", "case")) {
  12898. if (branch) branch.end = prev();
  12899. cur = [];
  12900. branch = new AST_Case({
  12901. start: (tmp = S.token, next(), tmp),
  12902. expression: expression(true),
  12903. body: cur
  12904. });
  12905. a.push(branch);
  12906. expect(":");
  12907. } else if (is("keyword", "default")) {
  12908. if (branch) branch.end = prev();
  12909. cur = [];
  12910. branch = new AST_Default({
  12911. start: (tmp = S.token, next(), expect(":"), tmp),
  12912. body: cur
  12913. });
  12914. a.push(branch);
  12915. } else {
  12916. if (!cur) unexpected();
  12917. cur.push(statement());
  12918. }
  12919. }
  12920. if (branch) branch.end = prev();
  12921. next();
  12922. return a;
  12923. }
  12924. function try_() {
  12925. var body = block_(), bcatch = null, bfinally = null;
  12926. if (is("keyword", "catch")) {
  12927. var start = S.token;
  12928. next();
  12929. expect("(");
  12930. var name = as_symbol(AST_SymbolCatch);
  12931. expect(")");
  12932. bcatch = new AST_Catch({
  12933. start: start,
  12934. argname: name,
  12935. body: block_(),
  12936. end: prev()
  12937. });
  12938. }
  12939. if (is("keyword", "finally")) {
  12940. var start = S.token;
  12941. next();
  12942. bfinally = new AST_Finally({
  12943. start: start,
  12944. body: block_(),
  12945. end: prev()
  12946. });
  12947. }
  12948. if (!bcatch && !bfinally) croak("Missing catch/finally blocks");
  12949. return new AST_Try({
  12950. body: body,
  12951. bcatch: bcatch,
  12952. bfinally: bfinally
  12953. });
  12954. }
  12955. function vardefs(no_in, in_const) {
  12956. var a = [];
  12957. for (;;) {
  12958. a.push(new AST_VarDef({
  12959. start: S.token,
  12960. name: as_symbol(in_const ? AST_SymbolConst : AST_SymbolVar),
  12961. value: is("operator", "=") ? (next(), expression(false, no_in)) : null,
  12962. end: prev()
  12963. }));
  12964. if (!is("punc", ",")) break;
  12965. next();
  12966. }
  12967. return a;
  12968. }
  12969. var var_ = function(no_in) {
  12970. return new AST_Var({
  12971. start: prev(),
  12972. definitions: vardefs(no_in, false),
  12973. end: prev()
  12974. });
  12975. };
  12976. var const_ = function() {
  12977. return new AST_Const({
  12978. start: prev(),
  12979. definitions: vardefs(false, true),
  12980. end: prev()
  12981. });
  12982. };
  12983. var new_ = function() {
  12984. var start = S.token;
  12985. expect_token("operator", "new");
  12986. var newexp = expr_atom(false), args;
  12987. if (is("punc", "(")) {
  12988. next();
  12989. args = expr_list(")");
  12990. } else {
  12991. args = [];
  12992. }
  12993. return subscripts(new AST_New({
  12994. start: start,
  12995. expression: newexp,
  12996. args: args,
  12997. end: prev()
  12998. }), true);
  12999. };
  13000. function as_atom_node() {
  13001. var tok = S.token, ret;
  13002. switch (tok.type) {
  13003. case "name":
  13004. case "keyword":
  13005. ret = _make_symbol(AST_SymbolRef);
  13006. break;
  13007. case "num":
  13008. ret = new AST_Number({
  13009. start: tok,
  13010. end: tok,
  13011. value: tok.value
  13012. });
  13013. break;
  13014. case "string":
  13015. ret = new AST_String({
  13016. start: tok,
  13017. end: tok,
  13018. value: tok.value
  13019. });
  13020. break;
  13021. case "regexp":
  13022. ret = new AST_RegExp({
  13023. start: tok,
  13024. end: tok,
  13025. value: tok.value
  13026. });
  13027. break;
  13028. case "atom":
  13029. switch (tok.value) {
  13030. case "false":
  13031. ret = new AST_False({
  13032. start: tok,
  13033. end: tok
  13034. });
  13035. break;
  13036. case "true":
  13037. ret = new AST_True({
  13038. start: tok,
  13039. end: tok
  13040. });
  13041. break;
  13042. case "null":
  13043. ret = new AST_Null({
  13044. start: tok,
  13045. end: tok
  13046. });
  13047. break;
  13048. }
  13049. break;
  13050. }
  13051. next();
  13052. return ret;
  13053. }
  13054. var expr_atom = function(allow_calls) {
  13055. if (is("operator", "new")) {
  13056. return new_();
  13057. }
  13058. var start = S.token;
  13059. if (is("punc")) {
  13060. switch (start.value) {
  13061. case "(":
  13062. next();
  13063. var ex = expression(true);
  13064. ex.start = start;
  13065. ex.end = S.token;
  13066. expect(")");
  13067. return subscripts(ex, allow_calls);
  13068. case "[":
  13069. return subscripts(array_(), allow_calls);
  13070. case "{":
  13071. return subscripts(object_(), allow_calls);
  13072. }
  13073. unexpected();
  13074. }
  13075. if (is("keyword", "function")) {
  13076. next();
  13077. var func = function_(AST_Function);
  13078. func.start = start;
  13079. func.end = prev();
  13080. return subscripts(func, allow_calls);
  13081. }
  13082. if (ATOMIC_START_TOKEN[S.token.type]) {
  13083. return subscripts(as_atom_node(), allow_calls);
  13084. }
  13085. unexpected();
  13086. };
  13087. function expr_list(closing, allow_trailing_comma, allow_empty) {
  13088. var first = true, a = [];
  13089. while (!is("punc", closing)) {
  13090. if (first) first = false; else expect(",");
  13091. if (allow_trailing_comma && is("punc", closing)) break;
  13092. if (is("punc", ",") && allow_empty) {
  13093. a.push(new AST_Hole({
  13094. start: S.token,
  13095. end: S.token
  13096. }));
  13097. } else {
  13098. a.push(expression(false));
  13099. }
  13100. }
  13101. next();
  13102. return a;
  13103. }
  13104. var array_ = embed_tokens(function() {
  13105. expect("[");
  13106. return new AST_Array({
  13107. elements: expr_list("]", !options.strict, true)
  13108. });
  13109. });
  13110. var object_ = embed_tokens(function() {
  13111. expect("{");
  13112. var first = true, a = [];
  13113. while (!is("punc", "}")) {
  13114. if (first) first = false; else expect(",");
  13115. if (!options.strict && is("punc", "}")) break;
  13116. var start = S.token;
  13117. var type = start.type;
  13118. var name = as_property_name();
  13119. if (type == "name" && !is("punc", ":")) {
  13120. if (name == "get") {
  13121. a.push(new AST_ObjectGetter({
  13122. start: start,
  13123. key: as_atom_node(),
  13124. value: function_(AST_Accessor),
  13125. end: prev()
  13126. }));
  13127. continue;
  13128. }
  13129. if (name == "set") {
  13130. a.push(new AST_ObjectSetter({
  13131. start: start,
  13132. key: as_atom_node(),
  13133. value: function_(AST_Accessor),
  13134. end: prev()
  13135. }));
  13136. continue;
  13137. }
  13138. }
  13139. expect(":");
  13140. a.push(new AST_ObjectKeyVal({
  13141. start: start,
  13142. key: name,
  13143. value: expression(false),
  13144. end: prev()
  13145. }));
  13146. }
  13147. next();
  13148. return new AST_Object({
  13149. properties: a
  13150. });
  13151. });
  13152. function as_property_name() {
  13153. var tmp = S.token;
  13154. next();
  13155. switch (tmp.type) {
  13156. case "num":
  13157. case "string":
  13158. case "name":
  13159. case "operator":
  13160. case "keyword":
  13161. case "atom":
  13162. return tmp.value;
  13163. default:
  13164. unexpected();
  13165. }
  13166. }
  13167. function as_name() {
  13168. var tmp = S.token;
  13169. next();
  13170. switch (tmp.type) {
  13171. case "name":
  13172. case "operator":
  13173. case "keyword":
  13174. case "atom":
  13175. return tmp.value;
  13176. default:
  13177. unexpected();
  13178. }
  13179. }
  13180. function _make_symbol(type) {
  13181. var name = S.token.value;
  13182. return new (name == "this" ? AST_This : type)({
  13183. name: String(name),
  13184. start: S.token,
  13185. end: S.token
  13186. });
  13187. }
  13188. function as_symbol(type, noerror) {
  13189. if (!is("name")) {
  13190. if (!noerror) croak("Name expected");
  13191. return null;
  13192. }
  13193. var sym = _make_symbol(type);
  13194. next();
  13195. return sym;
  13196. }
  13197. var subscripts = function(expr, allow_calls) {
  13198. var start = expr.start;
  13199. if (is("punc", ".")) {
  13200. next();
  13201. return subscripts(new AST_Dot({
  13202. start: start,
  13203. expression: expr,
  13204. property: as_name(),
  13205. end: prev()
  13206. }), allow_calls);
  13207. }
  13208. if (is("punc", "[")) {
  13209. next();
  13210. var prop = expression(true);
  13211. expect("]");
  13212. return subscripts(new AST_Sub({
  13213. start: start,
  13214. expression: expr,
  13215. property: prop,
  13216. end: prev()
  13217. }), allow_calls);
  13218. }
  13219. if (allow_calls && is("punc", "(")) {
  13220. next();
  13221. return subscripts(new AST_Call({
  13222. start: start,
  13223. expression: expr,
  13224. args: expr_list(")"),
  13225. end: prev()
  13226. }), true);
  13227. }
  13228. return expr;
  13229. };
  13230. var maybe_unary = function(allow_calls) {
  13231. var start = S.token;
  13232. if (is("operator") && UNARY_PREFIX(start.value)) {
  13233. next();
  13234. handle_regexp();
  13235. var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls));
  13236. ex.start = start;
  13237. ex.end = prev();
  13238. return ex;
  13239. }
  13240. var val = expr_atom(allow_calls);
  13241. while (is("operator") && UNARY_POSTFIX(S.token.value) && !S.token.nlb) {
  13242. val = make_unary(AST_UnaryPostfix, S.token.value, val);
  13243. val.start = start;
  13244. val.end = S.token;
  13245. next();
  13246. }
  13247. return val;
  13248. };
  13249. function make_unary(ctor, op, expr) {
  13250. if ((op == "++" || op == "--") && !is_assignable(expr)) croak("Invalid use of " + op + " operator");
  13251. return new ctor({
  13252. operator: op,
  13253. expression: expr
  13254. });
  13255. }
  13256. var expr_op = function(left, min_prec, no_in) {
  13257. var op = is("operator") ? S.token.value : null;
  13258. if (op == "in" && no_in) op = null;
  13259. var prec = op != null ? PRECEDENCE[op] : null;
  13260. if (prec != null && prec > min_prec) {
  13261. next();
  13262. var right = expr_op(maybe_unary(true), prec, no_in);
  13263. return expr_op(new AST_Binary({
  13264. start: left.start,
  13265. left: left,
  13266. operator: op,
  13267. right: right,
  13268. end: right.end
  13269. }), min_prec, no_in);
  13270. }
  13271. return left;
  13272. };
  13273. function expr_ops(no_in) {
  13274. return expr_op(maybe_unary(true), 0, no_in);
  13275. }
  13276. var maybe_conditional = function(no_in) {
  13277. var start = S.token;
  13278. var expr = expr_ops(no_in);
  13279. if (is("operator", "?")) {
  13280. next();
  13281. var yes = expression(false);
  13282. expect(":");
  13283. return new AST_Conditional({
  13284. start: start,
  13285. condition: expr,
  13286. consequent: yes,
  13287. alternative: expression(false, no_in),
  13288. end: prev()
  13289. });
  13290. }
  13291. return expr;
  13292. };
  13293. function is_assignable(expr) {
  13294. if (!options.strict) return true;
  13295. if (expr instanceof AST_This) return false;
  13296. return expr instanceof AST_PropAccess || expr instanceof AST_Symbol;
  13297. }
  13298. var maybe_assign = function(no_in) {
  13299. var start = S.token;
  13300. var left = maybe_conditional(no_in), val = S.token.value;
  13301. if (is("operator") && ASSIGNMENT(val)) {
  13302. if (is_assignable(left)) {
  13303. next();
  13304. return new AST_Assign({
  13305. start: start,
  13306. left: left,
  13307. operator: val,
  13308. right: maybe_assign(no_in),
  13309. end: prev()
  13310. });
  13311. }
  13312. croak("Invalid assignment");
  13313. }
  13314. return left;
  13315. };
  13316. var expression = function(commas, no_in) {
  13317. var start = S.token;
  13318. var expr = maybe_assign(no_in);
  13319. if (commas && is("punc", ",")) {
  13320. next();
  13321. return new AST_Seq({
  13322. start: start,
  13323. car: expr,
  13324. cdr: expression(true, no_in),
  13325. end: peek()
  13326. });
  13327. }
  13328. return expr;
  13329. };
  13330. function in_loop(cont) {
  13331. ++S.in_loop;
  13332. var ret = cont();
  13333. --S.in_loop;
  13334. return ret;
  13335. }
  13336. if (options.expression) {
  13337. return expression(true);
  13338. }
  13339. return function() {
  13340. var start = S.token;
  13341. var body = [];
  13342. while (!is("eof")) body.push(statement());
  13343. var end = prev();
  13344. var toplevel = options.toplevel;
  13345. if (toplevel) {
  13346. toplevel.body = toplevel.body.concat(body);
  13347. toplevel.end = end;
  13348. } else {
  13349. toplevel = new AST_Toplevel({
  13350. start: start,
  13351. body: body,
  13352. end: end
  13353. });
  13354. }
  13355. return toplevel;
  13356. }();
  13357. }
  13358. "use strict";
  13359. function TreeTransformer(before, after) {
  13360. TreeWalker.call(this);
  13361. this.before = before;
  13362. this.after = after;
  13363. }
  13364. TreeTransformer.prototype = new TreeWalker();
  13365. (function(undefined) {
  13366. function _(node, descend) {
  13367. node.DEFMETHOD("transform", function(tw, in_list) {
  13368. var x, y;
  13369. tw.push(this);
  13370. if (tw.before) x = tw.before(this, descend, in_list);
  13371. if (x === undefined) {
  13372. if (!tw.after) {
  13373. x = this;
  13374. descend(x, tw);
  13375. } else {
  13376. tw.stack[tw.stack.length - 1] = x = this.clone();
  13377. descend(x, tw);
  13378. y = tw.after(x, in_list);
  13379. if (y !== undefined) x = y;
  13380. }
  13381. }
  13382. tw.pop();
  13383. return x;
  13384. });
  13385. }
  13386. function do_list(list, tw) {
  13387. return MAP(list, function(node) {
  13388. return node.transform(tw, true);
  13389. });
  13390. }
  13391. _(AST_Node, noop);
  13392. _(AST_LabeledStatement, function(self, tw) {
  13393. self.label = self.label.transform(tw);
  13394. self.body = self.body.transform(tw);
  13395. });
  13396. _(AST_SimpleStatement, function(self, tw) {
  13397. self.body = self.body.transform(tw);
  13398. });
  13399. _(AST_Block, function(self, tw) {
  13400. self.body = do_list(self.body, tw);
  13401. });
  13402. _(AST_DWLoop, function(self, tw) {
  13403. self.condition = self.condition.transform(tw);
  13404. self.body = self.body.transform(tw);
  13405. });
  13406. _(AST_For, function(self, tw) {
  13407. if (self.init) self.init = self.init.transform(tw);
  13408. if (self.condition) self.condition = self.condition.transform(tw);
  13409. if (self.step) self.step = self.step.transform(tw);
  13410. self.body = self.body.transform(tw);
  13411. });
  13412. _(AST_ForIn, function(self, tw) {
  13413. self.init = self.init.transform(tw);
  13414. self.object = self.object.transform(tw);
  13415. self.body = self.body.transform(tw);
  13416. });
  13417. _(AST_With, function(self, tw) {
  13418. self.expression = self.expression.transform(tw);
  13419. self.body = self.body.transform(tw);
  13420. });
  13421. _(AST_Exit, function(self, tw) {
  13422. if (self.value) self.value = self.value.transform(tw);
  13423. });
  13424. _(AST_LoopControl, function(self, tw) {
  13425. if (self.label) self.label = self.label.transform(tw);
  13426. });
  13427. _(AST_If, function(self, tw) {
  13428. self.condition = self.condition.transform(tw);
  13429. self.body = self.body.transform(tw);
  13430. if (self.alternative) self.alternative = self.alternative.transform(tw);
  13431. });
  13432. _(AST_Switch, function(self, tw) {
  13433. self.expression = self.expression.transform(tw);
  13434. self.body = do_list(self.body, tw);
  13435. });
  13436. _(AST_Case, function(self, tw) {
  13437. self.expression = self.expression.transform(tw);
  13438. self.body = do_list(self.body, tw);
  13439. });
  13440. _(AST_Try, function(self, tw) {
  13441. self.body = do_list(self.body, tw);
  13442. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  13443. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  13444. });
  13445. _(AST_Catch, function(self, tw) {
  13446. self.argname = self.argname.transform(tw);
  13447. self.body = do_list(self.body, tw);
  13448. });
  13449. _(AST_Definitions, function(self, tw) {
  13450. self.definitions = do_list(self.definitions, tw);
  13451. });
  13452. _(AST_VarDef, function(self, tw) {
  13453. self.name = self.name.transform(tw);
  13454. if (self.value) self.value = self.value.transform(tw);
  13455. });
  13456. _(AST_Lambda, function(self, tw) {
  13457. if (self.name) self.name = self.name.transform(tw);
  13458. self.argnames = do_list(self.argnames, tw);
  13459. self.body = do_list(self.body, tw);
  13460. });
  13461. _(AST_Call, function(self, tw) {
  13462. self.expression = self.expression.transform(tw);
  13463. self.args = do_list(self.args, tw);
  13464. });
  13465. _(AST_Seq, function(self, tw) {
  13466. self.car = self.car.transform(tw);
  13467. self.cdr = self.cdr.transform(tw);
  13468. });
  13469. _(AST_Dot, function(self, tw) {
  13470. self.expression = self.expression.transform(tw);
  13471. });
  13472. _(AST_Sub, function(self, tw) {
  13473. self.expression = self.expression.transform(tw);
  13474. self.property = self.property.transform(tw);
  13475. });
  13476. _(AST_Unary, function(self, tw) {
  13477. self.expression = self.expression.transform(tw);
  13478. });
  13479. _(AST_Binary, function(self, tw) {
  13480. self.left = self.left.transform(tw);
  13481. self.right = self.right.transform(tw);
  13482. });
  13483. _(AST_Conditional, function(self, tw) {
  13484. self.condition = self.condition.transform(tw);
  13485. self.consequent = self.consequent.transform(tw);
  13486. self.alternative = self.alternative.transform(tw);
  13487. });
  13488. _(AST_Array, function(self, tw) {
  13489. self.elements = do_list(self.elements, tw);
  13490. });
  13491. _(AST_Object, function(self, tw) {
  13492. self.properties = do_list(self.properties, tw);
  13493. });
  13494. _(AST_ObjectProperty, function(self, tw) {
  13495. self.value = self.value.transform(tw);
  13496. });
  13497. })();
  13498. "use strict";
  13499. function SymbolDef(scope, index, orig) {
  13500. this.name = orig.name;
  13501. this.orig = [ orig ];
  13502. this.scope = scope;
  13503. this.references = [];
  13504. this.global = false;
  13505. this.mangled_name = null;
  13506. this.undeclared = false;
  13507. this.constant = false;
  13508. this.index = index;
  13509. }
  13510. SymbolDef.prototype = {
  13511. unmangleable: function(options) {
  13512. return this.global && !(options && options.toplevel) || this.undeclared || !(options && options.eval) && (this.scope.uses_eval || this.scope.uses_with);
  13513. },
  13514. mangle: function(options) {
  13515. if (!this.mangled_name && !this.unmangleable(options)) {
  13516. var s = this.scope;
  13517. if (!options.screw_ie8 && this.orig[0] instanceof AST_SymbolLambda) s = s.parent_scope;
  13518. this.mangled_name = s.next_mangled(options, this);
  13519. }
  13520. }
  13521. };
  13522. AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
  13523. options = defaults(options, {
  13524. screw_ie8: false
  13525. });
  13526. var self = this;
  13527. var scope = self.parent_scope = null;
  13528. var defun = null;
  13529. var nesting = 0;
  13530. var tw = new TreeWalker(function(node, descend) {
  13531. if (options.screw_ie8 && node instanceof AST_Catch) {
  13532. var save_scope = scope;
  13533. scope = new AST_Scope(node);
  13534. scope.init_scope_vars(nesting);
  13535. scope.parent_scope = save_scope;
  13536. descend();
  13537. scope = save_scope;
  13538. return true;
  13539. }
  13540. if (node instanceof AST_Scope) {
  13541. node.init_scope_vars(nesting);
  13542. var save_scope = node.parent_scope = scope;
  13543. var save_defun = defun;
  13544. defun = scope = node;
  13545. ++nesting;
  13546. descend();
  13547. --nesting;
  13548. scope = save_scope;
  13549. defun = save_defun;
  13550. return true;
  13551. }
  13552. if (node instanceof AST_Directive) {
  13553. node.scope = scope;
  13554. push_uniq(scope.directives, node.value);
  13555. return true;
  13556. }
  13557. if (node instanceof AST_With) {
  13558. for (var s = scope; s; s = s.parent_scope) s.uses_with = true;
  13559. return;
  13560. }
  13561. if (node instanceof AST_Symbol) {
  13562. node.scope = scope;
  13563. }
  13564. if (node instanceof AST_SymbolLambda) {
  13565. defun.def_function(node);
  13566. } else if (node instanceof AST_SymbolDefun) {
  13567. (node.scope = defun.parent_scope).def_function(node);
  13568. } else if (node instanceof AST_SymbolVar || node instanceof AST_SymbolConst) {
  13569. var def = defun.def_variable(node);
  13570. def.constant = node instanceof AST_SymbolConst;
  13571. def.init = tw.parent().value;
  13572. } else if (node instanceof AST_SymbolCatch) {
  13573. (options.screw_ie8 ? scope : defun).def_variable(node);
  13574. }
  13575. });
  13576. self.walk(tw);
  13577. var func = null;
  13578. var globals = self.globals = new Dictionary();
  13579. var tw = new TreeWalker(function(node, descend) {
  13580. if (node instanceof AST_Lambda) {
  13581. var prev_func = func;
  13582. func = node;
  13583. descend();
  13584. func = prev_func;
  13585. return true;
  13586. }
  13587. if (node instanceof AST_SymbolRef) {
  13588. var name = node.name;
  13589. var sym = node.scope.find_variable(name);
  13590. if (!sym) {
  13591. var g;
  13592. if (globals.has(name)) {
  13593. g = globals.get(name);
  13594. } else {
  13595. g = new SymbolDef(self, globals.size(), node);
  13596. g.undeclared = true;
  13597. g.global = true;
  13598. globals.set(name, g);
  13599. }
  13600. node.thedef = g;
  13601. if (name == "eval" && tw.parent() instanceof AST_Call) {
  13602. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) s.uses_eval = true;
  13603. }
  13604. if (func && name == "arguments") {
  13605. func.uses_arguments = true;
  13606. }
  13607. } else {
  13608. node.thedef = sym;
  13609. }
  13610. node.reference();
  13611. return true;
  13612. }
  13613. });
  13614. self.walk(tw);
  13615. });
  13616. AST_Scope.DEFMETHOD("init_scope_vars", function(nesting) {
  13617. this.directives = [];
  13618. this.variables = new Dictionary();
  13619. this.functions = new Dictionary();
  13620. this.uses_with = false;
  13621. this.uses_eval = false;
  13622. this.parent_scope = null;
  13623. this.enclosed = [];
  13624. this.cname = -1;
  13625. this.nesting = nesting;
  13626. });
  13627. AST_Scope.DEFMETHOD("strict", function() {
  13628. return this.has_directive("use strict");
  13629. });
  13630. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  13631. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  13632. this.uses_arguments = false;
  13633. });
  13634. AST_SymbolRef.DEFMETHOD("reference", function() {
  13635. var def = this.definition();
  13636. def.references.push(this);
  13637. var s = this.scope;
  13638. while (s) {
  13639. push_uniq(s.enclosed, def);
  13640. if (s === def.scope) break;
  13641. s = s.parent_scope;
  13642. }
  13643. this.frame = this.scope.nesting - def.scope.nesting;
  13644. });
  13645. AST_Scope.DEFMETHOD("find_variable", function(name) {
  13646. if (name instanceof AST_Symbol) name = name.name;
  13647. return this.variables.get(name) || this.parent_scope && this.parent_scope.find_variable(name);
  13648. });
  13649. AST_Scope.DEFMETHOD("has_directive", function(value) {
  13650. return this.parent_scope && this.parent_scope.has_directive(value) || (this.directives.indexOf(value) >= 0 ? this : null);
  13651. });
  13652. AST_Scope.DEFMETHOD("def_function", function(symbol) {
  13653. this.functions.set(symbol.name, this.def_variable(symbol));
  13654. });
  13655. AST_Scope.DEFMETHOD("def_variable", function(symbol) {
  13656. var def;
  13657. if (!this.variables.has(symbol.name)) {
  13658. def = new SymbolDef(this, this.variables.size(), symbol);
  13659. this.variables.set(symbol.name, def);
  13660. def.global = !this.parent_scope;
  13661. } else {
  13662. def = this.variables.get(symbol.name);
  13663. def.orig.push(symbol);
  13664. }
  13665. return symbol.thedef = def;
  13666. });
  13667. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  13668. var ext = this.enclosed;
  13669. out: while (true) {
  13670. var m = base54(++this.cname);
  13671. if (!is_identifier(m)) continue;
  13672. if (options.except.indexOf(m) >= 0) continue;
  13673. for (var i = ext.length; --i >= 0; ) {
  13674. var sym = ext[i];
  13675. var name = sym.mangled_name || sym.unmangleable(options) && sym.name;
  13676. if (m == name) continue out;
  13677. }
  13678. return m;
  13679. }
  13680. });
  13681. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  13682. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  13683. while (true) {
  13684. var name = AST_Lambda.prototype.next_mangled.call(this, options, def);
  13685. if (!(tricky_def && tricky_def.mangled_name == name)) return name;
  13686. }
  13687. });
  13688. AST_Scope.DEFMETHOD("references", function(sym) {
  13689. if (sym instanceof AST_Symbol) sym = sym.definition();
  13690. return this.enclosed.indexOf(sym) < 0 ? null : sym;
  13691. });
  13692. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  13693. return this.definition().unmangleable(options);
  13694. });
  13695. AST_SymbolAccessor.DEFMETHOD("unmangleable", function() {
  13696. return true;
  13697. });
  13698. AST_Label.DEFMETHOD("unmangleable", function() {
  13699. return false;
  13700. });
  13701. AST_Symbol.DEFMETHOD("unreferenced", function() {
  13702. return this.definition().references.length == 0 && !(this.scope.uses_eval || this.scope.uses_with);
  13703. });
  13704. AST_Symbol.DEFMETHOD("undeclared", function() {
  13705. return this.definition().undeclared;
  13706. });
  13707. AST_LabelRef.DEFMETHOD("undeclared", function() {
  13708. return false;
  13709. });
  13710. AST_Label.DEFMETHOD("undeclared", function() {
  13711. return false;
  13712. });
  13713. AST_Symbol.DEFMETHOD("definition", function() {
  13714. return this.thedef;
  13715. });
  13716. AST_Symbol.DEFMETHOD("global", function() {
  13717. return this.definition().global;
  13718. });
  13719. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  13720. return defaults(options, {
  13721. except: [],
  13722. eval: false,
  13723. sort: false,
  13724. toplevel: false,
  13725. screw_ie8: false
  13726. });
  13727. });
  13728. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  13729. options = this._default_mangler_options(options);
  13730. var lname = -1;
  13731. var to_mangle = [];
  13732. var tw = new TreeWalker(function(node, descend) {
  13733. if (node instanceof AST_LabeledStatement) {
  13734. var save_nesting = lname;
  13735. descend();
  13736. lname = save_nesting;
  13737. return true;
  13738. }
  13739. if (node instanceof AST_Scope) {
  13740. var p = tw.parent(), a = [];
  13741. node.variables.each(function(symbol) {
  13742. if (options.except.indexOf(symbol.name) < 0) {
  13743. a.push(symbol);
  13744. }
  13745. });
  13746. if (options.sort) a.sort(function(a, b) {
  13747. return b.references.length - a.references.length;
  13748. });
  13749. to_mangle.push.apply(to_mangle, a);
  13750. return;
  13751. }
  13752. if (node instanceof AST_Label) {
  13753. var name;
  13754. do name = base54(++lname); while (!is_identifier(name));
  13755. node.mangled_name = name;
  13756. return true;
  13757. }
  13758. if (options.screw_ie8 && node instanceof AST_SymbolCatch) {
  13759. to_mangle.push(node.definition());
  13760. return;
  13761. }
  13762. });
  13763. this.walk(tw);
  13764. to_mangle.forEach(function(def) {
  13765. def.mangle(options);
  13766. });
  13767. });
  13768. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  13769. options = this._default_mangler_options(options);
  13770. var tw = new TreeWalker(function(node) {
  13771. if (node instanceof AST_Constant) base54.consider(node.print_to_string()); else if (node instanceof AST_Return) base54.consider("return"); else if (node instanceof AST_Throw) base54.consider("throw"); else if (node instanceof AST_Continue) base54.consider("continue"); else if (node instanceof AST_Break) base54.consider("break"); else if (node instanceof AST_Debugger) base54.consider("debugger"); else if (node instanceof AST_Directive) base54.consider(node.value); else if (node instanceof AST_While) base54.consider("while"); else if (node instanceof AST_Do) base54.consider("do while"); else if (node instanceof AST_If) {
  13772. base54.consider("if");
  13773. if (node.alternative) base54.consider("else");
  13774. } else if (node instanceof AST_Var) base54.consider("var"); else if (node instanceof AST_Const) base54.consider("const"); else if (node instanceof AST_Lambda) base54.consider("function"); else if (node instanceof AST_For) base54.consider("for"); else if (node instanceof AST_ForIn) base54.consider("for in"); else if (node instanceof AST_Switch) base54.consider("switch"); else if (node instanceof AST_Case) base54.consider("case"); else if (node instanceof AST_Default) base54.consider("default"); else if (node instanceof AST_With) base54.consider("with"); else if (node instanceof AST_ObjectSetter) base54.consider("set" + node.key); else if (node instanceof AST_ObjectGetter) base54.consider("get" + node.key); else if (node instanceof AST_ObjectKeyVal) base54.consider(node.key); else if (node instanceof AST_New) base54.consider("new"); else if (node instanceof AST_This) base54.consider("this"); else if (node instanceof AST_Try) base54.consider("try"); else if (node instanceof AST_Catch) base54.consider("catch"); else if (node instanceof AST_Finally) base54.consider("finally"); else if (node instanceof AST_Symbol && node.unmangleable(options)) base54.consider(node.name); else if (node instanceof AST_Unary || node instanceof AST_Binary) base54.consider(node.operator); else if (node instanceof AST_Dot) base54.consider(node.property);
  13775. });
  13776. this.walk(tw);
  13777. base54.sort();
  13778. });
  13779. var base54 = function() {
  13780. var string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
  13781. var chars, frequency;
  13782. function reset() {
  13783. frequency = Object.create(null);
  13784. chars = string.split("").map(function(ch) {
  13785. return ch.charCodeAt(0);
  13786. });
  13787. chars.forEach(function(ch) {
  13788. frequency[ch] = 0;
  13789. });
  13790. }
  13791. base54.consider = function(str) {
  13792. for (var i = str.length; --i >= 0; ) {
  13793. var code = str.charCodeAt(i);
  13794. if (code in frequency) ++frequency[code];
  13795. }
  13796. };
  13797. base54.sort = function() {
  13798. chars = mergeSort(chars, function(a, b) {
  13799. if (is_digit(a) && !is_digit(b)) return 1;
  13800. if (is_digit(b) && !is_digit(a)) return -1;
  13801. return frequency[b] - frequency[a];
  13802. });
  13803. };
  13804. base54.reset = reset;
  13805. reset();
  13806. base54.get = function() {
  13807. return chars;
  13808. };
  13809. base54.freq = function() {
  13810. return frequency;
  13811. };
  13812. function base54(num) {
  13813. var ret = "", base = 54;
  13814. do {
  13815. ret += String.fromCharCode(chars[num % base]);
  13816. num = Math.floor(num / base);
  13817. base = 64;
  13818. } while (num > 0);
  13819. return ret;
  13820. }
  13821. return base54;
  13822. }();
  13823. AST_Toplevel.DEFMETHOD("scope_warnings", function(options) {
  13824. options = defaults(options, {
  13825. undeclared: false,
  13826. unreferenced: true,
  13827. assign_to_global: true,
  13828. func_arguments: true,
  13829. nested_defuns: true,
  13830. eval: true
  13831. });
  13832. var tw = new TreeWalker(function(node) {
  13833. if (options.undeclared && node instanceof AST_SymbolRef && node.undeclared()) {
  13834. AST_Node.warn("Undeclared symbol: {name} [{file}:{line},{col}]", {
  13835. name: node.name,
  13836. file: node.start.file,
  13837. line: node.start.line,
  13838. col: node.start.col
  13839. });
  13840. }
  13841. if (options.assign_to_global) {
  13842. var sym = null;
  13843. if (node instanceof AST_Assign && node.left instanceof AST_SymbolRef) sym = node.left; else if (node instanceof AST_ForIn && node.init instanceof AST_SymbolRef) sym = node.init;
  13844. if (sym && (sym.undeclared() || sym.global() && sym.scope !== sym.definition().scope)) {
  13845. AST_Node.warn("{msg}: {name} [{file}:{line},{col}]", {
  13846. msg: sym.undeclared() ? "Accidental global?" : "Assignment to global",
  13847. name: sym.name,
  13848. file: sym.start.file,
  13849. line: sym.start.line,
  13850. col: sym.start.col
  13851. });
  13852. }
  13853. }
  13854. if (options.eval && node instanceof AST_SymbolRef && node.undeclared() && node.name == "eval") {
  13855. AST_Node.warn("Eval is used [{file}:{line},{col}]", node.start);
  13856. }
  13857. if (options.unreferenced && (node instanceof AST_SymbolDeclaration || node instanceof AST_Label) && node.unreferenced()) {
  13858. AST_Node.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]", {
  13859. type: node instanceof AST_Label ? "Label" : "Symbol",
  13860. name: node.name,
  13861. file: node.start.file,
  13862. line: node.start.line,
  13863. col: node.start.col
  13864. });
  13865. }
  13866. if (options.func_arguments && node instanceof AST_Lambda && node.uses_arguments) {
  13867. AST_Node.warn("arguments used in function {name} [{file}:{line},{col}]", {
  13868. name: node.name ? node.name.name : "anonymous",
  13869. file: node.start.file,
  13870. line: node.start.line,
  13871. col: node.start.col
  13872. });
  13873. }
  13874. if (options.nested_defuns && node instanceof AST_Defun && !(tw.parent() instanceof AST_Scope)) {
  13875. AST_Node.warn('Function {name} declared in nested statement "{type}" [{file}:{line},{col}]', {
  13876. name: node.name.name,
  13877. type: tw.parent().TYPE,
  13878. file: node.start.file,
  13879. line: node.start.line,
  13880. col: node.start.col
  13881. });
  13882. }
  13883. });
  13884. this.walk(tw);
  13885. });
  13886. "use strict";
  13887. function OutputStream(options) {
  13888. options = defaults(options, {
  13889. indent_start: 0,
  13890. indent_level: 4,
  13891. quote_keys: false,
  13892. space_colon: true,
  13893. ascii_only: false,
  13894. unescape_regexps: false,
  13895. inline_script: false,
  13896. width: 80,
  13897. max_line_len: 32e3,
  13898. beautify: false,
  13899. source_map: null,
  13900. bracketize: false,
  13901. semicolons: true,
  13902. comments: false,
  13903. preserve_line: false,
  13904. screw_ie8: false,
  13905. preamble: null
  13906. }, true);
  13907. var indentation = 0;
  13908. var current_col = 0;
  13909. var current_line = 1;
  13910. var current_pos = 0;
  13911. var OUTPUT = "";
  13912. function to_ascii(str, identifier) {
  13913. return str.replace(/[\u0080-\uffff]/g, function(ch) {
  13914. var code = ch.charCodeAt(0).toString(16);
  13915. if (code.length <= 2 && !identifier) {
  13916. while (code.length < 2) code = "0" + code;
  13917. return "\\x" + code;
  13918. } else {
  13919. while (code.length < 4) code = "0" + code;
  13920. return "\\u" + code;
  13921. }
  13922. });
  13923. }
  13924. function make_string(str) {
  13925. var dq = 0, sq = 0;
  13926. str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s) {
  13927. switch (s) {
  13928. case "\\":
  13929. return "\\\\";
  13930. case "\b":
  13931. return "\\b";
  13932. case "\f":
  13933. return "\\f";
  13934. case "\n":
  13935. return "\\n";
  13936. case "\r":
  13937. return "\\r";
  13938. case "\u2028":
  13939. return "\\u2028";
  13940. case "\u2029":
  13941. return "\\u2029";
  13942. case '"':
  13943. ++dq;
  13944. return '"';
  13945. case "'":
  13946. ++sq;
  13947. return "'";
  13948. case "\x00":
  13949. return "\\x00";
  13950. }
  13951. return s;
  13952. });
  13953. if (options.ascii_only) str = to_ascii(str);
  13954. if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'"; else return '"' + str.replace(/\x22/g, '\\"') + '"';
  13955. }
  13956. function encode_string(str) {
  13957. var ret = make_string(str);
  13958. if (options.inline_script) ret = ret.replace(/<\x2fscript([>\/\t\n\f\r ])/gi, "<\\/script$1");
  13959. return ret;
  13960. }
  13961. function make_name(name) {
  13962. name = name.toString();
  13963. if (options.ascii_only) name = to_ascii(name, true);
  13964. return name;
  13965. }
  13966. function make_indent(back) {
  13967. return repeat_string(" ", options.indent_start + indentation - back * options.indent_level);
  13968. }
  13969. var might_need_space = false;
  13970. var might_need_semicolon = false;
  13971. var last = null;
  13972. function last_char() {
  13973. return last.charAt(last.length - 1);
  13974. }
  13975. function maybe_newline() {
  13976. if (options.max_line_len && current_col > options.max_line_len) print("\n");
  13977. }
  13978. var requireSemicolonChars = makePredicate("( [ + * / - , .");
  13979. function print(str) {
  13980. str = String(str);
  13981. var ch = str.charAt(0);
  13982. if (might_need_semicolon) {
  13983. if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) {
  13984. if (options.semicolons || requireSemicolonChars(ch)) {
  13985. OUTPUT += ";";
  13986. current_col++;
  13987. current_pos++;
  13988. } else {
  13989. OUTPUT += "\n";
  13990. current_pos++;
  13991. current_line++;
  13992. current_col = 0;
  13993. }
  13994. if (!options.beautify) might_need_space = false;
  13995. }
  13996. might_need_semicolon = false;
  13997. maybe_newline();
  13998. }
  13999. if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {
  14000. var target_line = stack[stack.length - 1].start.line;
  14001. while (current_line < target_line) {
  14002. OUTPUT += "\n";
  14003. current_pos++;
  14004. current_line++;
  14005. current_col = 0;
  14006. might_need_space = false;
  14007. }
  14008. }
  14009. if (might_need_space) {
  14010. var prev = last_char();
  14011. if (is_identifier_char(prev) && (is_identifier_char(ch) || ch == "\\") || /^[\+\-\/]$/.test(ch) && ch == prev) {
  14012. OUTPUT += " ";
  14013. current_col++;
  14014. current_pos++;
  14015. }
  14016. might_need_space = false;
  14017. }
  14018. var a = str.split(/\r?\n/), n = a.length - 1;
  14019. current_line += n;
  14020. if (n == 0) {
  14021. current_col += a[n].length;
  14022. } else {
  14023. current_col = a[n].length;
  14024. }
  14025. current_pos += str.length;
  14026. last = str;
  14027. OUTPUT += str;
  14028. }
  14029. var space = options.beautify ? function() {
  14030. print(" ");
  14031. } : function() {
  14032. might_need_space = true;
  14033. };
  14034. var indent = options.beautify ? function(half) {
  14035. if (options.beautify) {
  14036. print(make_indent(half ? .5 : 0));
  14037. }
  14038. } : noop;
  14039. var with_indent = options.beautify ? function(col, cont) {
  14040. if (col === true) col = next_indent();
  14041. var save_indentation = indentation;
  14042. indentation = col;
  14043. var ret = cont();
  14044. indentation = save_indentation;
  14045. return ret;
  14046. } : function(col, cont) {
  14047. return cont();
  14048. };
  14049. var newline = options.beautify ? function() {
  14050. print("\n");
  14051. } : noop;
  14052. var semicolon = options.beautify ? function() {
  14053. print(";");
  14054. } : function() {
  14055. might_need_semicolon = true;
  14056. };
  14057. function force_semicolon() {
  14058. might_need_semicolon = false;
  14059. print(";");
  14060. }
  14061. function next_indent() {
  14062. return indentation + options.indent_level;
  14063. }
  14064. function with_block(cont) {
  14065. var ret;
  14066. print("{");
  14067. newline();
  14068. with_indent(next_indent(), function() {
  14069. ret = cont();
  14070. });
  14071. indent();
  14072. print("}");
  14073. return ret;
  14074. }
  14075. function with_parens(cont) {
  14076. print("(");
  14077. var ret = cont();
  14078. print(")");
  14079. return ret;
  14080. }
  14081. function with_square(cont) {
  14082. print("[");
  14083. var ret = cont();
  14084. print("]");
  14085. return ret;
  14086. }
  14087. function comma() {
  14088. print(",");
  14089. space();
  14090. }
  14091. function colon() {
  14092. print(":");
  14093. if (options.space_colon) space();
  14094. }
  14095. var add_mapping = options.source_map ? function(token, name) {
  14096. try {
  14097. if (token) options.source_map.add(token.file || "?", current_line, current_col, token.line, token.col, !name && token.type == "name" ? token.value : name);
  14098. } catch (ex) {
  14099. AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {
  14100. file: token.file,
  14101. line: token.line,
  14102. col: token.col,
  14103. cline: current_line,
  14104. ccol: current_col,
  14105. name: name || ""
  14106. });
  14107. }
  14108. } : noop;
  14109. function get() {
  14110. return OUTPUT;
  14111. }
  14112. if (options.preamble) {
  14113. print(options.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  14114. }
  14115. var stack = [];
  14116. return {
  14117. get: get,
  14118. toString: get,
  14119. indent: indent,
  14120. indentation: function() {
  14121. return indentation;
  14122. },
  14123. current_width: function() {
  14124. return current_col - indentation;
  14125. },
  14126. should_break: function() {
  14127. return options.width && this.current_width() >= options.width;
  14128. },
  14129. newline: newline,
  14130. print: print,
  14131. space: space,
  14132. comma: comma,
  14133. colon: colon,
  14134. last: function() {
  14135. return last;
  14136. },
  14137. semicolon: semicolon,
  14138. force_semicolon: force_semicolon,
  14139. to_ascii: to_ascii,
  14140. print_name: function(name) {
  14141. print(make_name(name));
  14142. },
  14143. print_string: function(str) {
  14144. print(encode_string(str));
  14145. },
  14146. next_indent: next_indent,
  14147. with_indent: with_indent,
  14148. with_block: with_block,
  14149. with_parens: with_parens,
  14150. with_square: with_square,
  14151. add_mapping: add_mapping,
  14152. option: function(opt) {
  14153. return options[opt];
  14154. },
  14155. line: function() {
  14156. return current_line;
  14157. },
  14158. col: function() {
  14159. return current_col;
  14160. },
  14161. pos: function() {
  14162. return current_pos;
  14163. },
  14164. push_node: function(node) {
  14165. stack.push(node);
  14166. },
  14167. pop_node: function() {
  14168. return stack.pop();
  14169. },
  14170. stack: function() {
  14171. return stack;
  14172. },
  14173. parent: function(n) {
  14174. return stack[stack.length - 2 - (n || 0)];
  14175. }
  14176. };
  14177. }
  14178. (function() {
  14179. function DEFPRINT(nodetype, generator) {
  14180. nodetype.DEFMETHOD("_codegen", generator);
  14181. }
  14182. AST_Node.DEFMETHOD("print", function(stream, force_parens) {
  14183. var self = this, generator = self._codegen;
  14184. function doit() {
  14185. self.add_comments(stream);
  14186. self.add_source_map(stream);
  14187. generator(self, stream);
  14188. }
  14189. stream.push_node(self);
  14190. if (force_parens || self.needs_parens(stream)) {
  14191. stream.with_parens(doit);
  14192. } else {
  14193. doit();
  14194. }
  14195. stream.pop_node();
  14196. });
  14197. AST_Node.DEFMETHOD("print_to_string", function(options) {
  14198. var s = OutputStream(options);
  14199. this.print(s);
  14200. return s.get();
  14201. });
  14202. AST_Node.DEFMETHOD("add_comments", function(output) {
  14203. var c = output.option("comments"), self = this;
  14204. if (c) {
  14205. var start = self.start;
  14206. if (start && !start._comments_dumped) {
  14207. start._comments_dumped = true;
  14208. var comments = start.comments_before || [];
  14209. if (self instanceof AST_Exit && self.value) {
  14210. self.value.walk(new TreeWalker(function(node) {
  14211. if (node.start && node.start.comments_before) {
  14212. comments = comments.concat(node.start.comments_before);
  14213. node.start.comments_before = [];
  14214. }
  14215. if (node instanceof AST_Function || node instanceof AST_Array || node instanceof AST_Object) {
  14216. return true;
  14217. }
  14218. }));
  14219. }
  14220. if (c.test) {
  14221. comments = comments.filter(function(comment) {
  14222. return c.test(comment.value);
  14223. });
  14224. } else if (typeof c == "function") {
  14225. comments = comments.filter(function(comment) {
  14226. return c(self, comment);
  14227. });
  14228. }
  14229. comments.forEach(function(c) {
  14230. if (/comment[134]/.test(c.type)) {
  14231. output.print("//" + c.value + "\n");
  14232. output.indent();
  14233. } else if (c.type == "comment2") {
  14234. output.print("/*" + c.value + "*/");
  14235. if (start.nlb) {
  14236. output.print("\n");
  14237. output.indent();
  14238. } else {
  14239. output.space();
  14240. }
  14241. }
  14242. });
  14243. }
  14244. }
  14245. });
  14246. function PARENS(nodetype, func) {
  14247. if (Array.isArray(nodetype)) {
  14248. nodetype.forEach(function(nodetype) {
  14249. PARENS(nodetype, func);
  14250. });
  14251. } else {
  14252. nodetype.DEFMETHOD("needs_parens", func);
  14253. }
  14254. }
  14255. PARENS(AST_Node, function() {
  14256. return false;
  14257. });
  14258. PARENS(AST_Function, function(output) {
  14259. return first_in_statement(output);
  14260. });
  14261. PARENS(AST_Object, function(output) {
  14262. return first_in_statement(output);
  14263. });
  14264. PARENS([ AST_Unary, AST_Undefined ], function(output) {
  14265. var p = output.parent();
  14266. return p instanceof AST_PropAccess && p.expression === this;
  14267. });
  14268. PARENS(AST_Seq, function(output) {
  14269. var p = output.parent();
  14270. return p instanceof AST_Call || p instanceof AST_Unary || p instanceof AST_Binary || p instanceof AST_VarDef || p instanceof AST_PropAccess || p instanceof AST_Array || p instanceof AST_ObjectProperty || p instanceof AST_Conditional;
  14271. });
  14272. PARENS(AST_Binary, function(output) {
  14273. var p = output.parent();
  14274. if (p instanceof AST_Call && p.expression === this) return true;
  14275. if (p instanceof AST_Unary) return true;
  14276. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14277. if (p instanceof AST_Binary) {
  14278. var po = p.operator, pp = PRECEDENCE[po];
  14279. var so = this.operator, sp = PRECEDENCE[so];
  14280. if (pp > sp || pp == sp && this === p.right) {
  14281. return true;
  14282. }
  14283. }
  14284. });
  14285. PARENS(AST_PropAccess, function(output) {
  14286. var p = output.parent();
  14287. if (p instanceof AST_New && p.expression === this) {
  14288. try {
  14289. this.walk(new TreeWalker(function(node) {
  14290. if (node instanceof AST_Call) throw p;
  14291. }));
  14292. } catch (ex) {
  14293. if (ex !== p) throw ex;
  14294. return true;
  14295. }
  14296. }
  14297. });
  14298. PARENS(AST_Call, function(output) {
  14299. var p = output.parent(), p1;
  14300. if (p instanceof AST_New && p.expression === this) return true;
  14301. return this.expression instanceof AST_Function && p instanceof AST_PropAccess && p.expression === this && (p1 = output.parent(1)) instanceof AST_Assign && p1.left === p;
  14302. });
  14303. PARENS(AST_New, function(output) {
  14304. var p = output.parent();
  14305. if (no_constructor_parens(this, output) && (p instanceof AST_PropAccess || p instanceof AST_Call && p.expression === this)) return true;
  14306. });
  14307. PARENS(AST_Number, function(output) {
  14308. var p = output.parent();
  14309. if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this) return true;
  14310. });
  14311. PARENS(AST_NaN, function(output) {
  14312. var p = output.parent();
  14313. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14314. });
  14315. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  14316. var p = output.parent();
  14317. if (p instanceof AST_Unary) return true;
  14318. if (p instanceof AST_Binary && !(p instanceof AST_Assign)) return true;
  14319. if (p instanceof AST_Call && p.expression === this) return true;
  14320. if (p instanceof AST_Conditional && p.condition === this) return true;
  14321. if (p instanceof AST_PropAccess && p.expression === this) return true;
  14322. });
  14323. DEFPRINT(AST_Directive, function(self, output) {
  14324. output.print_string(self.value);
  14325. output.semicolon();
  14326. });
  14327. DEFPRINT(AST_Debugger, function(self, output) {
  14328. output.print("debugger");
  14329. output.semicolon();
  14330. });
  14331. function display_body(body, is_toplevel, output) {
  14332. var last = body.length - 1;
  14333. body.forEach(function(stmt, i) {
  14334. if (!(stmt instanceof AST_EmptyStatement)) {
  14335. output.indent();
  14336. stmt.print(output);
  14337. if (!(i == last && is_toplevel)) {
  14338. output.newline();
  14339. if (is_toplevel) output.newline();
  14340. }
  14341. }
  14342. });
  14343. }
  14344. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  14345. force_statement(this.body, output);
  14346. });
  14347. DEFPRINT(AST_Statement, function(self, output) {
  14348. self.body.print(output);
  14349. output.semicolon();
  14350. });
  14351. DEFPRINT(AST_Toplevel, function(self, output) {
  14352. display_body(self.body, true, output);
  14353. output.print("");
  14354. });
  14355. DEFPRINT(AST_LabeledStatement, function(self, output) {
  14356. self.label.print(output);
  14357. output.colon();
  14358. self.body.print(output);
  14359. });
  14360. DEFPRINT(AST_SimpleStatement, function(self, output) {
  14361. self.body.print(output);
  14362. output.semicolon();
  14363. });
  14364. function print_bracketed(body, output) {
  14365. if (body.length > 0) output.with_block(function() {
  14366. display_body(body, false, output);
  14367. }); else output.print("{}");
  14368. }
  14369. DEFPRINT(AST_BlockStatement, function(self, output) {
  14370. print_bracketed(self.body, output);
  14371. });
  14372. DEFPRINT(AST_EmptyStatement, function(self, output) {
  14373. output.semicolon();
  14374. });
  14375. DEFPRINT(AST_Do, function(self, output) {
  14376. output.print("do");
  14377. output.space();
  14378. self._do_print_body(output);
  14379. output.space();
  14380. output.print("while");
  14381. output.space();
  14382. output.with_parens(function() {
  14383. self.condition.print(output);
  14384. });
  14385. output.semicolon();
  14386. });
  14387. DEFPRINT(AST_While, function(self, output) {
  14388. output.print("while");
  14389. output.space();
  14390. output.with_parens(function() {
  14391. self.condition.print(output);
  14392. });
  14393. output.space();
  14394. self._do_print_body(output);
  14395. });
  14396. DEFPRINT(AST_For, function(self, output) {
  14397. output.print("for");
  14398. output.space();
  14399. output.with_parens(function() {
  14400. if (self.init && !(self.init instanceof AST_EmptyStatement)) {
  14401. if (self.init instanceof AST_Definitions) {
  14402. self.init.print(output);
  14403. } else {
  14404. parenthesize_for_noin(self.init, output, true);
  14405. }
  14406. output.print(";");
  14407. output.space();
  14408. } else {
  14409. output.print(";");
  14410. }
  14411. if (self.condition) {
  14412. self.condition.print(output);
  14413. output.print(";");
  14414. output.space();
  14415. } else {
  14416. output.print(";");
  14417. }
  14418. if (self.step) {
  14419. self.step.print(output);
  14420. }
  14421. });
  14422. output.space();
  14423. self._do_print_body(output);
  14424. });
  14425. DEFPRINT(AST_ForIn, function(self, output) {
  14426. output.print("for");
  14427. output.space();
  14428. output.with_parens(function() {
  14429. self.init.print(output);
  14430. output.space();
  14431. output.print("in");
  14432. output.space();
  14433. self.object.print(output);
  14434. });
  14435. output.space();
  14436. self._do_print_body(output);
  14437. });
  14438. DEFPRINT(AST_With, function(self, output) {
  14439. output.print("with");
  14440. output.space();
  14441. output.with_parens(function() {
  14442. self.expression.print(output);
  14443. });
  14444. output.space();
  14445. self._do_print_body(output);
  14446. });
  14447. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  14448. var self = this;
  14449. if (!nokeyword) {
  14450. output.print("function");
  14451. }
  14452. if (self.name) {
  14453. output.space();
  14454. self.name.print(output);
  14455. }
  14456. output.with_parens(function() {
  14457. self.argnames.forEach(function(arg, i) {
  14458. if (i) output.comma();
  14459. arg.print(output);
  14460. });
  14461. });
  14462. output.space();
  14463. print_bracketed(self.body, output);
  14464. });
  14465. DEFPRINT(AST_Lambda, function(self, output) {
  14466. self._do_print(output);
  14467. });
  14468. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  14469. output.print(kind);
  14470. if (this.value) {
  14471. output.space();
  14472. this.value.print(output);
  14473. }
  14474. output.semicolon();
  14475. });
  14476. DEFPRINT(AST_Return, function(self, output) {
  14477. self._do_print(output, "return");
  14478. });
  14479. DEFPRINT(AST_Throw, function(self, output) {
  14480. self._do_print(output, "throw");
  14481. });
  14482. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  14483. output.print(kind);
  14484. if (this.label) {
  14485. output.space();
  14486. this.label.print(output);
  14487. }
  14488. output.semicolon();
  14489. });
  14490. DEFPRINT(AST_Break, function(self, output) {
  14491. self._do_print(output, "break");
  14492. });
  14493. DEFPRINT(AST_Continue, function(self, output) {
  14494. self._do_print(output, "continue");
  14495. });
  14496. function make_then(self, output) {
  14497. if (output.option("bracketize")) {
  14498. make_block(self.body, output);
  14499. return;
  14500. }
  14501. if (!self.body) return output.force_semicolon();
  14502. if (self.body instanceof AST_Do && !output.option("screw_ie8")) {
  14503. make_block(self.body, output);
  14504. return;
  14505. }
  14506. var b = self.body;
  14507. while (true) {
  14508. if (b instanceof AST_If) {
  14509. if (!b.alternative) {
  14510. make_block(self.body, output);
  14511. return;
  14512. }
  14513. b = b.alternative;
  14514. } else if (b instanceof AST_StatementWithBody) {
  14515. b = b.body;
  14516. } else break;
  14517. }
  14518. force_statement(self.body, output);
  14519. }
  14520. DEFPRINT(AST_If, function(self, output) {
  14521. output.print("if");
  14522. output.space();
  14523. output.with_parens(function() {
  14524. self.condition.print(output);
  14525. });
  14526. output.space();
  14527. if (self.alternative) {
  14528. make_then(self, output);
  14529. output.space();
  14530. output.print("else");
  14531. output.space();
  14532. force_statement(self.alternative, output);
  14533. } else {
  14534. self._do_print_body(output);
  14535. }
  14536. });
  14537. DEFPRINT(AST_Switch, function(self, output) {
  14538. output.print("switch");
  14539. output.space();
  14540. output.with_parens(function() {
  14541. self.expression.print(output);
  14542. });
  14543. output.space();
  14544. if (self.body.length > 0) output.with_block(function() {
  14545. self.body.forEach(function(stmt, i) {
  14546. if (i) output.newline();
  14547. output.indent(true);
  14548. stmt.print(output);
  14549. });
  14550. }); else output.print("{}");
  14551. });
  14552. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  14553. if (this.body.length > 0) {
  14554. output.newline();
  14555. this.body.forEach(function(stmt) {
  14556. output.indent();
  14557. stmt.print(output);
  14558. output.newline();
  14559. });
  14560. }
  14561. });
  14562. DEFPRINT(AST_Default, function(self, output) {
  14563. output.print("default:");
  14564. self._do_print_body(output);
  14565. });
  14566. DEFPRINT(AST_Case, function(self, output) {
  14567. output.print("case");
  14568. output.space();
  14569. self.expression.print(output);
  14570. output.print(":");
  14571. self._do_print_body(output);
  14572. });
  14573. DEFPRINT(AST_Try, function(self, output) {
  14574. output.print("try");
  14575. output.space();
  14576. print_bracketed(self.body, output);
  14577. if (self.bcatch) {
  14578. output.space();
  14579. self.bcatch.print(output);
  14580. }
  14581. if (self.bfinally) {
  14582. output.space();
  14583. self.bfinally.print(output);
  14584. }
  14585. });
  14586. DEFPRINT(AST_Catch, function(self, output) {
  14587. output.print("catch");
  14588. output.space();
  14589. output.with_parens(function() {
  14590. self.argname.print(output);
  14591. });
  14592. output.space();
  14593. print_bracketed(self.body, output);
  14594. });
  14595. DEFPRINT(AST_Finally, function(self, output) {
  14596. output.print("finally");
  14597. output.space();
  14598. print_bracketed(self.body, output);
  14599. });
  14600. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  14601. output.print(kind);
  14602. output.space();
  14603. this.definitions.forEach(function(def, i) {
  14604. if (i) output.comma();
  14605. def.print(output);
  14606. });
  14607. var p = output.parent();
  14608. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  14609. var avoid_semicolon = in_for && p.init === this;
  14610. if (!avoid_semicolon) output.semicolon();
  14611. });
  14612. DEFPRINT(AST_Var, function(self, output) {
  14613. self._do_print(output, "var");
  14614. });
  14615. DEFPRINT(AST_Const, function(self, output) {
  14616. self._do_print(output, "const");
  14617. });
  14618. function parenthesize_for_noin(node, output, noin) {
  14619. if (!noin) node.print(output); else try {
  14620. node.walk(new TreeWalker(function(node) {
  14621. if (node instanceof AST_Binary && node.operator == "in") throw output;
  14622. }));
  14623. node.print(output);
  14624. } catch (ex) {
  14625. if (ex !== output) throw ex;
  14626. node.print(output, true);
  14627. }
  14628. }
  14629. DEFPRINT(AST_VarDef, function(self, output) {
  14630. self.name.print(output);
  14631. if (self.value) {
  14632. output.space();
  14633. output.print("=");
  14634. output.space();
  14635. var p = output.parent(1);
  14636. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  14637. parenthesize_for_noin(self.value, output, noin);
  14638. }
  14639. });
  14640. DEFPRINT(AST_Call, function(self, output) {
  14641. self.expression.print(output);
  14642. if (self instanceof AST_New && no_constructor_parens(self, output)) return;
  14643. output.with_parens(function() {
  14644. self.args.forEach(function(expr, i) {
  14645. if (i) output.comma();
  14646. expr.print(output);
  14647. });
  14648. });
  14649. });
  14650. DEFPRINT(AST_New, function(self, output) {
  14651. output.print("new");
  14652. output.space();
  14653. AST_Call.prototype._codegen(self, output);
  14654. });
  14655. AST_Seq.DEFMETHOD("_do_print", function(output) {
  14656. this.car.print(output);
  14657. if (this.cdr) {
  14658. output.comma();
  14659. if (output.should_break()) {
  14660. output.newline();
  14661. output.indent();
  14662. }
  14663. this.cdr.print(output);
  14664. }
  14665. });
  14666. DEFPRINT(AST_Seq, function(self, output) {
  14667. self._do_print(output);
  14668. });
  14669. DEFPRINT(AST_Dot, function(self, output) {
  14670. var expr = self.expression;
  14671. expr.print(output);
  14672. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  14673. if (!/[xa-f.]/i.test(output.last())) {
  14674. output.print(".");
  14675. }
  14676. }
  14677. output.print(".");
  14678. output.add_mapping(self.end);
  14679. output.print_name(self.property);
  14680. });
  14681. DEFPRINT(AST_Sub, function(self, output) {
  14682. self.expression.print(output);
  14683. output.print("[");
  14684. self.property.print(output);
  14685. output.print("]");
  14686. });
  14687. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  14688. var op = self.operator;
  14689. output.print(op);
  14690. if (/^[a-z]/i.test(op) || /[+-]$/.test(op) && self.expression instanceof AST_UnaryPrefix && /^[+-]/.test(self.expression.operator)) {
  14691. output.space();
  14692. }
  14693. self.expression.print(output);
  14694. });
  14695. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  14696. self.expression.print(output);
  14697. output.print(self.operator);
  14698. });
  14699. DEFPRINT(AST_Binary, function(self, output) {
  14700. self.left.print(output);
  14701. output.space();
  14702. output.print(self.operator);
  14703. if (self.operator == "<" && self.right instanceof AST_UnaryPrefix && self.right.operator == "!" && self.right.expression instanceof AST_UnaryPrefix && self.right.expression.operator == "--") {
  14704. output.print(" ");
  14705. } else {
  14706. output.space();
  14707. }
  14708. self.right.print(output);
  14709. });
  14710. DEFPRINT(AST_Conditional, function(self, output) {
  14711. self.condition.print(output);
  14712. output.space();
  14713. output.print("?");
  14714. output.space();
  14715. self.consequent.print(output);
  14716. output.space();
  14717. output.colon();
  14718. self.alternative.print(output);
  14719. });
  14720. DEFPRINT(AST_Array, function(self, output) {
  14721. output.with_square(function() {
  14722. var a = self.elements, len = a.length;
  14723. if (len > 0) output.space();
  14724. a.forEach(function(exp, i) {
  14725. if (i) output.comma();
  14726. exp.print(output);
  14727. if (i === len - 1 && exp instanceof AST_Hole) output.comma();
  14728. });
  14729. if (len > 0) output.space();
  14730. });
  14731. });
  14732. DEFPRINT(AST_Object, function(self, output) {
  14733. if (self.properties.length > 0) output.with_block(function() {
  14734. self.properties.forEach(function(prop, i) {
  14735. if (i) {
  14736. output.print(",");
  14737. output.newline();
  14738. }
  14739. output.indent();
  14740. prop.print(output);
  14741. });
  14742. output.newline();
  14743. }); else output.print("{}");
  14744. });
  14745. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  14746. var key = self.key;
  14747. if (output.option("quote_keys")) {
  14748. output.print_string(key + "");
  14749. } else if ((typeof key == "number" || !output.option("beautify") && +key + "" == key) && parseFloat(key) >= 0) {
  14750. output.print(make_num(key));
  14751. } else if (RESERVED_WORDS(key) ? output.option("screw_ie8") : is_identifier_string(key)) {
  14752. output.print_name(key);
  14753. } else {
  14754. output.print_string(key);
  14755. }
  14756. output.colon();
  14757. self.value.print(output);
  14758. });
  14759. DEFPRINT(AST_ObjectSetter, function(self, output) {
  14760. output.print("set");
  14761. output.space();
  14762. self.key.print(output);
  14763. self.value._do_print(output, true);
  14764. });
  14765. DEFPRINT(AST_ObjectGetter, function(self, output) {
  14766. output.print("get");
  14767. output.space();
  14768. self.key.print(output);
  14769. self.value._do_print(output, true);
  14770. });
  14771. DEFPRINT(AST_Symbol, function(self, output) {
  14772. var def = self.definition();
  14773. output.print_name(def ? def.mangled_name || def.name : self.name);
  14774. });
  14775. DEFPRINT(AST_Undefined, function(self, output) {
  14776. output.print("void 0");
  14777. });
  14778. DEFPRINT(AST_Hole, noop);
  14779. DEFPRINT(AST_Infinity, function(self, output) {
  14780. output.print("1/0");
  14781. });
  14782. DEFPRINT(AST_NaN, function(self, output) {
  14783. output.print("0/0");
  14784. });
  14785. DEFPRINT(AST_This, function(self, output) {
  14786. output.print("this");
  14787. });
  14788. DEFPRINT(AST_Constant, function(self, output) {
  14789. output.print(self.getValue());
  14790. });
  14791. DEFPRINT(AST_String, function(self, output) {
  14792. output.print_string(self.getValue());
  14793. });
  14794. DEFPRINT(AST_Number, function(self, output) {
  14795. output.print(make_num(self.getValue()));
  14796. });
  14797. function regexp_safe_literal(code) {
  14798. return [ 92, 47, 46, 43, 42, 63, 40, 41, 91, 93, 123, 125, 36, 94, 58, 124, 33, 10, 13, 0, 65279, 8232, 8233 ].indexOf(code) < 0;
  14799. }
  14800. DEFPRINT(AST_RegExp, function(self, output) {
  14801. var str = self.getValue().toString();
  14802. if (output.option("ascii_only")) {
  14803. str = output.to_ascii(str);
  14804. } else if (output.option("unescape_regexps")) {
  14805. str = str.split("\\\\").map(function(str) {
  14806. return str.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g, function(s) {
  14807. var code = parseInt(s.substr(2), 16);
  14808. return regexp_safe_literal(code) ? String.fromCharCode(code) : s;
  14809. });
  14810. }).join("\\\\");
  14811. }
  14812. output.print(str);
  14813. var p = output.parent();
  14814. if (p instanceof AST_Binary && /^in/.test(p.operator) && p.left === self) output.print(" ");
  14815. });
  14816. function force_statement(stat, output) {
  14817. if (output.option("bracketize")) {
  14818. if (!stat || stat instanceof AST_EmptyStatement) output.print("{}"); else if (stat instanceof AST_BlockStatement) stat.print(output); else output.with_block(function() {
  14819. output.indent();
  14820. stat.print(output);
  14821. output.newline();
  14822. });
  14823. } else {
  14824. if (!stat || stat instanceof AST_EmptyStatement) output.force_semicolon(); else stat.print(output);
  14825. }
  14826. }
  14827. function first_in_statement(output) {
  14828. var a = output.stack(), i = a.length, node = a[--i], p = a[--i];
  14829. while (i > 0) {
  14830. if (p instanceof AST_Statement && p.body === node) return true;
  14831. if (p instanceof AST_Seq && p.car === node || p instanceof AST_Call && p.expression === node && !(p instanceof AST_New) || p instanceof AST_Dot && p.expression === node || p instanceof AST_Sub && p.expression === node || p instanceof AST_Conditional && p.condition === node || p instanceof AST_Binary && p.left === node || p instanceof AST_UnaryPostfix && p.expression === node) {
  14832. node = p;
  14833. p = a[--i];
  14834. } else {
  14835. return false;
  14836. }
  14837. }
  14838. }
  14839. function no_constructor_parens(self, output) {
  14840. return self.args.length == 0 && !output.option("beautify");
  14841. }
  14842. function best_of(a) {
  14843. var best = a[0], len = best.length;
  14844. for (var i = 1; i < a.length; ++i) {
  14845. if (a[i].length < len) {
  14846. best = a[i];
  14847. len = best.length;
  14848. }
  14849. }
  14850. return best;
  14851. }
  14852. function make_num(num) {
  14853. var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace("e+", "e") ], m;
  14854. if (Math.floor(num) === num) {
  14855. if (num >= 0) {
  14856. a.push("0x" + num.toString(16).toLowerCase(), "0" + num.toString(8));
  14857. } else {
  14858. a.push("-0x" + (-num).toString(16).toLowerCase(), "-0" + (-num).toString(8));
  14859. }
  14860. if (m = /^(.*?)(0+)$/.exec(num)) {
  14861. a.push(m[1] + "e" + m[2].length);
  14862. }
  14863. } else if (m = /^0?\.(0+)(.*)$/.exec(num)) {
  14864. a.push(m[2] + "e-" + (m[1].length + m[2].length), str.substr(str.indexOf(".")));
  14865. }
  14866. return best_of(a);
  14867. }
  14868. function make_block(stmt, output) {
  14869. if (stmt instanceof AST_BlockStatement) {
  14870. stmt.print(output);
  14871. return;
  14872. }
  14873. output.with_block(function() {
  14874. output.indent();
  14875. stmt.print(output);
  14876. output.newline();
  14877. });
  14878. }
  14879. function DEFMAP(nodetype, generator) {
  14880. nodetype.DEFMETHOD("add_source_map", function(stream) {
  14881. generator(this, stream);
  14882. });
  14883. }
  14884. DEFMAP(AST_Node, noop);
  14885. function basic_sourcemap_gen(self, output) {
  14886. output.add_mapping(self.start);
  14887. }
  14888. DEFMAP(AST_Directive, basic_sourcemap_gen);
  14889. DEFMAP(AST_Debugger, basic_sourcemap_gen);
  14890. DEFMAP(AST_Symbol, basic_sourcemap_gen);
  14891. DEFMAP(AST_Jump, basic_sourcemap_gen);
  14892. DEFMAP(AST_StatementWithBody, basic_sourcemap_gen);
  14893. DEFMAP(AST_LabeledStatement, noop);
  14894. DEFMAP(AST_Lambda, basic_sourcemap_gen);
  14895. DEFMAP(AST_Switch, basic_sourcemap_gen);
  14896. DEFMAP(AST_SwitchBranch, basic_sourcemap_gen);
  14897. DEFMAP(AST_BlockStatement, basic_sourcemap_gen);
  14898. DEFMAP(AST_Toplevel, noop);
  14899. DEFMAP(AST_New, basic_sourcemap_gen);
  14900. DEFMAP(AST_Try, basic_sourcemap_gen);
  14901. DEFMAP(AST_Catch, basic_sourcemap_gen);
  14902. DEFMAP(AST_Finally, basic_sourcemap_gen);
  14903. DEFMAP(AST_Definitions, basic_sourcemap_gen);
  14904. DEFMAP(AST_Constant, basic_sourcemap_gen);
  14905. DEFMAP(AST_ObjectProperty, function(self, output) {
  14906. output.add_mapping(self.start, self.key);
  14907. });
  14908. })();
  14909. "use strict";
  14910. function Compressor(options, false_by_default) {
  14911. if (!(this instanceof Compressor)) return new Compressor(options, false_by_default);
  14912. TreeTransformer.call(this, this.before, this.after);
  14913. this.options = defaults(options, {
  14914. sequences: !false_by_default,
  14915. properties: !false_by_default,
  14916. dead_code: !false_by_default,
  14917. drop_debugger: !false_by_default,
  14918. unsafe: false,
  14919. unsafe_comps: false,
  14920. conditionals: !false_by_default,
  14921. comparisons: !false_by_default,
  14922. evaluate: !false_by_default,
  14923. booleans: !false_by_default,
  14924. loops: !false_by_default,
  14925. unused: !false_by_default,
  14926. hoist_funs: !false_by_default,
  14927. keep_fargs: false,
  14928. hoist_vars: false,
  14929. if_return: !false_by_default,
  14930. join_vars: !false_by_default,
  14931. cascade: !false_by_default,
  14932. side_effects: !false_by_default,
  14933. pure_getters: false,
  14934. pure_funcs: null,
  14935. negate_iife: !false_by_default,
  14936. screw_ie8: false,
  14937. drop_console: false,
  14938. angular: false,
  14939. warnings: true,
  14940. global_defs: {}
  14941. }, true);
  14942. }
  14943. Compressor.prototype = new TreeTransformer();
  14944. merge(Compressor.prototype, {
  14945. option: function(key) {
  14946. return this.options[key];
  14947. },
  14948. warn: function() {
  14949. if (this.options.warnings) AST_Node.warn.apply(AST_Node, arguments);
  14950. },
  14951. before: function(node, descend, in_list) {
  14952. if (node._squeezed) return node;
  14953. var was_scope = false;
  14954. if (node instanceof AST_Scope) {
  14955. node = node.hoist_declarations(this);
  14956. was_scope = true;
  14957. }
  14958. descend(node, this);
  14959. node = node.optimize(this);
  14960. if (was_scope && node instanceof AST_Scope) {
  14961. node.drop_unused(this);
  14962. descend(node, this);
  14963. }
  14964. node._squeezed = true;
  14965. return node;
  14966. }
  14967. });
  14968. (function() {
  14969. function OPT(node, optimizer) {
  14970. node.DEFMETHOD("optimize", function(compressor) {
  14971. var self = this;
  14972. if (self._optimized) return self;
  14973. var opt = optimizer(self, compressor);
  14974. opt._optimized = true;
  14975. if (opt === self) return opt;
  14976. return opt.transform(compressor);
  14977. });
  14978. }
  14979. OPT(AST_Node, function(self, compressor) {
  14980. return self;
  14981. });
  14982. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  14983. return this.print_to_string() == node.print_to_string();
  14984. });
  14985. function make_node(ctor, orig, props) {
  14986. if (!props) props = {};
  14987. if (orig) {
  14988. if (!props.start) props.start = orig.start;
  14989. if (!props.end) props.end = orig.end;
  14990. }
  14991. return new ctor(props);
  14992. }
  14993. function make_node_from_constant(compressor, val, orig) {
  14994. if (val instanceof AST_Node) return val.transform(compressor);
  14995. switch (typeof val) {
  14996. case "string":
  14997. return make_node(AST_String, orig, {
  14998. value: val
  14999. }).optimize(compressor);
  15000. case "number":
  15001. return make_node(isNaN(val) ? AST_NaN : AST_Number, orig, {
  15002. value: val
  15003. }).optimize(compressor);
  15004. case "boolean":
  15005. return make_node(val ? AST_True : AST_False, orig).optimize(compressor);
  15006. case "undefined":
  15007. return make_node(AST_Undefined, orig).optimize(compressor);
  15008. default:
  15009. if (val === null) {
  15010. return make_node(AST_Null, orig).optimize(compressor);
  15011. }
  15012. if (val instanceof RegExp) {
  15013. return make_node(AST_RegExp, orig).optimize(compressor);
  15014. }
  15015. throw new Error(string_template("Can't handle constant of type: {type}", {
  15016. type: typeof val
  15017. }));
  15018. }
  15019. }
  15020. function as_statement_array(thing) {
  15021. if (thing === null) return [];
  15022. if (thing instanceof AST_BlockStatement) return thing.body;
  15023. if (thing instanceof AST_EmptyStatement) return [];
  15024. if (thing instanceof AST_Statement) return [ thing ];
  15025. throw new Error("Can't convert thing to statement array");
  15026. }
  15027. function is_empty(thing) {
  15028. if (thing === null) return true;
  15029. if (thing instanceof AST_EmptyStatement) return true;
  15030. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  15031. return false;
  15032. }
  15033. function loop_body(x) {
  15034. if (x instanceof AST_Switch) return x;
  15035. if (x instanceof AST_For || x instanceof AST_ForIn || x instanceof AST_DWLoop) {
  15036. return x.body instanceof AST_BlockStatement ? x.body : x;
  15037. }
  15038. return x;
  15039. }
  15040. function tighten_body(statements, compressor) {
  15041. var CHANGED;
  15042. do {
  15043. CHANGED = false;
  15044. if (compressor.option("angular")) {
  15045. statements = process_for_angular(statements);
  15046. }
  15047. statements = eliminate_spurious_blocks(statements);
  15048. if (compressor.option("dead_code")) {
  15049. statements = eliminate_dead_code(statements, compressor);
  15050. }
  15051. if (compressor.option("if_return")) {
  15052. statements = handle_if_return(statements, compressor);
  15053. }
  15054. if (compressor.option("sequences")) {
  15055. statements = sequencesize(statements, compressor);
  15056. }
  15057. if (compressor.option("join_vars")) {
  15058. statements = join_consecutive_vars(statements, compressor);
  15059. }
  15060. } while (CHANGED);
  15061. if (compressor.option("negate_iife")) {
  15062. negate_iifes(statements, compressor);
  15063. }
  15064. return statements;
  15065. function process_for_angular(statements) {
  15066. function make_injector(func, name) {
  15067. return make_node(AST_SimpleStatement, func, {
  15068. body: make_node(AST_Assign, func, {
  15069. operator: "=",
  15070. left: make_node(AST_Dot, name, {
  15071. expression: make_node(AST_SymbolRef, name, name),
  15072. property: "$inject"
  15073. }),
  15074. right: make_node(AST_Array, func, {
  15075. elements: func.argnames.map(function(sym) {
  15076. return make_node(AST_String, sym, {
  15077. value: sym.name
  15078. });
  15079. })
  15080. })
  15081. })
  15082. });
  15083. }
  15084. return statements.reduce(function(a, stat) {
  15085. a.push(stat);
  15086. var token = stat.start;
  15087. var comments = token.comments_before;
  15088. if (comments && comments.length > 0) {
  15089. var last = comments.pop();
  15090. if (/@ngInject/.test(last.value)) {
  15091. if (stat instanceof AST_Defun) {
  15092. a.push(make_injector(stat, stat.name));
  15093. } else if (stat instanceof AST_Definitions) {
  15094. stat.definitions.forEach(function(def) {
  15095. if (def.value && def.value instanceof AST_Lambda) {
  15096. a.push(make_injector(def.value, def.name));
  15097. }
  15098. });
  15099. } else {
  15100. compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
  15101. }
  15102. }
  15103. }
  15104. return a;
  15105. }, []);
  15106. }
  15107. function eliminate_spurious_blocks(statements) {
  15108. var seen_dirs = [];
  15109. return statements.reduce(function(a, stat) {
  15110. if (stat instanceof AST_BlockStatement) {
  15111. CHANGED = true;
  15112. a.push.apply(a, eliminate_spurious_blocks(stat.body));
  15113. } else if (stat instanceof AST_EmptyStatement) {
  15114. CHANGED = true;
  15115. } else if (stat instanceof AST_Directive) {
  15116. if (seen_dirs.indexOf(stat.value) < 0) {
  15117. a.push(stat);
  15118. seen_dirs.push(stat.value);
  15119. } else {
  15120. CHANGED = true;
  15121. }
  15122. } else {
  15123. a.push(stat);
  15124. }
  15125. return a;
  15126. }, []);
  15127. }
  15128. function handle_if_return(statements, compressor) {
  15129. var self = compressor.self();
  15130. var in_lambda = self instanceof AST_Lambda;
  15131. var ret = [];
  15132. loop: for (var i = statements.length; --i >= 0; ) {
  15133. var stat = statements[i];
  15134. switch (true) {
  15135. case in_lambda && stat instanceof AST_Return && !stat.value && ret.length == 0:
  15136. CHANGED = true;
  15137. continue loop;
  15138. case stat instanceof AST_If:
  15139. if (stat.body instanceof AST_Return) {
  15140. if ((in_lambda && ret.length == 0 || ret[0] instanceof AST_Return && !ret[0].value) && !stat.body.value && !stat.alternative) {
  15141. CHANGED = true;
  15142. var cond = make_node(AST_SimpleStatement, stat.condition, {
  15143. body: stat.condition
  15144. });
  15145. ret.unshift(cond);
  15146. continue loop;
  15147. }
  15148. if (ret[0] instanceof AST_Return && stat.body.value && ret[0].value && !stat.alternative) {
  15149. CHANGED = true;
  15150. stat = stat.clone();
  15151. stat.alternative = ret[0];
  15152. ret[0] = stat.transform(compressor);
  15153. continue loop;
  15154. }
  15155. if ((ret.length == 0 || ret[0] instanceof AST_Return) && stat.body.value && !stat.alternative && in_lambda) {
  15156. CHANGED = true;
  15157. stat = stat.clone();
  15158. stat.alternative = ret[0] || make_node(AST_Return, stat, {
  15159. value: make_node(AST_Undefined, stat)
  15160. });
  15161. ret[0] = stat.transform(compressor);
  15162. continue loop;
  15163. }
  15164. if (!stat.body.value && in_lambda) {
  15165. CHANGED = true;
  15166. stat = stat.clone();
  15167. stat.condition = stat.condition.negate(compressor);
  15168. stat.body = make_node(AST_BlockStatement, stat, {
  15169. body: as_statement_array(stat.alternative).concat(ret)
  15170. });
  15171. stat.alternative = null;
  15172. ret = [ stat.transform(compressor) ];
  15173. continue loop;
  15174. }
  15175. if (ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement && (!stat.alternative || stat.alternative instanceof AST_SimpleStatement)) {
  15176. CHANGED = true;
  15177. ret.push(make_node(AST_Return, ret[0], {
  15178. value: make_node(AST_Undefined, ret[0])
  15179. }).transform(compressor));
  15180. ret = as_statement_array(stat.alternative).concat(ret);
  15181. ret.unshift(stat);
  15182. continue loop;
  15183. }
  15184. }
  15185. var ab = aborts(stat.body);
  15186. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab.label) : null;
  15187. if (ab && (ab instanceof AST_Return && !ab.value && in_lambda || ab instanceof AST_Continue && self === loop_body(lct) || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct)) {
  15188. if (ab.label) {
  15189. remove(ab.label.thedef.references, ab);
  15190. }
  15191. CHANGED = true;
  15192. var body = as_statement_array(stat.body).slice(0, -1);
  15193. stat = stat.clone();
  15194. stat.condition = stat.condition.negate(compressor);
  15195. stat.body = make_node(AST_BlockStatement, stat, {
  15196. body: as_statement_array(stat.alternative).concat(ret)
  15197. });
  15198. stat.alternative = make_node(AST_BlockStatement, stat, {
  15199. body: body
  15200. });
  15201. ret = [ stat.transform(compressor) ];
  15202. continue loop;
  15203. }
  15204. var ab = aborts(stat.alternative);
  15205. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab.label) : null;
  15206. if (ab && (ab instanceof AST_Return && !ab.value && in_lambda || ab instanceof AST_Continue && self === loop_body(lct) || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct)) {
  15207. if (ab.label) {
  15208. remove(ab.label.thedef.references, ab);
  15209. }
  15210. CHANGED = true;
  15211. stat = stat.clone();
  15212. stat.body = make_node(AST_BlockStatement, stat.body, {
  15213. body: as_statement_array(stat.body).concat(ret)
  15214. });
  15215. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  15216. body: as_statement_array(stat.alternative).slice(0, -1)
  15217. });
  15218. ret = [ stat.transform(compressor) ];
  15219. continue loop;
  15220. }
  15221. ret.unshift(stat);
  15222. break;
  15223. default:
  15224. ret.unshift(stat);
  15225. break;
  15226. }
  15227. }
  15228. return ret;
  15229. }
  15230. function eliminate_dead_code(statements, compressor) {
  15231. var has_quit = false;
  15232. var orig = statements.length;
  15233. var self = compressor.self();
  15234. statements = statements.reduce(function(a, stat) {
  15235. if (has_quit) {
  15236. extract_declarations_from_unreachable_code(compressor, stat, a);
  15237. } else {
  15238. if (stat instanceof AST_LoopControl) {
  15239. var lct = compressor.loopcontrol_target(stat.label);
  15240. if (stat instanceof AST_Break && lct instanceof AST_BlockStatement && loop_body(lct) === self || stat instanceof AST_Continue && loop_body(lct) === self) {
  15241. if (stat.label) {
  15242. remove(stat.label.thedef.references, stat);
  15243. }
  15244. } else {
  15245. a.push(stat);
  15246. }
  15247. } else {
  15248. a.push(stat);
  15249. }
  15250. if (aborts(stat)) has_quit = true;
  15251. }
  15252. return a;
  15253. }, []);
  15254. CHANGED = statements.length != orig;
  15255. return statements;
  15256. }
  15257. function sequencesize(statements, compressor) {
  15258. if (statements.length < 2) return statements;
  15259. var seq = [], ret = [];
  15260. function push_seq() {
  15261. seq = AST_Seq.from_array(seq);
  15262. if (seq) ret.push(make_node(AST_SimpleStatement, seq, {
  15263. body: seq
  15264. }));
  15265. seq = [];
  15266. }
  15267. statements.forEach(function(stat) {
  15268. if (stat instanceof AST_SimpleStatement) seq.push(stat.body); else push_seq(), ret.push(stat);
  15269. });
  15270. push_seq();
  15271. ret = sequencesize_2(ret, compressor);
  15272. CHANGED = ret.length != statements.length;
  15273. return ret;
  15274. }
  15275. function sequencesize_2(statements, compressor) {
  15276. function cons_seq(right) {
  15277. ret.pop();
  15278. var left = prev.body;
  15279. if (left instanceof AST_Seq) {
  15280. left.add(right);
  15281. } else {
  15282. left = AST_Seq.cons(left, right);
  15283. }
  15284. return left.transform(compressor);
  15285. }
  15286. var ret = [], prev = null;
  15287. statements.forEach(function(stat) {
  15288. if (prev) {
  15289. if (stat instanceof AST_For) {
  15290. var opera = {};
  15291. try {
  15292. prev.body.walk(new TreeWalker(function(node) {
  15293. if (node instanceof AST_Binary && node.operator == "in") throw opera;
  15294. }));
  15295. if (stat.init && !(stat.init instanceof AST_Definitions)) {
  15296. stat.init = cons_seq(stat.init);
  15297. } else if (!stat.init) {
  15298. stat.init = prev.body;
  15299. ret.pop();
  15300. }
  15301. } catch (ex) {
  15302. if (ex !== opera) throw ex;
  15303. }
  15304. } else if (stat instanceof AST_If) {
  15305. stat.condition = cons_seq(stat.condition);
  15306. } else if (stat instanceof AST_With) {
  15307. stat.expression = cons_seq(stat.expression);
  15308. } else if (stat instanceof AST_Exit && stat.value) {
  15309. stat.value = cons_seq(stat.value);
  15310. } else if (stat instanceof AST_Exit) {
  15311. stat.value = cons_seq(make_node(AST_Undefined, stat));
  15312. } else if (stat instanceof AST_Switch) {
  15313. stat.expression = cons_seq(stat.expression);
  15314. }
  15315. }
  15316. ret.push(stat);
  15317. prev = stat instanceof AST_SimpleStatement ? stat : null;
  15318. });
  15319. return ret;
  15320. }
  15321. function join_consecutive_vars(statements, compressor) {
  15322. var prev = null;
  15323. return statements.reduce(function(a, stat) {
  15324. if (stat instanceof AST_Definitions && prev && prev.TYPE == stat.TYPE) {
  15325. prev.definitions = prev.definitions.concat(stat.definitions);
  15326. CHANGED = true;
  15327. } else if (stat instanceof AST_For && prev instanceof AST_Definitions && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  15328. CHANGED = true;
  15329. a.pop();
  15330. if (stat.init) {
  15331. stat.init.definitions = prev.definitions.concat(stat.init.definitions);
  15332. } else {
  15333. stat.init = prev;
  15334. }
  15335. a.push(stat);
  15336. prev = stat;
  15337. } else {
  15338. prev = stat;
  15339. a.push(stat);
  15340. }
  15341. return a;
  15342. }, []);
  15343. }
  15344. function negate_iifes(statements, compressor) {
  15345. statements.forEach(function(stat) {
  15346. if (stat instanceof AST_SimpleStatement) {
  15347. stat.body = function transform(thing) {
  15348. return thing.transform(new TreeTransformer(function(node) {
  15349. if (node instanceof AST_Call && node.expression instanceof AST_Function) {
  15350. return make_node(AST_UnaryPrefix, node, {
  15351. operator: "!",
  15352. expression: node
  15353. });
  15354. } else if (node instanceof AST_Call) {
  15355. node.expression = transform(node.expression);
  15356. } else if (node instanceof AST_Seq) {
  15357. node.car = transform(node.car);
  15358. } else if (node instanceof AST_Conditional) {
  15359. var expr = transform(node.condition);
  15360. if (expr !== node.condition) {
  15361. node.condition = expr;
  15362. var tmp = node.consequent;
  15363. node.consequent = node.alternative;
  15364. node.alternative = tmp;
  15365. }
  15366. }
  15367. return node;
  15368. }));
  15369. }(stat.body);
  15370. }
  15371. });
  15372. }
  15373. }
  15374. function extract_declarations_from_unreachable_code(compressor, stat, target) {
  15375. compressor.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start);
  15376. stat.walk(new TreeWalker(function(node) {
  15377. if (node instanceof AST_Definitions) {
  15378. compressor.warn("Declarations in unreachable code! [{file}:{line},{col}]", node.start);
  15379. node.remove_initializers();
  15380. target.push(node);
  15381. return true;
  15382. }
  15383. if (node instanceof AST_Defun) {
  15384. target.push(node);
  15385. return true;
  15386. }
  15387. if (node instanceof AST_Scope) {
  15388. return true;
  15389. }
  15390. }));
  15391. }
  15392. (function(def) {
  15393. var unary_bool = [ "!", "delete" ];
  15394. var binary_bool = [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ];
  15395. def(AST_Node, function() {
  15396. return false;
  15397. });
  15398. def(AST_UnaryPrefix, function() {
  15399. return member(this.operator, unary_bool);
  15400. });
  15401. def(AST_Binary, function() {
  15402. return member(this.operator, binary_bool) || (this.operator == "&&" || this.operator == "||") && this.left.is_boolean() && this.right.is_boolean();
  15403. });
  15404. def(AST_Conditional, function() {
  15405. return this.consequent.is_boolean() && this.alternative.is_boolean();
  15406. });
  15407. def(AST_Assign, function() {
  15408. return this.operator == "=" && this.right.is_boolean();
  15409. });
  15410. def(AST_Seq, function() {
  15411. return this.cdr.is_boolean();
  15412. });
  15413. def(AST_True, function() {
  15414. return true;
  15415. });
  15416. def(AST_False, function() {
  15417. return true;
  15418. });
  15419. })(function(node, func) {
  15420. node.DEFMETHOD("is_boolean", func);
  15421. });
  15422. (function(def) {
  15423. def(AST_Node, function() {
  15424. return false;
  15425. });
  15426. def(AST_String, function() {
  15427. return true;
  15428. });
  15429. def(AST_UnaryPrefix, function() {
  15430. return this.operator == "typeof";
  15431. });
  15432. def(AST_Binary, function(compressor) {
  15433. return this.operator == "+" && (this.left.is_string(compressor) || this.right.is_string(compressor));
  15434. });
  15435. def(AST_Assign, function(compressor) {
  15436. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  15437. });
  15438. def(AST_Seq, function(compressor) {
  15439. return this.cdr.is_string(compressor);
  15440. });
  15441. def(AST_Conditional, function(compressor) {
  15442. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  15443. });
  15444. def(AST_Call, function(compressor) {
  15445. return compressor.option("unsafe") && this.expression instanceof AST_SymbolRef && this.expression.name == "String" && this.expression.undeclared();
  15446. });
  15447. })(function(node, func) {
  15448. node.DEFMETHOD("is_string", func);
  15449. });
  15450. function best_of(ast1, ast2) {
  15451. return ast1.print_to_string().length > ast2.print_to_string().length ? ast2 : ast1;
  15452. }
  15453. (function(def) {
  15454. AST_Node.DEFMETHOD("evaluate", function(compressor) {
  15455. if (!compressor.option("evaluate")) return [ this ];
  15456. try {
  15457. var val = this._eval(compressor);
  15458. return [ best_of(make_node_from_constant(compressor, val, this), this), val ];
  15459. } catch (ex) {
  15460. if (ex !== def) throw ex;
  15461. return [ this ];
  15462. }
  15463. });
  15464. def(AST_Statement, function() {
  15465. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  15466. });
  15467. def(AST_Function, function() {
  15468. throw def;
  15469. });
  15470. function ev(node, compressor) {
  15471. if (!compressor) throw new Error("Compressor must be passed");
  15472. return node._eval(compressor);
  15473. }
  15474. def(AST_Node, function() {
  15475. throw def;
  15476. });
  15477. def(AST_Constant, function() {
  15478. return this.getValue();
  15479. });
  15480. def(AST_UnaryPrefix, function(compressor) {
  15481. var e = this.expression;
  15482. switch (this.operator) {
  15483. case "!":
  15484. return !ev(e, compressor);
  15485. case "typeof":
  15486. if (e instanceof AST_Function) return typeof function() {};
  15487. e = ev(e, compressor);
  15488. if (e instanceof RegExp) throw def;
  15489. return typeof e;
  15490. case "void":
  15491. return void ev(e, compressor);
  15492. case "~":
  15493. return ~ev(e, compressor);
  15494. case "-":
  15495. e = ev(e, compressor);
  15496. if (e === 0) throw def;
  15497. return -e;
  15498. case "+":
  15499. return +ev(e, compressor);
  15500. }
  15501. throw def;
  15502. });
  15503. def(AST_Binary, function(c) {
  15504. var left = this.left, right = this.right;
  15505. switch (this.operator) {
  15506. case "&&":
  15507. return ev(left, c) && ev(right, c);
  15508. case "||":
  15509. return ev(left, c) || ev(right, c);
  15510. case "|":
  15511. return ev(left, c) | ev(right, c);
  15512. case "&":
  15513. return ev(left, c) & ev(right, c);
  15514. case "^":
  15515. return ev(left, c) ^ ev(right, c);
  15516. case "+":
  15517. return ev(left, c) + ev(right, c);
  15518. case "*":
  15519. return ev(left, c) * ev(right, c);
  15520. case "/":
  15521. return ev(left, c) / ev(right, c);
  15522. case "%":
  15523. return ev(left, c) % ev(right, c);
  15524. case "-":
  15525. return ev(left, c) - ev(right, c);
  15526. case "<<":
  15527. return ev(left, c) << ev(right, c);
  15528. case ">>":
  15529. return ev(left, c) >> ev(right, c);
  15530. case ">>>":
  15531. return ev(left, c) >>> ev(right, c);
  15532. case "==":
  15533. return ev(left, c) == ev(right, c);
  15534. case "===":
  15535. return ev(left, c) === ev(right, c);
  15536. case "!=":
  15537. return ev(left, c) != ev(right, c);
  15538. case "!==":
  15539. return ev(left, c) !== ev(right, c);
  15540. case "<":
  15541. return ev(left, c) < ev(right, c);
  15542. case "<=":
  15543. return ev(left, c) <= ev(right, c);
  15544. case ">":
  15545. return ev(left, c) > ev(right, c);
  15546. case ">=":
  15547. return ev(left, c) >= ev(right, c);
  15548. case "in":
  15549. return ev(left, c) in ev(right, c);
  15550. case "instanceof":
  15551. return ev(left, c) instanceof ev(right, c);
  15552. }
  15553. throw def;
  15554. });
  15555. def(AST_Conditional, function(compressor) {
  15556. return ev(this.condition, compressor) ? ev(this.consequent, compressor) : ev(this.alternative, compressor);
  15557. });
  15558. def(AST_SymbolRef, function(compressor) {
  15559. var d = this.definition();
  15560. if (d && d.constant && d.init) return ev(d.init, compressor);
  15561. throw def;
  15562. });
  15563. def(AST_Dot, function(compressor) {
  15564. if (compressor.option("unsafe") && this.property == "length") {
  15565. var str = ev(this.expression, compressor);
  15566. if (typeof str == "string") return str.length;
  15567. }
  15568. throw def;
  15569. });
  15570. })(function(node, func) {
  15571. node.DEFMETHOD("_eval", func);
  15572. });
  15573. (function(def) {
  15574. function basic_negation(exp) {
  15575. return make_node(AST_UnaryPrefix, exp, {
  15576. operator: "!",
  15577. expression: exp
  15578. });
  15579. }
  15580. def(AST_Node, function() {
  15581. return basic_negation(this);
  15582. });
  15583. def(AST_Statement, function() {
  15584. throw new Error("Cannot negate a statement");
  15585. });
  15586. def(AST_Function, function() {
  15587. return basic_negation(this);
  15588. });
  15589. def(AST_UnaryPrefix, function() {
  15590. if (this.operator == "!") return this.expression;
  15591. return basic_negation(this);
  15592. });
  15593. def(AST_Seq, function(compressor) {
  15594. var self = this.clone();
  15595. self.cdr = self.cdr.negate(compressor);
  15596. return self;
  15597. });
  15598. def(AST_Conditional, function(compressor) {
  15599. var self = this.clone();
  15600. self.consequent = self.consequent.negate(compressor);
  15601. self.alternative = self.alternative.negate(compressor);
  15602. return best_of(basic_negation(this), self);
  15603. });
  15604. def(AST_Binary, function(compressor) {
  15605. var self = this.clone(), op = this.operator;
  15606. if (compressor.option("unsafe_comps")) {
  15607. switch (op) {
  15608. case "<=":
  15609. self.operator = ">";
  15610. return self;
  15611. case "<":
  15612. self.operator = ">=";
  15613. return self;
  15614. case ">=":
  15615. self.operator = "<";
  15616. return self;
  15617. case ">":
  15618. self.operator = "<=";
  15619. return self;
  15620. }
  15621. }
  15622. switch (op) {
  15623. case "==":
  15624. self.operator = "!=";
  15625. return self;
  15626. case "!=":
  15627. self.operator = "==";
  15628. return self;
  15629. case "===":
  15630. self.operator = "!==";
  15631. return self;
  15632. case "!==":
  15633. self.operator = "===";
  15634. return self;
  15635. case "&&":
  15636. self.operator = "||";
  15637. self.left = self.left.negate(compressor);
  15638. self.right = self.right.negate(compressor);
  15639. return best_of(basic_negation(this), self);
  15640. case "||":
  15641. self.operator = "&&";
  15642. self.left = self.left.negate(compressor);
  15643. self.right = self.right.negate(compressor);
  15644. return best_of(basic_negation(this), self);
  15645. }
  15646. return basic_negation(this);
  15647. });
  15648. })(function(node, func) {
  15649. node.DEFMETHOD("negate", function(compressor) {
  15650. return func.call(this, compressor);
  15651. });
  15652. });
  15653. (function(def) {
  15654. def(AST_Node, function(compressor) {
  15655. return true;
  15656. });
  15657. def(AST_EmptyStatement, function(compressor) {
  15658. return false;
  15659. });
  15660. def(AST_Constant, function(compressor) {
  15661. return false;
  15662. });
  15663. def(AST_This, function(compressor) {
  15664. return false;
  15665. });
  15666. def(AST_Call, function(compressor) {
  15667. var pure = compressor.option("pure_funcs");
  15668. if (!pure) return true;
  15669. return pure.indexOf(this.expression.print_to_string()) < 0;
  15670. });
  15671. def(AST_Block, function(compressor) {
  15672. for (var i = this.body.length; --i >= 0; ) {
  15673. if (this.body[i].has_side_effects(compressor)) return true;
  15674. }
  15675. return false;
  15676. });
  15677. def(AST_SimpleStatement, function(compressor) {
  15678. return this.body.has_side_effects(compressor);
  15679. });
  15680. def(AST_Defun, function(compressor) {
  15681. return true;
  15682. });
  15683. def(AST_Function, function(compressor) {
  15684. return false;
  15685. });
  15686. def(AST_Binary, function(compressor) {
  15687. return this.left.has_side_effects(compressor) || this.right.has_side_effects(compressor);
  15688. });
  15689. def(AST_Assign, function(compressor) {
  15690. return true;
  15691. });
  15692. def(AST_Conditional, function(compressor) {
  15693. return this.condition.has_side_effects(compressor) || this.consequent.has_side_effects(compressor) || this.alternative.has_side_effects(compressor);
  15694. });
  15695. def(AST_Unary, function(compressor) {
  15696. return this.operator == "delete" || this.operator == "++" || this.operator == "--" || this.expression.has_side_effects(compressor);
  15697. });
  15698. def(AST_SymbolRef, function(compressor) {
  15699. return false;
  15700. });
  15701. def(AST_Object, function(compressor) {
  15702. for (var i = this.properties.length; --i >= 0; ) if (this.properties[i].has_side_effects(compressor)) return true;
  15703. return false;
  15704. });
  15705. def(AST_ObjectProperty, function(compressor) {
  15706. return this.value.has_side_effects(compressor);
  15707. });
  15708. def(AST_Array, function(compressor) {
  15709. for (var i = this.elements.length; --i >= 0; ) if (this.elements[i].has_side_effects(compressor)) return true;
  15710. return false;
  15711. });
  15712. def(AST_Dot, function(compressor) {
  15713. if (!compressor.option("pure_getters")) return true;
  15714. return this.expression.has_side_effects(compressor);
  15715. });
  15716. def(AST_Sub, function(compressor) {
  15717. if (!compressor.option("pure_getters")) return true;
  15718. return this.expression.has_side_effects(compressor) || this.property.has_side_effects(compressor);
  15719. });
  15720. def(AST_PropAccess, function(compressor) {
  15721. return !compressor.option("pure_getters");
  15722. });
  15723. def(AST_Seq, function(compressor) {
  15724. return this.car.has_side_effects(compressor) || this.cdr.has_side_effects(compressor);
  15725. });
  15726. })(function(node, func) {
  15727. node.DEFMETHOD("has_side_effects", func);
  15728. });
  15729. function aborts(thing) {
  15730. return thing && thing.aborts();
  15731. }
  15732. (function(def) {
  15733. def(AST_Statement, function() {
  15734. return null;
  15735. });
  15736. def(AST_Jump, function() {
  15737. return this;
  15738. });
  15739. function block_aborts() {
  15740. var n = this.body.length;
  15741. return n > 0 && aborts(this.body[n - 1]);
  15742. }
  15743. def(AST_BlockStatement, block_aborts);
  15744. def(AST_SwitchBranch, block_aborts);
  15745. def(AST_If, function() {
  15746. return this.alternative && aborts(this.body) && aborts(this.alternative);
  15747. });
  15748. })(function(node, func) {
  15749. node.DEFMETHOD("aborts", func);
  15750. });
  15751. OPT(AST_Directive, function(self, compressor) {
  15752. if (self.scope.has_directive(self.value) !== self.scope) {
  15753. return make_node(AST_EmptyStatement, self);
  15754. }
  15755. return self;
  15756. });
  15757. OPT(AST_Debugger, function(self, compressor) {
  15758. if (compressor.option("drop_debugger")) return make_node(AST_EmptyStatement, self);
  15759. return self;
  15760. });
  15761. OPT(AST_LabeledStatement, function(self, compressor) {
  15762. if (self.body instanceof AST_Break && compressor.loopcontrol_target(self.body.label) === self.body) {
  15763. return make_node(AST_EmptyStatement, self);
  15764. }
  15765. return self.label.references.length == 0 ? self.body : self;
  15766. });
  15767. OPT(AST_Block, function(self, compressor) {
  15768. self.body = tighten_body(self.body, compressor);
  15769. return self;
  15770. });
  15771. OPT(AST_BlockStatement, function(self, compressor) {
  15772. self.body = tighten_body(self.body, compressor);
  15773. switch (self.body.length) {
  15774. case 1:
  15775. return self.body[0];
  15776. case 0:
  15777. return make_node(AST_EmptyStatement, self);
  15778. }
  15779. return self;
  15780. });
  15781. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  15782. var self = this;
  15783. if (compressor.option("unused") && !(self instanceof AST_Toplevel) && !self.uses_eval) {
  15784. var in_use = [];
  15785. var initializations = new Dictionary();
  15786. var scope = this;
  15787. var tw = new TreeWalker(function(node, descend) {
  15788. if (node !== self) {
  15789. if (node instanceof AST_Defun) {
  15790. initializations.add(node.name.name, node);
  15791. return true;
  15792. }
  15793. if (node instanceof AST_Definitions && scope === self) {
  15794. node.definitions.forEach(function(def) {
  15795. if (def.value) {
  15796. initializations.add(def.name.name, def.value);
  15797. if (def.value.has_side_effects(compressor)) {
  15798. def.value.walk(tw);
  15799. }
  15800. }
  15801. });
  15802. return true;
  15803. }
  15804. if (node instanceof AST_SymbolRef) {
  15805. push_uniq(in_use, node.definition());
  15806. return true;
  15807. }
  15808. if (node instanceof AST_Scope) {
  15809. var save_scope = scope;
  15810. scope = node;
  15811. descend();
  15812. scope = save_scope;
  15813. return true;
  15814. }
  15815. }
  15816. });
  15817. self.walk(tw);
  15818. for (var i = 0; i < in_use.length; ++i) {
  15819. in_use[i].orig.forEach(function(decl) {
  15820. var init = initializations.get(decl.name);
  15821. if (init) init.forEach(function(init) {
  15822. var tw = new TreeWalker(function(node) {
  15823. if (node instanceof AST_SymbolRef) {
  15824. push_uniq(in_use, node.definition());
  15825. }
  15826. });
  15827. init.walk(tw);
  15828. });
  15829. });
  15830. }
  15831. var tt = new TreeTransformer(function before(node, descend, in_list) {
  15832. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  15833. if (!compressor.option("keep_fargs")) {
  15834. for (var a = node.argnames, i = a.length; --i >= 0; ) {
  15835. var sym = a[i];
  15836. if (sym.unreferenced()) {
  15837. a.pop();
  15838. compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
  15839. name: sym.name,
  15840. file: sym.start.file,
  15841. line: sym.start.line,
  15842. col: sym.start.col
  15843. });
  15844. } else break;
  15845. }
  15846. }
  15847. }
  15848. if (node instanceof AST_Defun && node !== self) {
  15849. if (!member(node.name.definition(), in_use)) {
  15850. compressor.warn("Dropping unused function {name} [{file}:{line},{col}]", {
  15851. name: node.name.name,
  15852. file: node.name.start.file,
  15853. line: node.name.start.line,
  15854. col: node.name.start.col
  15855. });
  15856. return make_node(AST_EmptyStatement, node);
  15857. }
  15858. return node;
  15859. }
  15860. if (node instanceof AST_Definitions && !(tt.parent() instanceof AST_ForIn)) {
  15861. var def = node.definitions.filter(function(def) {
  15862. if (member(def.name.definition(), in_use)) return true;
  15863. var w = {
  15864. name: def.name.name,
  15865. file: def.name.start.file,
  15866. line: def.name.start.line,
  15867. col: def.name.start.col
  15868. };
  15869. if (def.value && def.value.has_side_effects(compressor)) {
  15870. def._unused_side_effects = true;
  15871. compressor.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", w);
  15872. return true;
  15873. }
  15874. compressor.warn("Dropping unused variable {name} [{file}:{line},{col}]", w);
  15875. return false;
  15876. });
  15877. def = mergeSort(def, function(a, b) {
  15878. if (!a.value && b.value) return -1;
  15879. if (!b.value && a.value) return 1;
  15880. return 0;
  15881. });
  15882. var side_effects = [];
  15883. for (var i = 0; i < def.length; ) {
  15884. var x = def[i];
  15885. if (x._unused_side_effects) {
  15886. side_effects.push(x.value);
  15887. def.splice(i, 1);
  15888. } else {
  15889. if (side_effects.length > 0) {
  15890. side_effects.push(x.value);
  15891. x.value = AST_Seq.from_array(side_effects);
  15892. side_effects = [];
  15893. }
  15894. ++i;
  15895. }
  15896. }
  15897. if (side_effects.length > 0) {
  15898. side_effects = make_node(AST_BlockStatement, node, {
  15899. body: [ make_node(AST_SimpleStatement, node, {
  15900. body: AST_Seq.from_array(side_effects)
  15901. }) ]
  15902. });
  15903. } else {
  15904. side_effects = null;
  15905. }
  15906. if (def.length == 0 && !side_effects) {
  15907. return make_node(AST_EmptyStatement, node);
  15908. }
  15909. if (def.length == 0) {
  15910. return side_effects;
  15911. }
  15912. node.definitions = def;
  15913. if (side_effects) {
  15914. side_effects.body.unshift(node);
  15915. node = side_effects;
  15916. }
  15917. return node;
  15918. }
  15919. if (node instanceof AST_For) {
  15920. descend(node, this);
  15921. if (node.init instanceof AST_BlockStatement) {
  15922. var body = node.init.body.slice(0, -1);
  15923. node.init = node.init.body.slice(-1)[0].body;
  15924. body.push(node);
  15925. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  15926. body: body
  15927. });
  15928. }
  15929. }
  15930. if (node instanceof AST_Scope && node !== self) return node;
  15931. });
  15932. self.transform(tt);
  15933. }
  15934. });
  15935. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  15936. var hoist_funs = compressor.option("hoist_funs");
  15937. var hoist_vars = compressor.option("hoist_vars");
  15938. var self = this;
  15939. if (hoist_funs || hoist_vars) {
  15940. var dirs = [];
  15941. var hoisted = [];
  15942. var vars = new Dictionary(), vars_found = 0, var_decl = 0;
  15943. self.walk(new TreeWalker(function(node) {
  15944. if (node instanceof AST_Scope && node !== self) return true;
  15945. if (node instanceof AST_Var) {
  15946. ++var_decl;
  15947. return true;
  15948. }
  15949. }));
  15950. hoist_vars = hoist_vars && var_decl > 1;
  15951. var tt = new TreeTransformer(function before(node) {
  15952. if (node !== self) {
  15953. if (node instanceof AST_Directive) {
  15954. dirs.push(node);
  15955. return make_node(AST_EmptyStatement, node);
  15956. }
  15957. if (node instanceof AST_Defun && hoist_funs) {
  15958. hoisted.push(node);
  15959. return make_node(AST_EmptyStatement, node);
  15960. }
  15961. if (node instanceof AST_Var && hoist_vars) {
  15962. node.definitions.forEach(function(def) {
  15963. vars.set(def.name.name, def);
  15964. ++vars_found;
  15965. });
  15966. var seq = node.to_assignments();
  15967. var p = tt.parent();
  15968. if (p instanceof AST_ForIn && p.init === node) {
  15969. if (seq == null) return node.definitions[0].name;
  15970. return seq;
  15971. }
  15972. if (p instanceof AST_For && p.init === node) {
  15973. return seq;
  15974. }
  15975. if (!seq) return make_node(AST_EmptyStatement, node);
  15976. return make_node(AST_SimpleStatement, node, {
  15977. body: seq
  15978. });
  15979. }
  15980. if (node instanceof AST_Scope) return node;
  15981. }
  15982. });
  15983. self = self.transform(tt);
  15984. if (vars_found > 0) {
  15985. var defs = [];
  15986. vars.each(function(def, name) {
  15987. if (self instanceof AST_Lambda && find_if(function(x) {
  15988. return x.name == def.name.name;
  15989. }, self.argnames)) {
  15990. vars.del(name);
  15991. } else {
  15992. def = def.clone();
  15993. def.value = null;
  15994. defs.push(def);
  15995. vars.set(name, def);
  15996. }
  15997. });
  15998. if (defs.length > 0) {
  15999. for (var i = 0; i < self.body.length; ) {
  16000. if (self.body[i] instanceof AST_SimpleStatement) {
  16001. var expr = self.body[i].body, sym, assign;
  16002. if (expr instanceof AST_Assign && expr.operator == "=" && (sym = expr.left) instanceof AST_Symbol && vars.has(sym.name)) {
  16003. var def = vars.get(sym.name);
  16004. if (def.value) break;
  16005. def.value = expr.right;
  16006. remove(defs, def);
  16007. defs.push(def);
  16008. self.body.splice(i, 1);
  16009. continue;
  16010. }
  16011. if (expr instanceof AST_Seq && (assign = expr.car) instanceof AST_Assign && assign.operator == "=" && (sym = assign.left) instanceof AST_Symbol && vars.has(sym.name)) {
  16012. var def = vars.get(sym.name);
  16013. if (def.value) break;
  16014. def.value = assign.right;
  16015. remove(defs, def);
  16016. defs.push(def);
  16017. self.body[i].body = expr.cdr;
  16018. continue;
  16019. }
  16020. }
  16021. if (self.body[i] instanceof AST_EmptyStatement) {
  16022. self.body.splice(i, 1);
  16023. continue;
  16024. }
  16025. if (self.body[i] instanceof AST_BlockStatement) {
  16026. var tmp = [ i, 1 ].concat(self.body[i].body);
  16027. self.body.splice.apply(self.body, tmp);
  16028. continue;
  16029. }
  16030. break;
  16031. }
  16032. defs = make_node(AST_Var, self, {
  16033. definitions: defs
  16034. });
  16035. hoisted.push(defs);
  16036. }
  16037. }
  16038. self.body = dirs.concat(hoisted, self.body);
  16039. }
  16040. return self;
  16041. });
  16042. OPT(AST_SimpleStatement, function(self, compressor) {
  16043. if (compressor.option("side_effects")) {
  16044. if (!self.body.has_side_effects(compressor)) {
  16045. compressor.warn("Dropping side-effect-free statement [{file}:{line},{col}]", self.start);
  16046. return make_node(AST_EmptyStatement, self);
  16047. }
  16048. }
  16049. return self;
  16050. });
  16051. OPT(AST_DWLoop, function(self, compressor) {
  16052. var cond = self.condition.evaluate(compressor);
  16053. self.condition = cond[0];
  16054. if (!compressor.option("loops")) return self;
  16055. if (cond.length > 1) {
  16056. if (cond[1]) {
  16057. return make_node(AST_For, self, {
  16058. body: self.body
  16059. });
  16060. } else if (self instanceof AST_While) {
  16061. if (compressor.option("dead_code")) {
  16062. var a = [];
  16063. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16064. return make_node(AST_BlockStatement, self, {
  16065. body: a
  16066. });
  16067. }
  16068. }
  16069. }
  16070. return self;
  16071. });
  16072. function if_break_in_loop(self, compressor) {
  16073. function drop_it(rest) {
  16074. rest = as_statement_array(rest);
  16075. if (self.body instanceof AST_BlockStatement) {
  16076. self.body = self.body.clone();
  16077. self.body.body = rest.concat(self.body.body.slice(1));
  16078. self.body = self.body.transform(compressor);
  16079. } else {
  16080. self.body = make_node(AST_BlockStatement, self.body, {
  16081. body: rest
  16082. }).transform(compressor);
  16083. }
  16084. if_break_in_loop(self, compressor);
  16085. }
  16086. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  16087. if (first instanceof AST_If) {
  16088. if (first.body instanceof AST_Break && compressor.loopcontrol_target(first.body.label) === self) {
  16089. if (self.condition) {
  16090. self.condition = make_node(AST_Binary, self.condition, {
  16091. left: self.condition,
  16092. operator: "&&",
  16093. right: first.condition.negate(compressor)
  16094. });
  16095. } else {
  16096. self.condition = first.condition.negate(compressor);
  16097. }
  16098. drop_it(first.alternative);
  16099. } else if (first.alternative instanceof AST_Break && compressor.loopcontrol_target(first.alternative.label) === self) {
  16100. if (self.condition) {
  16101. self.condition = make_node(AST_Binary, self.condition, {
  16102. left: self.condition,
  16103. operator: "&&",
  16104. right: first.condition
  16105. });
  16106. } else {
  16107. self.condition = first.condition;
  16108. }
  16109. drop_it(first.body);
  16110. }
  16111. }
  16112. }
  16113. OPT(AST_While, function(self, compressor) {
  16114. if (!compressor.option("loops")) return self;
  16115. self = AST_DWLoop.prototype.optimize.call(self, compressor);
  16116. if (self instanceof AST_While) {
  16117. if_break_in_loop(self, compressor);
  16118. self = make_node(AST_For, self, self).transform(compressor);
  16119. }
  16120. return self;
  16121. });
  16122. OPT(AST_For, function(self, compressor) {
  16123. var cond = self.condition;
  16124. if (cond) {
  16125. cond = cond.evaluate(compressor);
  16126. self.condition = cond[0];
  16127. }
  16128. if (!compressor.option("loops")) return self;
  16129. if (cond) {
  16130. if (cond.length > 1 && !cond[1]) {
  16131. if (compressor.option("dead_code")) {
  16132. var a = [];
  16133. if (self.init instanceof AST_Statement) {
  16134. a.push(self.init);
  16135. } else if (self.init) {
  16136. a.push(make_node(AST_SimpleStatement, self.init, {
  16137. body: self.init
  16138. }));
  16139. }
  16140. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16141. return make_node(AST_BlockStatement, self, {
  16142. body: a
  16143. });
  16144. }
  16145. }
  16146. }
  16147. if_break_in_loop(self, compressor);
  16148. return self;
  16149. });
  16150. OPT(AST_If, function(self, compressor) {
  16151. if (!compressor.option("conditionals")) return self;
  16152. var cond = self.condition.evaluate(compressor);
  16153. self.condition = cond[0];
  16154. if (cond.length > 1) {
  16155. if (cond[1]) {
  16156. compressor.warn("Condition always true [{file}:{line},{col}]", self.condition.start);
  16157. if (compressor.option("dead_code")) {
  16158. var a = [];
  16159. if (self.alternative) {
  16160. extract_declarations_from_unreachable_code(compressor, self.alternative, a);
  16161. }
  16162. a.push(self.body);
  16163. return make_node(AST_BlockStatement, self, {
  16164. body: a
  16165. }).transform(compressor);
  16166. }
  16167. } else {
  16168. compressor.warn("Condition always false [{file}:{line},{col}]", self.condition.start);
  16169. if (compressor.option("dead_code")) {
  16170. var a = [];
  16171. extract_declarations_from_unreachable_code(compressor, self.body, a);
  16172. if (self.alternative) a.push(self.alternative);
  16173. return make_node(AST_BlockStatement, self, {
  16174. body: a
  16175. }).transform(compressor);
  16176. }
  16177. }
  16178. }
  16179. if (is_empty(self.alternative)) self.alternative = null;
  16180. var negated = self.condition.negate(compressor);
  16181. var negated_is_best = best_of(self.condition, negated) === negated;
  16182. if (self.alternative && negated_is_best) {
  16183. negated_is_best = false;
  16184. self.condition = negated;
  16185. var tmp = self.body;
  16186. self.body = self.alternative || make_node(AST_EmptyStatement);
  16187. self.alternative = tmp;
  16188. }
  16189. if (is_empty(self.body) && is_empty(self.alternative)) {
  16190. return make_node(AST_SimpleStatement, self.condition, {
  16191. body: self.condition
  16192. }).transform(compressor);
  16193. }
  16194. if (self.body instanceof AST_SimpleStatement && self.alternative instanceof AST_SimpleStatement) {
  16195. return make_node(AST_SimpleStatement, self, {
  16196. body: make_node(AST_Conditional, self, {
  16197. condition: self.condition,
  16198. consequent: self.body.body,
  16199. alternative: self.alternative.body
  16200. })
  16201. }).transform(compressor);
  16202. }
  16203. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  16204. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  16205. body: make_node(AST_Binary, self, {
  16206. operator: "||",
  16207. left: negated,
  16208. right: self.body.body
  16209. })
  16210. }).transform(compressor);
  16211. return make_node(AST_SimpleStatement, self, {
  16212. body: make_node(AST_Binary, self, {
  16213. operator: "&&",
  16214. left: self.condition,
  16215. right: self.body.body
  16216. })
  16217. }).transform(compressor);
  16218. }
  16219. if (self.body instanceof AST_EmptyStatement && self.alternative && self.alternative instanceof AST_SimpleStatement) {
  16220. return make_node(AST_SimpleStatement, self, {
  16221. body: make_node(AST_Binary, self, {
  16222. operator: "||",
  16223. left: self.condition,
  16224. right: self.alternative.body
  16225. })
  16226. }).transform(compressor);
  16227. }
  16228. if (self.body instanceof AST_Exit && self.alternative instanceof AST_Exit && self.body.TYPE == self.alternative.TYPE) {
  16229. return make_node(self.body.CTOR, self, {
  16230. value: make_node(AST_Conditional, self, {
  16231. condition: self.condition,
  16232. consequent: self.body.value || make_node(AST_Undefined, self.body).optimize(compressor),
  16233. alternative: self.alternative.value || make_node(AST_Undefined, self.alternative).optimize(compressor)
  16234. })
  16235. }).transform(compressor);
  16236. }
  16237. if (self.body instanceof AST_If && !self.body.alternative && !self.alternative) {
  16238. self.condition = make_node(AST_Binary, self.condition, {
  16239. operator: "&&",
  16240. left: self.condition,
  16241. right: self.body.condition
  16242. }).transform(compressor);
  16243. self.body = self.body.body;
  16244. }
  16245. if (aborts(self.body)) {
  16246. if (self.alternative) {
  16247. var alt = self.alternative;
  16248. self.alternative = null;
  16249. return make_node(AST_BlockStatement, self, {
  16250. body: [ self, alt ]
  16251. }).transform(compressor);
  16252. }
  16253. }
  16254. if (aborts(self.alternative)) {
  16255. var body = self.body;
  16256. self.body = self.alternative;
  16257. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  16258. self.alternative = null;
  16259. return make_node(AST_BlockStatement, self, {
  16260. body: [ self, body ]
  16261. }).transform(compressor);
  16262. }
  16263. return self;
  16264. });
  16265. OPT(AST_Switch, function(self, compressor) {
  16266. if (self.body.length == 0 && compressor.option("conditionals")) {
  16267. return make_node(AST_SimpleStatement, self, {
  16268. body: self.expression
  16269. }).transform(compressor);
  16270. }
  16271. for (;;) {
  16272. var last_branch = self.body[self.body.length - 1];
  16273. if (last_branch) {
  16274. var stat = last_branch.body[last_branch.body.length - 1];
  16275. if (stat instanceof AST_Break && loop_body(compressor.loopcontrol_target(stat.label)) === self) last_branch.body.pop();
  16276. if (last_branch instanceof AST_Default && last_branch.body.length == 0) {
  16277. self.body.pop();
  16278. continue;
  16279. }
  16280. }
  16281. break;
  16282. }
  16283. var exp = self.expression.evaluate(compressor);
  16284. out: if (exp.length == 2) try {
  16285. self.expression = exp[0];
  16286. if (!compressor.option("dead_code")) break out;
  16287. var value = exp[1];
  16288. var in_if = false;
  16289. var in_block = false;
  16290. var started = false;
  16291. var stopped = false;
  16292. var ruined = false;
  16293. var tt = new TreeTransformer(function(node, descend, in_list) {
  16294. if (node instanceof AST_Lambda || node instanceof AST_SimpleStatement) {
  16295. return node;
  16296. } else if (node instanceof AST_Switch && node === self) {
  16297. node = node.clone();
  16298. descend(node, this);
  16299. return ruined ? node : make_node(AST_BlockStatement, node, {
  16300. body: node.body.reduce(function(a, branch) {
  16301. return a.concat(branch.body);
  16302. }, [])
  16303. }).transform(compressor);
  16304. } else if (node instanceof AST_If || node instanceof AST_Try) {
  16305. var save = in_if;
  16306. in_if = !in_block;
  16307. descend(node, this);
  16308. in_if = save;
  16309. return node;
  16310. } else if (node instanceof AST_StatementWithBody || node instanceof AST_Switch) {
  16311. var save = in_block;
  16312. in_block = true;
  16313. descend(node, this);
  16314. in_block = save;
  16315. return node;
  16316. } else if (node instanceof AST_Break && this.loopcontrol_target(node.label) === self) {
  16317. if (in_if) {
  16318. ruined = true;
  16319. return node;
  16320. }
  16321. if (in_block) return node;
  16322. stopped = true;
  16323. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  16324. } else if (node instanceof AST_SwitchBranch && this.parent() === self) {
  16325. if (stopped) return MAP.skip;
  16326. if (node instanceof AST_Case) {
  16327. var exp = node.expression.evaluate(compressor);
  16328. if (exp.length < 2) {
  16329. throw self;
  16330. }
  16331. if (exp[1] === value || started) {
  16332. started = true;
  16333. if (aborts(node)) stopped = true;
  16334. descend(node, this);
  16335. return node;
  16336. }
  16337. return MAP.skip;
  16338. }
  16339. descend(node, this);
  16340. return node;
  16341. }
  16342. });
  16343. tt.stack = compressor.stack.slice();
  16344. self = self.transform(tt);
  16345. } catch (ex) {
  16346. if (ex !== self) throw ex;
  16347. }
  16348. return self;
  16349. });
  16350. OPT(AST_Case, function(self, compressor) {
  16351. self.body = tighten_body(self.body, compressor);
  16352. return self;
  16353. });
  16354. OPT(AST_Try, function(self, compressor) {
  16355. self.body = tighten_body(self.body, compressor);
  16356. return self;
  16357. });
  16358. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  16359. this.definitions.forEach(function(def) {
  16360. def.value = null;
  16361. });
  16362. });
  16363. AST_Definitions.DEFMETHOD("to_assignments", function() {
  16364. var assignments = this.definitions.reduce(function(a, def) {
  16365. if (def.value) {
  16366. var name = make_node(AST_SymbolRef, def.name, def.name);
  16367. a.push(make_node(AST_Assign, def, {
  16368. operator: "=",
  16369. left: name,
  16370. right: def.value
  16371. }));
  16372. }
  16373. return a;
  16374. }, []);
  16375. if (assignments.length == 0) return null;
  16376. return AST_Seq.from_array(assignments);
  16377. });
  16378. OPT(AST_Definitions, function(self, compressor) {
  16379. if (self.definitions.length == 0) return make_node(AST_EmptyStatement, self);
  16380. return self;
  16381. });
  16382. OPT(AST_Function, function(self, compressor) {
  16383. self = AST_Lambda.prototype.optimize.call(self, compressor);
  16384. if (compressor.option("unused")) {
  16385. if (self.name && self.name.unreferenced()) {
  16386. self.name = null;
  16387. }
  16388. }
  16389. return self;
  16390. });
  16391. OPT(AST_Call, function(self, compressor) {
  16392. if (compressor.option("unsafe")) {
  16393. var exp = self.expression;
  16394. if (exp instanceof AST_SymbolRef && exp.undeclared()) {
  16395. switch (exp.name) {
  16396. case "Array":
  16397. if (self.args.length != 1) {
  16398. return make_node(AST_Array, self, {
  16399. elements: self.args
  16400. }).transform(compressor);
  16401. }
  16402. break;
  16403. case "Object":
  16404. if (self.args.length == 0) {
  16405. return make_node(AST_Object, self, {
  16406. properties: []
  16407. });
  16408. }
  16409. break;
  16410. case "String":
  16411. if (self.args.length == 0) return make_node(AST_String, self, {
  16412. value: ""
  16413. });
  16414. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  16415. left: self.args[0],
  16416. operator: "+",
  16417. right: make_node(AST_String, self, {
  16418. value: ""
  16419. })
  16420. }).transform(compressor);
  16421. break;
  16422. case "Number":
  16423. if (self.args.length == 0) return make_node(AST_Number, self, {
  16424. value: 0
  16425. });
  16426. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  16427. expression: self.args[0],
  16428. operator: "+"
  16429. }).transform(compressor);
  16430. case "Boolean":
  16431. if (self.args.length == 0) return make_node(AST_False, self);
  16432. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  16433. expression: make_node(AST_UnaryPrefix, null, {
  16434. expression: self.args[0],
  16435. operator: "!"
  16436. }),
  16437. operator: "!"
  16438. }).transform(compressor);
  16439. break;
  16440. case "Function":
  16441. if (all(self.args, function(x) {
  16442. return x instanceof AST_String;
  16443. })) {
  16444. try {
  16445. var code = "(function(" + self.args.slice(0, -1).map(function(arg) {
  16446. return arg.value;
  16447. }).join(",") + "){" + self.args[self.args.length - 1].value + "})()";
  16448. var ast = parse(code);
  16449. ast.figure_out_scope({
  16450. screw_ie8: compressor.option("screw_ie8")
  16451. });
  16452. var comp = new Compressor(compressor.options);
  16453. ast = ast.transform(comp);
  16454. ast.figure_out_scope({
  16455. screw_ie8: compressor.option("screw_ie8")
  16456. });
  16457. ast.mangle_names();
  16458. var fun;
  16459. try {
  16460. ast.walk(new TreeWalker(function(node) {
  16461. if (node instanceof AST_Lambda) {
  16462. fun = node;
  16463. throw ast;
  16464. }
  16465. }));
  16466. } catch (ex) {
  16467. if (ex !== ast) throw ex;
  16468. }
  16469. var args = fun.argnames.map(function(arg, i) {
  16470. return make_node(AST_String, self.args[i], {
  16471. value: arg.print_to_string()
  16472. });
  16473. });
  16474. var code = OutputStream();
  16475. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  16476. code = code.toString().replace(/^\{|\}$/g, "");
  16477. args.push(make_node(AST_String, self.args[self.args.length - 1], {
  16478. value: code
  16479. }));
  16480. self.args = args;
  16481. return self;
  16482. } catch (ex) {
  16483. if (ex instanceof JS_Parse_Error) {
  16484. compressor.warn("Error parsing code passed to new Function [{file}:{line},{col}]", self.args[self.args.length - 1].start);
  16485. compressor.warn(ex.toString());
  16486. } else {
  16487. console.log(ex);
  16488. throw ex;
  16489. }
  16490. }
  16491. }
  16492. break;
  16493. }
  16494. } else if (exp instanceof AST_Dot && exp.property == "toString" && self.args.length == 0) {
  16495. return make_node(AST_Binary, self, {
  16496. left: make_node(AST_String, self, {
  16497. value: ""
  16498. }),
  16499. operator: "+",
  16500. right: exp.expression
  16501. }).transform(compressor);
  16502. } else if (exp instanceof AST_Dot && exp.expression instanceof AST_Array && exp.property == "join") EXIT: {
  16503. var separator = self.args.length == 0 ? "," : self.args[0].evaluate(compressor)[1];
  16504. if (separator == null) break EXIT;
  16505. var elements = exp.expression.elements.reduce(function(a, el) {
  16506. el = el.evaluate(compressor);
  16507. if (a.length == 0 || el.length == 1) {
  16508. a.push(el);
  16509. } else {
  16510. var last = a[a.length - 1];
  16511. if (last.length == 2) {
  16512. var val = "" + last[1] + separator + el[1];
  16513. a[a.length - 1] = [ make_node_from_constant(compressor, val, last[0]), val ];
  16514. } else {
  16515. a.push(el);
  16516. }
  16517. }
  16518. return a;
  16519. }, []);
  16520. if (elements.length == 0) return make_node(AST_String, self, {
  16521. value: ""
  16522. });
  16523. if (elements.length == 1) return elements[0][0];
  16524. if (separator == "") {
  16525. var first;
  16526. if (elements[0][0] instanceof AST_String || elements[1][0] instanceof AST_String) {
  16527. first = elements.shift()[0];
  16528. } else {
  16529. first = make_node(AST_String, self, {
  16530. value: ""
  16531. });
  16532. }
  16533. return elements.reduce(function(prev, el) {
  16534. return make_node(AST_Binary, el[0], {
  16535. operator: "+",
  16536. left: prev,
  16537. right: el[0]
  16538. });
  16539. }, first).transform(compressor);
  16540. }
  16541. var node = self.clone();
  16542. node.expression = node.expression.clone();
  16543. node.expression.expression = node.expression.expression.clone();
  16544. node.expression.expression.elements = elements.map(function(el) {
  16545. return el[0];
  16546. });
  16547. return best_of(self, node);
  16548. }
  16549. }
  16550. if (compressor.option("side_effects")) {
  16551. if (self.expression instanceof AST_Function && self.args.length == 0 && !AST_Block.prototype.has_side_effects.call(self.expression, compressor)) {
  16552. return make_node(AST_Undefined, self).transform(compressor);
  16553. }
  16554. }
  16555. if (compressor.option("drop_console")) {
  16556. if (self.expression instanceof AST_PropAccess && self.expression.expression instanceof AST_SymbolRef && self.expression.expression.name == "console" && self.expression.expression.undeclared()) {
  16557. return make_node(AST_Undefined, self).transform(compressor);
  16558. }
  16559. }
  16560. return self.evaluate(compressor)[0];
  16561. });
  16562. OPT(AST_New, function(self, compressor) {
  16563. if (compressor.option("unsafe")) {
  16564. var exp = self.expression;
  16565. if (exp instanceof AST_SymbolRef && exp.undeclared()) {
  16566. switch (exp.name) {
  16567. case "Object":
  16568. case "RegExp":
  16569. case "Function":
  16570. case "Error":
  16571. case "Array":
  16572. return make_node(AST_Call, self, self).transform(compressor);
  16573. }
  16574. }
  16575. }
  16576. return self;
  16577. });
  16578. OPT(AST_Seq, function(self, compressor) {
  16579. if (!compressor.option("side_effects")) return self;
  16580. if (!self.car.has_side_effects(compressor)) {
  16581. var p;
  16582. if (!(self.cdr instanceof AST_SymbolRef && self.cdr.name == "eval" && self.cdr.undeclared() && (p = compressor.parent()) instanceof AST_Call && p.expression === self)) {
  16583. return self.cdr;
  16584. }
  16585. }
  16586. if (compressor.option("cascade")) {
  16587. if (self.car instanceof AST_Assign && !self.car.left.has_side_effects(compressor)) {
  16588. if (self.car.left.equivalent_to(self.cdr)) {
  16589. return self.car;
  16590. }
  16591. if (self.cdr instanceof AST_Call && self.cdr.expression.equivalent_to(self.car.left)) {
  16592. self.cdr.expression = self.car;
  16593. return self.cdr;
  16594. }
  16595. }
  16596. if (!self.car.has_side_effects(compressor) && !self.cdr.has_side_effects(compressor) && self.car.equivalent_to(self.cdr)) {
  16597. return self.car;
  16598. }
  16599. }
  16600. if (self.cdr instanceof AST_UnaryPrefix && self.cdr.operator == "void" && !self.cdr.expression.has_side_effects(compressor)) {
  16601. self.cdr.operator = self.car;
  16602. return self.cdr;
  16603. }
  16604. if (self.cdr instanceof AST_Undefined) {
  16605. return make_node(AST_UnaryPrefix, self, {
  16606. operator: "void",
  16607. expression: self.car
  16608. });
  16609. }
  16610. return self;
  16611. });
  16612. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  16613. if (compressor.option("sequences")) {
  16614. if (this.expression instanceof AST_Seq) {
  16615. var seq = this.expression;
  16616. var x = seq.to_array();
  16617. this.expression = x.pop();
  16618. x.push(this);
  16619. seq = AST_Seq.from_array(x).transform(compressor);
  16620. return seq;
  16621. }
  16622. }
  16623. return this;
  16624. });
  16625. OPT(AST_UnaryPostfix, function(self, compressor) {
  16626. return self.lift_sequences(compressor);
  16627. });
  16628. OPT(AST_UnaryPrefix, function(self, compressor) {
  16629. self = self.lift_sequences(compressor);
  16630. var e = self.expression;
  16631. if (compressor.option("booleans") && compressor.in_boolean_context()) {
  16632. switch (self.operator) {
  16633. case "!":
  16634. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  16635. return e.expression;
  16636. }
  16637. break;
  16638. case "typeof":
  16639. compressor.warn("Boolean expression always true [{file}:{line},{col}]", self.start);
  16640. return make_node(AST_True, self);
  16641. }
  16642. if (e instanceof AST_Binary && self.operator == "!") {
  16643. self = best_of(self, e.negate(compressor));
  16644. }
  16645. }
  16646. return self.evaluate(compressor)[0];
  16647. });
  16648. function has_side_effects_or_prop_access(node, compressor) {
  16649. var save_pure_getters = compressor.option("pure_getters");
  16650. compressor.options.pure_getters = false;
  16651. var ret = node.has_side_effects(compressor);
  16652. compressor.options.pure_getters = save_pure_getters;
  16653. return ret;
  16654. }
  16655. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  16656. if (compressor.option("sequences")) {
  16657. if (this.left instanceof AST_Seq) {
  16658. var seq = this.left;
  16659. var x = seq.to_array();
  16660. this.left = x.pop();
  16661. x.push(this);
  16662. seq = AST_Seq.from_array(x).transform(compressor);
  16663. return seq;
  16664. }
  16665. if (this.right instanceof AST_Seq && this instanceof AST_Assign && !has_side_effects_or_prop_access(this.left, compressor)) {
  16666. var seq = this.right;
  16667. var x = seq.to_array();
  16668. this.right = x.pop();
  16669. x.push(this);
  16670. seq = AST_Seq.from_array(x).transform(compressor);
  16671. return seq;
  16672. }
  16673. }
  16674. return this;
  16675. });
  16676. var commutativeOperators = makePredicate("== === != !== * & | ^");
  16677. OPT(AST_Binary, function(self, compressor) {
  16678. var reverse = compressor.has_directive("use asm") ? noop : function(op, force) {
  16679. if (force || !(self.left.has_side_effects(compressor) || self.right.has_side_effects(compressor))) {
  16680. if (op) self.operator = op;
  16681. var tmp = self.left;
  16682. self.left = self.right;
  16683. self.right = tmp;
  16684. }
  16685. };
  16686. if (commutativeOperators(self.operator)) {
  16687. if (self.right instanceof AST_Constant && !(self.left instanceof AST_Constant)) {
  16688. if (!(self.left instanceof AST_Binary && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  16689. reverse(null, true);
  16690. }
  16691. }
  16692. if (/^[!=]==?$/.test(self.operator)) {
  16693. if (self.left instanceof AST_SymbolRef && self.right instanceof AST_Conditional) {
  16694. if (self.right.consequent instanceof AST_SymbolRef && self.right.consequent.definition() === self.left.definition()) {
  16695. if (/^==/.test(self.operator)) return self.right.condition;
  16696. if (/^!=/.test(self.operator)) return self.right.condition.negate(compressor);
  16697. }
  16698. if (self.right.alternative instanceof AST_SymbolRef && self.right.alternative.definition() === self.left.definition()) {
  16699. if (/^==/.test(self.operator)) return self.right.condition.negate(compressor);
  16700. if (/^!=/.test(self.operator)) return self.right.condition;
  16701. }
  16702. }
  16703. if (self.right instanceof AST_SymbolRef && self.left instanceof AST_Conditional) {
  16704. if (self.left.consequent instanceof AST_SymbolRef && self.left.consequent.definition() === self.right.definition()) {
  16705. if (/^==/.test(self.operator)) return self.left.condition;
  16706. if (/^!=/.test(self.operator)) return self.left.condition.negate(compressor);
  16707. }
  16708. if (self.left.alternative instanceof AST_SymbolRef && self.left.alternative.definition() === self.right.definition()) {
  16709. if (/^==/.test(self.operator)) return self.left.condition.negate(compressor);
  16710. if (/^!=/.test(self.operator)) return self.left.condition;
  16711. }
  16712. }
  16713. }
  16714. }
  16715. self = self.lift_sequences(compressor);
  16716. if (compressor.option("comparisons")) switch (self.operator) {
  16717. case "===":
  16718. case "!==":
  16719. if (self.left.is_string(compressor) && self.right.is_string(compressor) || self.left.is_boolean() && self.right.is_boolean()) {
  16720. self.operator = self.operator.substr(0, 2);
  16721. }
  16722. case "==":
  16723. case "!=":
  16724. if (self.left instanceof AST_String && self.left.value == "undefined" && self.right instanceof AST_UnaryPrefix && self.right.operator == "typeof" && compressor.option("unsafe")) {
  16725. if (!(self.right.expression instanceof AST_SymbolRef) || !self.right.expression.undeclared()) {
  16726. self.right = self.right.expression;
  16727. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  16728. if (self.operator.length == 2) self.operator += "=";
  16729. }
  16730. }
  16731. break;
  16732. }
  16733. if (compressor.option("booleans") && compressor.in_boolean_context()) switch (self.operator) {
  16734. case "&&":
  16735. var ll = self.left.evaluate(compressor);
  16736. var rr = self.right.evaluate(compressor);
  16737. if (ll.length > 1 && !ll[1] || rr.length > 1 && !rr[1]) {
  16738. compressor.warn("Boolean && always false [{file}:{line},{col}]", self.start);
  16739. return make_node(AST_False, self);
  16740. }
  16741. if (ll.length > 1 && ll[1]) {
  16742. return rr[0];
  16743. }
  16744. if (rr.length > 1 && rr[1]) {
  16745. return ll[0];
  16746. }
  16747. break;
  16748. case "||":
  16749. var ll = self.left.evaluate(compressor);
  16750. var rr = self.right.evaluate(compressor);
  16751. if (ll.length > 1 && ll[1] || rr.length > 1 && rr[1]) {
  16752. compressor.warn("Boolean || always true [{file}:{line},{col}]", self.start);
  16753. return make_node(AST_True, self);
  16754. }
  16755. if (ll.length > 1 && !ll[1]) {
  16756. return rr[0];
  16757. }
  16758. if (rr.length > 1 && !rr[1]) {
  16759. return ll[0];
  16760. }
  16761. break;
  16762. case "+":
  16763. var ll = self.left.evaluate(compressor);
  16764. var rr = self.right.evaluate(compressor);
  16765. if (ll.length > 1 && ll[0] instanceof AST_String && ll[1] || rr.length > 1 && rr[0] instanceof AST_String && rr[1]) {
  16766. compressor.warn("+ in boolean context always true [{file}:{line},{col}]", self.start);
  16767. return make_node(AST_True, self);
  16768. }
  16769. break;
  16770. }
  16771. if (compressor.option("comparisons")) {
  16772. if (!(compressor.parent() instanceof AST_Binary) || compressor.parent() instanceof AST_Assign) {
  16773. var negated = make_node(AST_UnaryPrefix, self, {
  16774. operator: "!",
  16775. expression: self.negate(compressor)
  16776. });
  16777. self = best_of(self, negated);
  16778. }
  16779. switch (self.operator) {
  16780. case "<":
  16781. reverse(">");
  16782. break;
  16783. case "<=":
  16784. reverse(">=");
  16785. break;
  16786. }
  16787. }
  16788. if (self.operator == "+" && self.right instanceof AST_String && self.right.getValue() === "" && self.left instanceof AST_Binary && self.left.operator == "+" && self.left.is_string(compressor)) {
  16789. return self.left;
  16790. }
  16791. if (compressor.option("evaluate")) {
  16792. if (self.operator == "+") {
  16793. if (self.left instanceof AST_Constant && self.right instanceof AST_Binary && self.right.operator == "+" && self.right.left instanceof AST_Constant && self.right.is_string(compressor)) {
  16794. self = make_node(AST_Binary, self, {
  16795. operator: "+",
  16796. left: make_node(AST_String, null, {
  16797. value: "" + self.left.getValue() + self.right.left.getValue(),
  16798. start: self.left.start,
  16799. end: self.right.left.end
  16800. }),
  16801. right: self.right.right
  16802. });
  16803. }
  16804. if (self.right instanceof AST_Constant && self.left instanceof AST_Binary && self.left.operator == "+" && self.left.right instanceof AST_Constant && self.left.is_string(compressor)) {
  16805. self = make_node(AST_Binary, self, {
  16806. operator: "+",
  16807. left: self.left.left,
  16808. right: make_node(AST_String, null, {
  16809. value: "" + self.left.right.getValue() + self.right.getValue(),
  16810. start: self.left.right.start,
  16811. end: self.right.end
  16812. })
  16813. });
  16814. }
  16815. if (self.left instanceof AST_Binary && self.left.operator == "+" && self.left.is_string(compressor) && self.left.right instanceof AST_Constant && self.right instanceof AST_Binary && self.right.operator == "+" && self.right.left instanceof AST_Constant && self.right.is_string(compressor)) {
  16816. self = make_node(AST_Binary, self, {
  16817. operator: "+",
  16818. left: make_node(AST_Binary, self.left, {
  16819. operator: "+",
  16820. left: self.left.left,
  16821. right: make_node(AST_String, null, {
  16822. value: "" + self.left.right.getValue() + self.right.left.getValue(),
  16823. start: self.left.right.start,
  16824. end: self.right.left.end
  16825. })
  16826. }),
  16827. right: self.right.right
  16828. });
  16829. }
  16830. }
  16831. }
  16832. if (self.right instanceof AST_Binary && self.right.operator == self.operator && (self.operator == "*" || self.operator == "&&" || self.operator == "||")) {
  16833. self.left = make_node(AST_Binary, self.left, {
  16834. operator: self.operator,
  16835. left: self.left,
  16836. right: self.right.left
  16837. });
  16838. self.right = self.right.right;
  16839. return self.transform(compressor);
  16840. }
  16841. return self.evaluate(compressor)[0];
  16842. });
  16843. OPT(AST_SymbolRef, function(self, compressor) {
  16844. if (self.undeclared()) {
  16845. var defines = compressor.option("global_defs");
  16846. if (defines && defines.hasOwnProperty(self.name)) {
  16847. return make_node_from_constant(compressor, defines[self.name], self);
  16848. }
  16849. switch (self.name) {
  16850. case "undefined":
  16851. return make_node(AST_Undefined, self);
  16852. case "NaN":
  16853. return make_node(AST_NaN, self);
  16854. case "Infinity":
  16855. return make_node(AST_Infinity, self);
  16856. }
  16857. }
  16858. return self;
  16859. });
  16860. OPT(AST_Undefined, function(self, compressor) {
  16861. if (compressor.option("unsafe")) {
  16862. var scope = compressor.find_parent(AST_Scope);
  16863. var undef = scope.find_variable("undefined");
  16864. if (undef) {
  16865. var ref = make_node(AST_SymbolRef, self, {
  16866. name: "undefined",
  16867. scope: scope,
  16868. thedef: undef
  16869. });
  16870. ref.reference();
  16871. return ref;
  16872. }
  16873. }
  16874. return self;
  16875. });
  16876. var ASSIGN_OPS = [ "+", "-", "/", "*", "%", ">>", "<<", ">>>", "|", "^", "&" ];
  16877. OPT(AST_Assign, function(self, compressor) {
  16878. self = self.lift_sequences(compressor);
  16879. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary && self.right.left instanceof AST_SymbolRef && self.right.left.name == self.left.name && member(self.right.operator, ASSIGN_OPS)) {
  16880. self.operator = self.right.operator + "=";
  16881. self.right = self.right.right;
  16882. }
  16883. return self;
  16884. });
  16885. OPT(AST_Conditional, function(self, compressor) {
  16886. if (!compressor.option("conditionals")) return self;
  16887. if (self.condition instanceof AST_Seq) {
  16888. var car = self.condition.car;
  16889. self.condition = self.condition.cdr;
  16890. return AST_Seq.cons(car, self);
  16891. }
  16892. var cond = self.condition.evaluate(compressor);
  16893. if (cond.length > 1) {
  16894. if (cond[1]) {
  16895. compressor.warn("Condition always true [{file}:{line},{col}]", self.start);
  16896. return self.consequent;
  16897. } else {
  16898. compressor.warn("Condition always false [{file}:{line},{col}]", self.start);
  16899. return self.alternative;
  16900. }
  16901. }
  16902. var negated = cond[0].negate(compressor);
  16903. if (best_of(cond[0], negated) === negated) {
  16904. self = make_node(AST_Conditional, self, {
  16905. condition: negated,
  16906. consequent: self.alternative,
  16907. alternative: self.consequent
  16908. });
  16909. }
  16910. var consequent = self.consequent;
  16911. var alternative = self.alternative;
  16912. if (consequent instanceof AST_Assign && alternative instanceof AST_Assign && consequent.operator == alternative.operator && consequent.left.equivalent_to(alternative.left)) {
  16913. return make_node(AST_Assign, self, {
  16914. operator: consequent.operator,
  16915. left: consequent.left,
  16916. right: make_node(AST_Conditional, self, {
  16917. condition: self.condition,
  16918. consequent: consequent.right,
  16919. alternative: alternative.right
  16920. })
  16921. });
  16922. }
  16923. if (consequent instanceof AST_Call && alternative.TYPE === consequent.TYPE && consequent.args.length == alternative.args.length && consequent.expression.equivalent_to(alternative.expression)) {
  16924. if (consequent.args.length == 0) {
  16925. return make_node(AST_Seq, self, {
  16926. car: self.condition,
  16927. cdr: consequent
  16928. });
  16929. }
  16930. if (consequent.args.length == 1) {
  16931. consequent.args[0] = make_node(AST_Conditional, self, {
  16932. condition: self.condition,
  16933. consequent: consequent.args[0],
  16934. alternative: alternative.args[0]
  16935. });
  16936. return consequent;
  16937. }
  16938. }
  16939. if (consequent instanceof AST_Conditional && consequent.alternative.equivalent_to(alternative)) {
  16940. return make_node(AST_Conditional, self, {
  16941. condition: make_node(AST_Binary, self, {
  16942. left: self.condition,
  16943. operator: "&&",
  16944. right: consequent.condition
  16945. }),
  16946. consequent: consequent.consequent,
  16947. alternative: alternative
  16948. });
  16949. }
  16950. return self;
  16951. });
  16952. OPT(AST_Boolean, function(self, compressor) {
  16953. if (compressor.option("booleans")) {
  16954. var p = compressor.parent();
  16955. if (p instanceof AST_Binary && (p.operator == "==" || p.operator == "!=")) {
  16956. compressor.warn("Non-strict equality against boolean: {operator} {value} [{file}:{line},{col}]", {
  16957. operator: p.operator,
  16958. value: self.value,
  16959. file: p.start.file,
  16960. line: p.start.line,
  16961. col: p.start.col
  16962. });
  16963. return make_node(AST_Number, self, {
  16964. value: +self.value
  16965. });
  16966. }
  16967. return make_node(AST_UnaryPrefix, self, {
  16968. operator: "!",
  16969. expression: make_node(AST_Number, self, {
  16970. value: 1 - self.value
  16971. })
  16972. });
  16973. }
  16974. return self;
  16975. });
  16976. OPT(AST_Sub, function(self, compressor) {
  16977. var prop = self.property;
  16978. if (prop instanceof AST_String && compressor.option("properties")) {
  16979. prop = prop.getValue();
  16980. if (RESERVED_WORDS(prop) ? compressor.option("screw_ie8") : is_identifier_string(prop)) {
  16981. return make_node(AST_Dot, self, {
  16982. expression: self.expression,
  16983. property: prop
  16984. }).optimize(compressor);
  16985. }
  16986. var v = parseFloat(prop);
  16987. if (!isNaN(v) && v.toString() == prop) {
  16988. self.property = make_node(AST_Number, self.property, {
  16989. value: v
  16990. });
  16991. }
  16992. }
  16993. return self;
  16994. });
  16995. OPT(AST_Dot, function(self, compressor) {
  16996. return self.evaluate(compressor)[0];
  16997. });
  16998. function literals_in_boolean_context(self, compressor) {
  16999. if (compressor.option("booleans") && compressor.in_boolean_context()) {
  17000. return make_node(AST_True, self);
  17001. }
  17002. return self;
  17003. }
  17004. OPT(AST_Array, literals_in_boolean_context);
  17005. OPT(AST_Object, literals_in_boolean_context);
  17006. OPT(AST_RegExp, literals_in_boolean_context);
  17007. })();
  17008. "use strict";
  17009. function SourceMap(options) {
  17010. options = defaults(options, {
  17011. file: null,
  17012. root: null,
  17013. orig: null,
  17014. orig_line_diff: 0,
  17015. dest_line_diff: 0
  17016. });
  17017. var generator = new MOZ_SourceMap.SourceMapGenerator({
  17018. file: options.file,
  17019. sourceRoot: options.root
  17020. });
  17021. var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
  17022. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  17023. if (orig_map) {
  17024. var info = orig_map.originalPositionFor({
  17025. line: orig_line,
  17026. column: orig_col
  17027. });
  17028. if (info.source === null) {
  17029. return;
  17030. }
  17031. source = info.source;
  17032. orig_line = info.line;
  17033. orig_col = info.column;
  17034. name = info.name;
  17035. }
  17036. generator.addMapping({
  17037. generated: {
  17038. line: gen_line + options.dest_line_diff,
  17039. column: gen_col
  17040. },
  17041. original: {
  17042. line: orig_line + options.orig_line_diff,
  17043. column: orig_col
  17044. },
  17045. source: source,
  17046. name: name
  17047. });
  17048. }
  17049. return {
  17050. add: add,
  17051. get: function() {
  17052. return generator;
  17053. },
  17054. toString: function() {
  17055. return generator.toString();
  17056. }
  17057. };
  17058. }
  17059. "use strict";
  17060. (function() {
  17061. var MOZ_TO_ME = {
  17062. ExpressionStatement: function(M) {
  17063. var expr = M.expression;
  17064. if (expr.type === "Literal" && typeof expr.value === "string") {
  17065. return new AST_Directive({
  17066. start: my_start_token(M),
  17067. end: my_end_token(M),
  17068. value: expr.value
  17069. });
  17070. }
  17071. return new AST_SimpleStatement({
  17072. start: my_start_token(M),
  17073. end: my_end_token(M),
  17074. body: from_moz(expr)
  17075. });
  17076. },
  17077. TryStatement: function(M) {
  17078. var handlers = M.handlers || [ M.handler ];
  17079. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  17080. throw new Error("Multiple catch clauses are not supported.");
  17081. }
  17082. return new AST_Try({
  17083. start: my_start_token(M),
  17084. end: my_end_token(M),
  17085. body: from_moz(M.block).body,
  17086. bcatch: from_moz(handlers[0]),
  17087. bfinally: M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  17088. });
  17089. },
  17090. Property: function(M) {
  17091. var key = M.key;
  17092. var name = key.type == "Identifier" ? key.name : key.value;
  17093. var args = {
  17094. start: my_start_token(key),
  17095. end: my_end_token(M.value),
  17096. key: name,
  17097. value: from_moz(M.value)
  17098. };
  17099. switch (M.kind) {
  17100. case "init":
  17101. return new AST_ObjectKeyVal(args);
  17102. case "set":
  17103. args.value.name = from_moz(key);
  17104. return new AST_ObjectSetter(args);
  17105. case "get":
  17106. args.value.name = from_moz(key);
  17107. return new AST_ObjectGetter(args);
  17108. }
  17109. },
  17110. ObjectExpression: function(M) {
  17111. return new AST_Object({
  17112. start: my_start_token(M),
  17113. end: my_end_token(M),
  17114. properties: M.properties.map(function(prop) {
  17115. prop.type = "Property";
  17116. return from_moz(prop);
  17117. })
  17118. });
  17119. },
  17120. SequenceExpression: function(M) {
  17121. return AST_Seq.from_array(M.expressions.map(from_moz));
  17122. },
  17123. MemberExpression: function(M) {
  17124. return new (M.computed ? AST_Sub : AST_Dot)({
  17125. start: my_start_token(M),
  17126. end: my_end_token(M),
  17127. property: M.computed ? from_moz(M.property) : M.property.name,
  17128. expression: from_moz(M.object)
  17129. });
  17130. },
  17131. SwitchCase: function(M) {
  17132. return new (M.test ? AST_Case : AST_Default)({
  17133. start: my_start_token(M),
  17134. end: my_end_token(M),
  17135. expression: from_moz(M.test),
  17136. body: M.consequent.map(from_moz)
  17137. });
  17138. },
  17139. VariableDeclaration: function(M) {
  17140. return new (M.kind === "const" ? AST_Const : AST_Var)({
  17141. start: my_start_token(M),
  17142. end: my_end_token(M),
  17143. definitions: M.declarations.map(from_moz)
  17144. });
  17145. },
  17146. Literal: function(M) {
  17147. var val = M.value, args = {
  17148. start: my_start_token(M),
  17149. end: my_end_token(M)
  17150. };
  17151. if (val === null) return new AST_Null(args);
  17152. switch (typeof val) {
  17153. case "string":
  17154. args.value = val;
  17155. return new AST_String(args);
  17156. case "number":
  17157. args.value = val;
  17158. return new AST_Number(args);
  17159. case "boolean":
  17160. return new (val ? AST_True : AST_False)(args);
  17161. default:
  17162. args.value = val;
  17163. return new AST_RegExp(args);
  17164. }
  17165. },
  17166. Identifier: function(M) {
  17167. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  17168. return new (p.type == "LabeledStatement" ? AST_Label : p.type == "VariableDeclarator" && p.id === M ? p.kind == "const" ? AST_SymbolConst : AST_SymbolVar : p.type == "FunctionExpression" ? p.id === M ? AST_SymbolLambda : AST_SymbolFunarg : p.type == "FunctionDeclaration" ? p.id === M ? AST_SymbolDefun : AST_SymbolFunarg : p.type == "CatchClause" ? AST_SymbolCatch : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef : AST_SymbolRef)({
  17169. start: my_start_token(M),
  17170. end: my_end_token(M),
  17171. name: M.name
  17172. });
  17173. }
  17174. };
  17175. MOZ_TO_ME.UpdateExpression = MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  17176. var prefix = "prefix" in M ? M.prefix : M.type == "UnaryExpression" ? true : false;
  17177. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  17178. start: my_start_token(M),
  17179. end: my_end_token(M),
  17180. operator: M.operator,
  17181. expression: from_moz(M.argument)
  17182. });
  17183. };
  17184. map("Program", AST_Toplevel, "body@body");
  17185. map("EmptyStatement", AST_EmptyStatement);
  17186. map("BlockStatement", AST_BlockStatement, "body@body");
  17187. map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
  17188. map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
  17189. map("BreakStatement", AST_Break, "label>label");
  17190. map("ContinueStatement", AST_Continue, "label>label");
  17191. map("WithStatement", AST_With, "object>expression, body>body");
  17192. map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
  17193. map("ReturnStatement", AST_Return, "argument>value");
  17194. map("ThrowStatement", AST_Throw, "argument>value");
  17195. map("WhileStatement", AST_While, "test>condition, body>body");
  17196. map("DoWhileStatement", AST_Do, "test>condition, body>body");
  17197. map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
  17198. map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
  17199. map("DebuggerStatement", AST_Debugger);
  17200. map("FunctionDeclaration", AST_Defun, "id>name, params@argnames, body%body");
  17201. map("VariableDeclarator", AST_VarDef, "id>name, init>value");
  17202. map("CatchClause", AST_Catch, "param>argname, body%body");
  17203. map("ThisExpression", AST_This);
  17204. map("ArrayExpression", AST_Array, "elements@elements");
  17205. map("FunctionExpression", AST_Function, "id>name, params@argnames, body%body");
  17206. map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
  17207. map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
  17208. map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
  17209. map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
  17210. map("NewExpression", AST_New, "callee>expression, arguments@args");
  17211. map("CallExpression", AST_Call, "callee>expression, arguments@args");
  17212. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  17213. return {
  17214. type: "ExpressionStatement",
  17215. expression: {
  17216. type: "Literal",
  17217. value: M.value
  17218. }
  17219. };
  17220. });
  17221. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  17222. return {
  17223. type: "ExpressionStatement",
  17224. expression: to_moz(M.body)
  17225. };
  17226. });
  17227. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  17228. return {
  17229. type: "SwitchCase",
  17230. test: to_moz(M.expression),
  17231. consequent: M.body.map(to_moz)
  17232. };
  17233. });
  17234. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  17235. return {
  17236. type: "TryStatement",
  17237. block: to_moz_block(M),
  17238. handler: to_moz(M.bcatch),
  17239. guardedHandlers: [],
  17240. finalizer: to_moz(M.bfinally)
  17241. };
  17242. });
  17243. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  17244. return {
  17245. type: "CatchClause",
  17246. param: to_moz(M.argname),
  17247. guard: null,
  17248. body: to_moz_block(M)
  17249. };
  17250. });
  17251. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  17252. return {
  17253. type: "VariableDeclaration",
  17254. kind: M instanceof AST_Const ? "const" : "var",
  17255. declarations: M.definitions.map(to_moz)
  17256. };
  17257. });
  17258. def_to_moz(AST_Seq, function To_Moz_SequenceExpression(M) {
  17259. return {
  17260. type: "SequenceExpression",
  17261. expressions: M.to_array().map(to_moz)
  17262. };
  17263. });
  17264. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  17265. var isComputed = M instanceof AST_Sub;
  17266. return {
  17267. type: "MemberExpression",
  17268. object: to_moz(M.expression),
  17269. computed: isComputed,
  17270. property: isComputed ? to_moz(M.property) : {
  17271. type: "Identifier",
  17272. name: M.property
  17273. }
  17274. };
  17275. });
  17276. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  17277. return {
  17278. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  17279. operator: M.operator,
  17280. prefix: M instanceof AST_UnaryPrefix,
  17281. argument: to_moz(M.expression)
  17282. };
  17283. });
  17284. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  17285. return {
  17286. type: M.operator == "&&" || M.operator == "||" ? "LogicalExpression" : "BinaryExpression",
  17287. left: to_moz(M.left),
  17288. operator: M.operator,
  17289. right: to_moz(M.right)
  17290. };
  17291. });
  17292. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  17293. return {
  17294. type: "ObjectExpression",
  17295. properties: M.properties.map(to_moz)
  17296. };
  17297. });
  17298. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M) {
  17299. var key = is_identifier(M.key) ? {
  17300. type: "Identifier",
  17301. name: M.key
  17302. } : {
  17303. type: "Literal",
  17304. value: M.key
  17305. };
  17306. var kind;
  17307. if (M instanceof AST_ObjectKeyVal) {
  17308. kind = "init";
  17309. } else if (M instanceof AST_ObjectGetter) {
  17310. kind = "get";
  17311. } else if (M instanceof AST_ObjectSetter) {
  17312. kind = "set";
  17313. }
  17314. return {
  17315. type: "Property",
  17316. kind: kind,
  17317. key: key,
  17318. value: to_moz(M.value)
  17319. };
  17320. });
  17321. def_to_moz(AST_Symbol, function To_Moz_Identifier(M) {
  17322. var def = M.definition();
  17323. return {
  17324. type: "Identifier",
  17325. name: def ? def.mangled_name || def.name : M.name
  17326. };
  17327. });
  17328. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  17329. var value = M.value;
  17330. if (typeof value === "number" && (value < 0 || value === 0 && 1 / value < 0)) {
  17331. return {
  17332. type: "UnaryExpression",
  17333. operator: "-",
  17334. prefix: true,
  17335. argument: {
  17336. type: "Literal",
  17337. value: -value
  17338. }
  17339. };
  17340. }
  17341. return {
  17342. type: "Literal",
  17343. value: value
  17344. };
  17345. });
  17346. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  17347. return {
  17348. type: "Identifier",
  17349. name: String(M.value)
  17350. };
  17351. });
  17352. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  17353. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  17354. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() {
  17355. return null;
  17356. });
  17357. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  17358. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  17359. function my_start_token(moznode) {
  17360. var loc = moznode.loc;
  17361. var range = moznode.range;
  17362. return new AST_Token({
  17363. file: loc && loc.source,
  17364. line: loc && loc.start.line,
  17365. col: loc && loc.start.column,
  17366. pos: range ? range[0] : moznode.start,
  17367. endpos: range ? range[0] : moznode.start
  17368. });
  17369. }
  17370. function my_end_token(moznode) {
  17371. var loc = moznode.loc;
  17372. var range = moznode.range;
  17373. return new AST_Token({
  17374. file: loc && loc.source,
  17375. line: loc && loc.end.line,
  17376. col: loc && loc.end.column,
  17377. pos: range ? range[1] : moznode.end,
  17378. endpos: range ? range[1] : moznode.end
  17379. });
  17380. }
  17381. function map(moztype, mytype, propmap) {
  17382. if (typeof UglifyJS_NoUnsafeEval !== "undefined") {
  17383. var prop_list = [];
  17384. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  17385. var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
  17386. if (!m) throw new Error("Can't understand property map: " + prop);
  17387. if ("=@>%".indexOf(m[2]) < 0) {
  17388. throw new Error("Can't understand operator in propmap: " + prop);
  17389. }
  17390. prop_list.push(m);
  17391. });
  17392. var moz_to_me = function(M) {
  17393. var props = {
  17394. start: my_start_token(M),
  17395. end: my_end_token(M)
  17396. };
  17397. for (var i = 0; i < prop_list.length; i++) {
  17398. var m = prop_list[i];
  17399. var moz = m[1], how = m[2], my = m[3];
  17400. var mozProp = M[moz];
  17401. var myProp;
  17402. switch (how) {
  17403. case "@":
  17404. myProp = mozProp.map(from_moz);
  17405. break;
  17406. case ">":
  17407. myProp = from_moz(mozProp);
  17408. break;
  17409. case "=":
  17410. myProp = mozProp;
  17411. break;
  17412. case "%":
  17413. myProp = from_moz(mozProp).body;
  17414. break;
  17415. }
  17416. props[my] = myProp;
  17417. }
  17418. return new mytype(props);
  17419. };
  17420. var me_to_moz = function(M) {
  17421. var props = {
  17422. type: moztype
  17423. };
  17424. for (var i = 0; i < prop_list.length; i++) {
  17425. var m = prop_list[i];
  17426. var moz = m[1], how = m[2], my = m[3];
  17427. var myProp = M[my];
  17428. var mozProp;
  17429. switch (how) {
  17430. case "@":
  17431. mozProp = myProp.map(to_moz);
  17432. break;
  17433. case ">":
  17434. mozProp = to_moz(myProp);
  17435. break;
  17436. case "=":
  17437. mozProp = myProp;
  17438. break;
  17439. case "%":
  17440. mozProp = to_moz_block(M);
  17441. break;
  17442. }
  17443. props[moz] = mozProp;
  17444. }
  17445. return props;
  17446. };
  17447. MOZ_TO_ME[moztype] = moz_to_me;
  17448. def_to_moz(mytype, me_to_moz);
  17449. return;
  17450. }
  17451. var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
  17452. moz_to_me += "return new " + mytype.name + "({\n" + "start: my_start_token(M),\n" + "end: my_end_token(M)";
  17453. var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
  17454. me_to_moz += "return {\n" + "type: " + JSON.stringify(moztype);
  17455. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  17456. var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
  17457. if (!m) throw new Error("Can't understand property map: " + prop);
  17458. var moz = m[1], how = m[2], my = m[3];
  17459. moz_to_me += ",\n" + my + ": ";
  17460. me_to_moz += ",\n" + moz + ": ";
  17461. switch (how) {
  17462. case "@":
  17463. moz_to_me += "M." + moz + ".map(from_moz)";
  17464. me_to_moz += "M." + my + ".map(to_moz)";
  17465. break;
  17466. case ">":
  17467. moz_to_me += "from_moz(M." + moz + ")";
  17468. me_to_moz += "to_moz(M." + my + ")";
  17469. break;
  17470. case "=":
  17471. moz_to_me += "M." + moz;
  17472. me_to_moz += "M." + my;
  17473. break;
  17474. case "%":
  17475. moz_to_me += "from_moz(M." + moz + ").body";
  17476. me_to_moz += "to_moz_block(M)";
  17477. break;
  17478. default:
  17479. throw new Error("Can't understand operator in propmap: " + prop);
  17480. }
  17481. });
  17482. moz_to_me += "\n})\n}";
  17483. me_to_moz += "\n}\n}";
  17484. moz_to_me = new Function("my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(my_start_token, my_end_token, from_moz);
  17485. me_to_moz = new Function("to_moz", "to_moz_block", "return(" + me_to_moz + ")")(to_moz, to_moz_block);
  17486. MOZ_TO_ME[moztype] = moz_to_me;
  17487. def_to_moz(mytype, me_to_moz);
  17488. }
  17489. var FROM_MOZ_STACK = null;
  17490. function from_moz(node) {
  17491. FROM_MOZ_STACK.push(node);
  17492. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  17493. FROM_MOZ_STACK.pop();
  17494. return ret;
  17495. }
  17496. AST_Node.from_mozilla_ast = function(node) {
  17497. var save_stack = FROM_MOZ_STACK;
  17498. FROM_MOZ_STACK = [];
  17499. var ast = from_moz(node);
  17500. FROM_MOZ_STACK = save_stack;
  17501. return ast;
  17502. };
  17503. function moz_sub_loc(token) {
  17504. return token.line ? {
  17505. line: token.line,
  17506. column: token.col
  17507. } : null;
  17508. }
  17509. function set_moz_loc(mynode, moznode) {
  17510. var start = mynode.start;
  17511. var end = mynode.end;
  17512. if (start.pos != null && end.pos != null) {
  17513. moznode.range = [ start.pos, end.pos ];
  17514. }
  17515. if (start.line) {
  17516. moznode.loc = {
  17517. start: moz_sub_loc(start),
  17518. end: moz_sub_loc(end)
  17519. };
  17520. if (start.file) {
  17521. moznode.loc.source = start.file;
  17522. }
  17523. }
  17524. return moznode;
  17525. }
  17526. function def_to_moz(mytype, handler) {
  17527. mytype.DEFMETHOD("to_mozilla_ast", function() {
  17528. return set_moz_loc(this, handler(this));
  17529. });
  17530. }
  17531. function to_moz(node) {
  17532. return node != null ? node.to_mozilla_ast() : null;
  17533. }
  17534. function to_moz_block(node) {
  17535. return {
  17536. type: "BlockStatement",
  17537. body: node.body.map(to_moz)
  17538. };
  17539. }
  17540. })();
  17541. exports["array_to_hash"] = array_to_hash;
  17542. exports["slice"] = slice;
  17543. exports["characters"] = characters;
  17544. exports["member"] = member;
  17545. exports["find_if"] = find_if;
  17546. exports["repeat_string"] = repeat_string;
  17547. exports["DefaultsError"] = DefaultsError;
  17548. exports["defaults"] = defaults;
  17549. exports["merge"] = merge;
  17550. exports["noop"] = noop;
  17551. exports["MAP"] = MAP;
  17552. exports["push_uniq"] = push_uniq;
  17553. exports["string_template"] = string_template;
  17554. exports["remove"] = remove;
  17555. exports["mergeSort"] = mergeSort;
  17556. exports["set_difference"] = set_difference;
  17557. exports["set_intersection"] = set_intersection;
  17558. exports["makePredicate"] = makePredicate;
  17559. exports["all"] = all;
  17560. exports["Dictionary"] = Dictionary;
  17561. exports["DEFNODE"] = DEFNODE;
  17562. exports["AST_Token"] = AST_Token;
  17563. exports["AST_Node"] = AST_Node;
  17564. exports["AST_Statement"] = AST_Statement;
  17565. exports["AST_Debugger"] = AST_Debugger;
  17566. exports["AST_Directive"] = AST_Directive;
  17567. exports["AST_SimpleStatement"] = AST_SimpleStatement;
  17568. exports["walk_body"] = walk_body;
  17569. exports["AST_Block"] = AST_Block;
  17570. exports["AST_BlockStatement"] = AST_BlockStatement;
  17571. exports["AST_EmptyStatement"] = AST_EmptyStatement;
  17572. exports["AST_StatementWithBody"] = AST_StatementWithBody;
  17573. exports["AST_LabeledStatement"] = AST_LabeledStatement;
  17574. exports["AST_IterationStatement"] = AST_IterationStatement;
  17575. exports["AST_DWLoop"] = AST_DWLoop;
  17576. exports["AST_Do"] = AST_Do;
  17577. exports["AST_While"] = AST_While;
  17578. exports["AST_For"] = AST_For;
  17579. exports["AST_ForIn"] = AST_ForIn;
  17580. exports["AST_With"] = AST_With;
  17581. exports["AST_Scope"] = AST_Scope;
  17582. exports["AST_Toplevel"] = AST_Toplevel;
  17583. exports["AST_Lambda"] = AST_Lambda;
  17584. exports["AST_Accessor"] = AST_Accessor;
  17585. exports["AST_Function"] = AST_Function;
  17586. exports["AST_Defun"] = AST_Defun;
  17587. exports["AST_Jump"] = AST_Jump;
  17588. exports["AST_Exit"] = AST_Exit;
  17589. exports["AST_Return"] = AST_Return;
  17590. exports["AST_Throw"] = AST_Throw;
  17591. exports["AST_LoopControl"] = AST_LoopControl;
  17592. exports["AST_Break"] = AST_Break;
  17593. exports["AST_Continue"] = AST_Continue;
  17594. exports["AST_If"] = AST_If;
  17595. exports["AST_Switch"] = AST_Switch;
  17596. exports["AST_SwitchBranch"] = AST_SwitchBranch;
  17597. exports["AST_Default"] = AST_Default;
  17598. exports["AST_Case"] = AST_Case;
  17599. exports["AST_Try"] = AST_Try;
  17600. exports["AST_Catch"] = AST_Catch;
  17601. exports["AST_Finally"] = AST_Finally;
  17602. exports["AST_Definitions"] = AST_Definitions;
  17603. exports["AST_Var"] = AST_Var;
  17604. exports["AST_Const"] = AST_Const;
  17605. exports["AST_VarDef"] = AST_VarDef;
  17606. exports["AST_Call"] = AST_Call;
  17607. exports["AST_New"] = AST_New;
  17608. exports["AST_Seq"] = AST_Seq;
  17609. exports["AST_PropAccess"] = AST_PropAccess;
  17610. exports["AST_Dot"] = AST_Dot;
  17611. exports["AST_Sub"] = AST_Sub;
  17612. exports["AST_Unary"] = AST_Unary;
  17613. exports["AST_UnaryPrefix"] = AST_UnaryPrefix;
  17614. exports["AST_UnaryPostfix"] = AST_UnaryPostfix;
  17615. exports["AST_Binary"] = AST_Binary;
  17616. exports["AST_Conditional"] = AST_Conditional;
  17617. exports["AST_Assign"] = AST_Assign;
  17618. exports["AST_Array"] = AST_Array;
  17619. exports["AST_Object"] = AST_Object;
  17620. exports["AST_ObjectProperty"] = AST_ObjectProperty;
  17621. exports["AST_ObjectKeyVal"] = AST_ObjectKeyVal;
  17622. exports["AST_ObjectSetter"] = AST_ObjectSetter;
  17623. exports["AST_ObjectGetter"] = AST_ObjectGetter;
  17624. exports["AST_Symbol"] = AST_Symbol;
  17625. exports["AST_SymbolAccessor"] = AST_SymbolAccessor;
  17626. exports["AST_SymbolDeclaration"] = AST_SymbolDeclaration;
  17627. exports["AST_SymbolVar"] = AST_SymbolVar;
  17628. exports["AST_SymbolConst"] = AST_SymbolConst;
  17629. exports["AST_SymbolFunarg"] = AST_SymbolFunarg;
  17630. exports["AST_SymbolDefun"] = AST_SymbolDefun;
  17631. exports["AST_SymbolLambda"] = AST_SymbolLambda;
  17632. exports["AST_SymbolCatch"] = AST_SymbolCatch;
  17633. exports["AST_Label"] = AST_Label;
  17634. exports["AST_SymbolRef"] = AST_SymbolRef;
  17635. exports["AST_LabelRef"] = AST_LabelRef;
  17636. exports["AST_This"] = AST_This;
  17637. exports["AST_Constant"] = AST_Constant;
  17638. exports["AST_String"] = AST_String;
  17639. exports["AST_Number"] = AST_Number;
  17640. exports["AST_RegExp"] = AST_RegExp;
  17641. exports["AST_Atom"] = AST_Atom;
  17642. exports["AST_Null"] = AST_Null;
  17643. exports["AST_NaN"] = AST_NaN;
  17644. exports["AST_Undefined"] = AST_Undefined;
  17645. exports["AST_Hole"] = AST_Hole;
  17646. exports["AST_Infinity"] = AST_Infinity;
  17647. exports["AST_Boolean"] = AST_Boolean;
  17648. exports["AST_False"] = AST_False;
  17649. exports["AST_True"] = AST_True;
  17650. exports["TreeWalker"] = TreeWalker;
  17651. exports["KEYWORDS"] = KEYWORDS;
  17652. exports["KEYWORDS_ATOM"] = KEYWORDS_ATOM;
  17653. exports["RESERVED_WORDS"] = RESERVED_WORDS;
  17654. exports["KEYWORDS_BEFORE_EXPRESSION"] = KEYWORDS_BEFORE_EXPRESSION;
  17655. exports["OPERATOR_CHARS"] = OPERATOR_CHARS;
  17656. exports["RE_HEX_NUMBER"] = RE_HEX_NUMBER;
  17657. exports["RE_OCT_NUMBER"] = RE_OCT_NUMBER;
  17658. exports["RE_DEC_NUMBER"] = RE_DEC_NUMBER;
  17659. exports["OPERATORS"] = OPERATORS;
  17660. exports["WHITESPACE_CHARS"] = WHITESPACE_CHARS;
  17661. exports["PUNC_BEFORE_EXPRESSION"] = PUNC_BEFORE_EXPRESSION;
  17662. exports["PUNC_CHARS"] = PUNC_CHARS;
  17663. exports["REGEXP_MODIFIERS"] = REGEXP_MODIFIERS;
  17664. exports["UNICODE"] = UNICODE;
  17665. exports["is_letter"] = is_letter;
  17666. exports["is_digit"] = is_digit;
  17667. exports["is_alphanumeric_char"] = is_alphanumeric_char;
  17668. exports["is_unicode_combining_mark"] = is_unicode_combining_mark;
  17669. exports["is_unicode_connector_punctuation"] = is_unicode_connector_punctuation;
  17670. exports["is_identifier"] = is_identifier;
  17671. exports["is_identifier_start"] = is_identifier_start;
  17672. exports["is_identifier_char"] = is_identifier_char;
  17673. exports["is_identifier_string"] = is_identifier_string;
  17674. exports["parse_js_number"] = parse_js_number;
  17675. exports["JS_Parse_Error"] = JS_Parse_Error;
  17676. exports["js_error"] = js_error;
  17677. exports["is_token"] = is_token;
  17678. exports["EX_EOF"] = EX_EOF;
  17679. exports["tokenizer"] = tokenizer;
  17680. exports["UNARY_PREFIX"] = UNARY_PREFIX;
  17681. exports["UNARY_POSTFIX"] = UNARY_POSTFIX;
  17682. exports["ASSIGNMENT"] = ASSIGNMENT;
  17683. exports["PRECEDENCE"] = PRECEDENCE;
  17684. exports["STATEMENTS_WITH_LABELS"] = STATEMENTS_WITH_LABELS;
  17685. exports["ATOMIC_START_TOKEN"] = ATOMIC_START_TOKEN;
  17686. exports["parse"] = parse;
  17687. exports["TreeTransformer"] = TreeTransformer;
  17688. exports["SymbolDef"] = SymbolDef;
  17689. exports["base54"] = base54;
  17690. exports["OutputStream"] = OutputStream;
  17691. exports["Compressor"] = Compressor;
  17692. exports["SourceMap"] = SourceMap;
  17693. })({}, function() {
  17694. return this;
  17695. }());
  17696. },{}],"OmegaPac":[function(require,module,exports){
  17697. var name, ref, value;
  17698. module.exports = {
  17699. Conditions: require('./src/conditions'),
  17700. PacGenerator: require('./src/pac_generator'),
  17701. Profiles: require('./src/profiles'),
  17702. RuleList: require('./src/rule_list'),
  17703. ShexpUtils: require('./src/shexp_utils')
  17704. };
  17705. ref = require('./src/utils.coffee');
  17706. for (name in ref) {
  17707. value = ref[name];
  17708. module.exports[name] = value;
  17709. }
  17710. },{"./src/conditions":61,"./src/pac_generator":62,"./src/profiles":63,"./src/rule_list":64,"./src/shexp_utils":65,"./src/utils.coffee":66}]},{},["OmegaPac"])("OmegaPac")
  17711. });